下面的代碼應該計數和比較用戶並輸出總計數,但不知何故結果爲空。我需要做些什麼來解決它?計數Active Directory用戶
$groups = $A_group, $B_Group
$gm = @()
foreach ($group in $groups) {
$gm += Get-ADGroupMember $group -Recursive |
`where {$_.objectclass -eq 'user'} |`
' select SamAccountName'
}
($gm.samaccountname | Select -Unique).Count
Write-Output total: ($gm.samaccountname | Select -Unique).Count
您的管線語法已損壞。刪除反引號和單引號。 –