Powershell 需要拉取所有具有SIDhistory但从未登录的用户

Powershell 需要拉取所有具有SIDhistory但从未登录的用户,powershell,active-directory,powershell-2.0,powershell-3.0,Powershell,Active Directory,Powershell 2.0,Powershell 3.0,我正在尝试收集一个脚本,以获取所有具有SIDhistory但从未使用过其帐户的用户的列表,并将其转储到CSV中。这就是我目前所拥有的 获取aduser-filter{sidhistory-like“*”}-properties lastLogonData |导出csv c:\users\desktop\sidhistoryneverloggedin.csv 我可以得到一个包含SID历史记录的所有用户的列表,但我不知道如何只提取那些没有登录活动的用户 谢谢你的帮助 管道将其穿过以下对象: Get

我正在尝试收集一个脚本,以获取所有具有SIDhistory但从未使用过其帐户的用户的列表,并将其转储到CSV中。这就是我目前所拥有的

获取aduser-filter{sidhistory-like“*”}-properties lastLogonData |导出csv c:\users\desktop\sidhistoryneverloggedin.csv

我可以得到一个包含SID历史记录的所有用户的列表,但我不知道如何只提取那些没有登录活动的用户


谢谢你的帮助

管道将其穿过以下对象:

 Get-aduser -filter {sidhistory -like "*"} -properties lastlogondate | Where-Object {$_.lastlogondate -eq $null} | Export-Csv output.csv
如果帐户从未登录,则lastlogindate属性将为$null