【问题标题】:Powershell to get AD user disabled in the past 6 months?Powershell 在过去 6 个月内禁用 AD 用户?
【发布时间】:2020-08-15 22:07:10
【问题描述】:

如何获取过去6个月内被禁用的AD用户以及dd/MM/yyyy格式为.CSV文件被禁用时的时间戳?

喜欢使用这个 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"

【问题讨论】:

    标签: powershell active-directory azure-active-directory powershell-4.0 powershell-remoting


    【解决方案1】:

    您需要将结果保存到文件中,而不是使用Out-GridView 来显示结果。您可以像这样使用 Export-Csv 以 CSV 格式轻松完成此操作。

    Export-Csv '.\DisabledEmployees.csv' -NoTypeInformation
    

    为了清楚起见,只需将管道末尾的Out-GridView 行替换为该行即可。

    【讨论】:

    • 谢谢,菲尔,这正是我需要的 :-)
    猜你喜欢
    • 2020-08-15
    • 2020-04-02
    • 2020-08-04
    • 2021-02-21
    • 1970-01-01
    • 2019-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多