Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Import-Module ActiveDirectory
- #Chemin export CSV
- $resultPath = "C:\temp\adusers.csv"
- #$userCSV
- #TargetAddress null par défaut
- $adusers = Get-ADUser * -Properties *
- $Results = @()
- foreach ($user in $adusers)
- {
- $Properties = @{
- UserPrincipalName = $user.UserPrincipalName
- sAMAccountName = $user.sAMAccountName
- DisplayName = $user.DisplayName
- Mail = $user.Mail
- PrimarySMTP = $user.ProxyAddresses | Where-object -filterscript {$_ -like "SMTP:"}
- # W Alias = $user.ProxyAddresses | Where-object -filterscript {$_ -like "smtp:"} -join “;”
- # W SipProxyAddress = $user.ProxyAddresses | Where-object -filterscript {$_ -like "sip:"}
- }
- $Results += New-Object psobject -Property $Properties | Export-Csv -Path $resultPath -Encoding UTF8 -NoTypeInformation -Append
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement