我試圖刪除AD組成員資格的帳戶已被禁用,但不知道如何正確合併cmdlet的用戶列表。這是我嘗試...Powershell 2.0 - 刪除組成員的已禁用帳戶列表
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
非常好!這工作!並且,謝謝你的明確解釋。 – user2731132
如果查找相同的解決方案,請使用users.csv更新後面的文章以供他人蔘考。謝謝你,阿迪因巴爾 – user2731132
@ user2731132每當你的問題是在StackOverflow上回答,而不是發佈評論感謝回答者(這往往最終被MODS得到刪除),請註明答案最點擊綠色解決了一個問題,「接受」查馬克的回答左側:meta.stackoverflow.com/help/someone-answers。另外,當你接受答案時,你獲得+2代表。 ) –