2023/04/19

匯出AD網域所有使用者密碼更新日期、到期日期

 

此為 powershell 執行片段,可以將下方程式碼存於 c:\ss\get_user_pwd_expire.ps1,然後以管理者執行 powershell (以一般 powershell 可能會取出空值),最後會將結果寫入到 c:\ss\get_user_pwd_expire.log 記錄檔

date > c:\ss\get_user_pwd_expire.log

Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False} -SearchBase "OU=Lala-Users,DC=lala,DC=com" -Properties "DisplayName", "msDS-UserPasswordExpiryTimeComputed","passwordlastset","Passwordneverexpires","LockedOut" | Select-Object -Property "Displayname","passwordlastset",@{Name="ExpiryDate";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}},"Passwordneverexpires","LockedOut" | ft >> c:\ss\get_user_pwd_expire.log


請將標記紅色字部分改為適合自己的內容。


Reference:https://blog.dino9021.com/2021/10/ou.html 

~END

沒有留言:

張貼留言

Ubuntu 如何查看及變更時區 TimeZone

使用指令 timedatectl 查看目前 ubuntu 的時區設定 $ timedatectl 列出所有 Asia 的時區 $ timedatectl list-timezones | grep Asia 變更時區為 Asia/Taipei $ sudo timedatectl...