【问题标题】:Get AD Computers from list of members in O365 Group从 O365 组的成员列表中获取 AD 计算机
【发布时间】:2021-09-01 10:04:18
【问题描述】:

我正在尝试从 O365 中的某个组中获取成员列表,然后使用该列表获取所有 Active Directory 计算机。

要获取成员列表:

$list = Get-UnifiedGroup -Identity "Group Name" | Get-UnifiedGroupLinks -LinkType Member | Select DisplayName

然后获取计算机:

foreach($user in $list) {
  Get-ADComputer -Filter "Description -like '$user'" -Property Name,Description | Select -Property Name
}

但是当我运行第二个命令时没有任何反应。我可以看到 $list 在我调用它时已填充。任何人都知道我做错了什么或更好的方法吗?请记住,我对 powershell 了解不多。

【问题讨论】:

  • 尝试将"Description -like '$user'"更改为"Description -like '$($user.DisplayName)'""Description -like '*$($user.DisplayName)*'"
  • 成功了!谢谢!

标签: powershell active-directory office365 exchange-server


【解决方案1】:

"Description -like '$user'" 更改为"Description -like '$($user.DisplayName)'"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-26
    • 1970-01-01
    • 2011-07-01
    • 1970-01-01
    • 2020-06-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多