heyvOOn

PowerShell - Export proxyAddresses from OU

Nov 7th, 2020 (edited)
2,433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Import-Module ActiveDirectory
  2.  
  3. Get-ADUser -Filter * -SearchBase "OU=Users,OU=Accounts,OU=centile,OU=enreach,DC=voiceworks,DC=local" -Properties proxyAddresses | ForEach {
  4.     ForEach ($Address in $_.proxyAddresses) {
  5.         [pscustomobject]@{
  6.             User = $_.Name
  7.             UPN = $_.UserPrincipalNAme
  8.             ProxyAddress = $Address
  9.         }
  10.     }
  11. } | Export-Csv -Path "C:\Scripts\AndreB\ExportedCSVs\CENTILE-UsersProxy$(get-date -f yyyy-MM-dd-HHmmss).csv" -NoTypeInformation
Add Comment
Please, Sign In to add comment