
我正在嘗試在 powershell 中輸出某個群組中的所有 AD 用戶,但電子郵件地址欄位中沒有資料。
我有以下命令:
get-aduser -filter * -properties * | where {!$_.emailaddress} | select-object samaccountname | export-csv c:\email\noemailusers.csv
但我試圖將結果範圍縮小到僅屬於特定群組成員的使用者。
任何幫助深表感謝!
答案1
從群組開始,取得成員清單;取得每個群組成員的 AD 使用者物件;檢查使用者是否有電子郵件地址。
Get-ADGroupMember $yourgroup | Get-ADUser -Properties mail | where { $_.mail -eq $null }