【问题标题】:Get all users in an ADgroup with the displayname使用显示名称获取 ADgroup 中的所有用户
【发布时间】:2018-04-17 20:26:23
【问题描述】:

我正在尝试从 csv 获取组列表的成员。我在下面创建的脚本输出了组名。我的问题是:我想获取 DisplayName 而不是用户名。

get-content "C:\temp\glist.csv" | foreach {get-adgroup -identity "$_" -properties * | select Name,Description, @{n='Members';e={$_.members -replace '^cn=([^,]+).+$','$1' -join '; '}} | export-csv "C:\temp\group_info $currentdate.csv" -NoTypeInformation -Encoding UTF8}

【问题讨论】:

    标签: powershell export-to-csv


    【解决方案1】:

    我不确定我是否完全理解您可以退出哪个属性,但试试这个,它将为每个组成员获取 Name 属性:

    Get-Content "C:\temp\glist.csv" `
        | ForEach {
            Get-ADGroup -Properties * -Filter * | select Name, Description, @{n='Members';e={($_.Members | Get-ADObject -Properties Name) -replace '^cn=([^,]+).+$','$1' -join '; '}} `
          } `
        | export-csv "C:\temp\group_info $currentdate.csv" -NoTypeInformation -Encoding UTF8
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-30
      • 2023-03-05
      • 2020-10-15
      • 1970-01-01
      相关资源
      最近更新 更多