Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. Import-Module ActiveDirectory
  2.  
  3. #Chemin export CSV
  4. $resultPath = "C:\temp\adusers.csv"
  5. #$userCSV
  6.  
  7. #TargetAddress null par défaut
  8. $adusers = Get-ADUser * -Properties *
  9.  
  10. $Results = @()
  11.  
  12. foreach ($user in $adusers)
  13. {
  14. $Properties = @{
  15.  
  16. UserPrincipalName = $user.UserPrincipalName
  17. sAMAccountName = $user.sAMAccountName
  18. DisplayName = $user.DisplayName
  19. Mail = $user.Mail
  20. PrimarySMTP = $user.ProxyAddresses | Where-object -filterscript {$_ -like "SMTP:"}
  21. # W Alias = $user.ProxyAddresses | Where-object -filterscript {$_ -like "smtp:"} -join “;”
  22. # W SipProxyAddress = $user.ProxyAddresses | Where-object -filterscript {$_ -like "sip:"}
  23.  
  24. }
  25.  
  26. $Results += New-Object psobject -Property $Properties | Export-Csv -Path $resultPath -Encoding UTF8 -NoTypeInformation -Append
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement