SHARE
TWEET

Untitled

a guest Sep 17th, 2019 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top