如何获取过去6个月内被禁用的AD用户,以及以ddMMyyyy格式作为.CSV文件的禁用时间戳?
比如使用这个Powershell https:/docs.microsoft.comen-uspowershellmoduleaddsadministrationget-aduser?view=win10-ps。 ?
$paramhash=@{
UsersOnly = $True
AccountDisabled = $True
SearchBase = "OU=Employees,DC=globomantics,dc=local"
}
Search-ADAccount @paramHash |
Get-ADuser -Properties Description,Department,Title,LastLogonDate,WhenChanged |
sort LastLogonDate |
Select Name,Department,Title,Description,WhenChanged,LastLogonDate,DistinguishedName |
out-gridview -title "Disabled Employees"
而不是使用 Out-GridView
显示结果,您需要将它们保存到一个文件中。 您可以通过使用 Export-Csv
像这样。
Export-Csv '.\DisabledEmployees.csv' -NoTypeInformation
清楚的说,只要把 Out-GridView
在管道末端的线路与这条线路。