我正在尝试删除帐户已被禁用但不确定如何正确组合 cmdlet 的用户列表的 AD 组成员身份。这是我的尝试...
Import-CSV T:\temp\users.csv | ForEach-Object {Get-ADPrincipalGroupMembership -Identity $_.member | ForEach-Object {Remove-ADPrincipalGroupMembership -Identity $_.member -MemberOf SamAccountName}}
users.csv(文件内容如下)
member
testuser1
testuser2
testuser3
我收到以下消息...
Remove-ADPrincipalGroupMembership : Cannot convert 'Microsoft.ActiveDirectory.Management.ADPropertyValueCollection' to
the type 'Microsoft.ActiveDirectory.Management.ADPrincipal' required by parameter 'Identity'. Specified method is not s
upported.
At line:1 char:160
+ Import-CSV T:\temp\users.csv | ForEach-Object {Get-ADPrincipalGroupMembership -Identity $_.member | ForEach-Object {R
emove-ADPrincipalGroupMembership -Identity <<<< $_.member -MemberOf SamAccountName}}
+ CategoryInfo : InvalidArgument: (:) [Remove-ADPrincipalGroupMembership], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Microsoft.ActiveDirectory.Management.Commands.RemoveADPrincipalGro
upMembership