问题描述
如何以dd/MM/yyyy格式获取过去6个月内被禁用的AD用户以及禁用时的时间戳为.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/en-us/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 用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!