I am just starting to learn about PowerShell and can already see how useful it will be. I am trying to create a small script that will search AD for accounts expiring within a specific time frame, then output the Display name, account expiration date and email address to csv.
The problem I am running into with this simple script is that I can't figure out how to get it to poll the AD attribute for email address and add it to the csv. When I add EmailAddress to Select-Object it just returns "Microsoft.ActiveDirectory.Management.ADPropertyValueCollection"
If anyone has any suggestions, or alternative ways to do this, I would appreciate the input.
..Import-Module ActiveDirectory Search-ADAccount -AccountExpiring -TimeSpan "120" | Select-Object Name,AccountExpirationDate | Sort-Object AccountExpirationDate | Export-Csv Expiring-Accounts.csv
↧