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

Need to pull all users with SIDhistory but have never logged in

我正在尝试编写一个脚本来提取所有具有 SIDhistory 但从未使用过他们的帐户的用户的列表并将其转储到 CSV 中。这是我目前所拥有的。

Get-aduser -filter {sidhistory -like "*"} -properties lastlogondate |导出 csv c:\users\desktop\sidhistoryneverloggedin.csv

我知道我可以获得所有具有 SID 历史记录的用户的列表,但我不知道如何只提取没有登录的用户 activity。

感谢您的帮助!

像这样通过 Where-Object 进行管道传输:

 Get-aduser -filter {sidhistory -like "*"} -properties lastlogondate | Where-Object {$_.lastlogondate -eq $null} | Export-Csv output.csv

如果帐户从未登录过,lastlogindate 属性将为 $null。