Powershell 我需要识别所有具有迁移历史记录的用户
我正在尝试获取一个powershell脚本,以遍历我们域中的所有用户,并查找他们是否在SIDhistory属性中有SIDhistory。然后,我需要将此用户列表导出到csv,因为我需要删除所有没有历史记录的帐户。我仍在学习powershell,但到目前为止,我已经找到了个人用户的历史记录。(导出CSV部分工作不正常) dsquery*-Filter“(samaccountname=USERID)”-Attr samaccountname ObjectSID sidHistory | export csv-path C:\Desktop\insertcsv.csv-notypeinformation 谢谢你能提供的任何帮助,我真的很感激 tl;dr-我需要将所有具有空SIDhistory属性的用户拉入csv,这非常简单Powershell 我需要识别所有具有迁移历史记录的用户,powershell,active-directory,Powershell,Active Directory,我正在尝试获取一个powershell脚本,以遍历我们域中的所有用户,并查找他们是否在SIDhistory属性中有SIDhistory。然后,我需要将此用户列表导出到csv,因为我需要删除所有没有历史记录的帐户。我仍在学习powershell,但到目前为止,我已经找到了个人用户的历史记录。(导出CSV部分工作不正常) dsquery*-Filter“(samaccountname=USERID)”-Attr samaccountname ObjectSID sidHistory | export
Get-aduser -filter * -properties sidhistory | Where sidhistory
这将首先返回所有用户,然后指示PowerShell也返回
sidhistory
属性(如果存在)。然后我们使用Where Object
进行过滤,只返回具有该属性的帐户。类似于get aduser-filter{!(SIDhistory=*)}-prop ObjectSID,SIDhistory |选择SamAccountName,ObjectSID,SIDhistory | ExportCsv$env:USERPROFILE\Desktop\NoSIDHistory.csv-notype这样的东西怎么样