使用Powershell在过去6个月中禁用AD用户? [英] Powershell to get AD user disabled in the past 6 months?
问题描述
如何获取在过去6个月中被禁用的AD用户以及以dd / mm / yyyy格式作为CSV文件被禁用的时间戳?
How to get the AD user that was disabled in the past 6 months and also the time stamp when it was disabled in dd/MM/yyyy format as.CSV file?
就像使用此Powershell一样 https ://docs.microsoft.com/zh-cn/powershell/module/addsadministration/get-aduser?view = win10-ps ?
Like using this Powershell https://docs.microsoft.com/en-us/powershell/module/addsadministration/get-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
这样轻松地以CSV格式完成操作。
Instead of using Out-GridView
to display the results, you need to save them to a file. You can do that easily in the CSV format by using Export-Csv
like this.
Export-Csv '.\DisabledEmployees.csv' -NoTypeInformation
只需用该行替换管道末尾的 Out-GridView
行。
To be clear, just replace the Out-GridView
line at the end of the pipeline with this line.
这篇关于使用Powershell在过去6个月中禁用AD用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!