windows:powershell:fetch_all_exchange_mail_addresses
Differences
This shows you the differences between two versions of the page.
| windows:powershell:fetch_all_exchange_mail_addresses [2015/01/12 11:50] – created biggi | windows:powershell:fetch_all_exchange_mail_addresses [2015/08/15 22:56] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | Once in a while I need to do some Windows management. This time I needed to extract a list of all mail addresses in specific active directory containers. Both the " | ||
| + | < | ||
| + | $countrylist = " | ||
| + | $oulist = " | ||
| + | |||
| + | Write-Output " | ||
| + | Write-Output " | ||
| + | Write-Output " | ||
| + | |||
| + | foreach ($country in $countrylist) { | ||
| + | Write-Output " | ||
| + | If (Test-Path C: | ||
| + | Clear-Content C: | ||
| + | } | ||
| + | |||
| + | foreach ($ou in $oulist) { | ||
| + | Write-Output " | ||
| + | |||
| + | $mailaddr = Get-Mailbox -OrganizationalUnit " | ||
| + | $mailaddr | ForEach-Object {$_.PrimarySmtpAddress} | Add-Content C: | ||
| + | $mailaddr | ForEach-Object {$_.EmailAddresses -replace(" | ||
| + | } | ||
| + | } | ||
| + | </ | ||
