Advertisement
Guest User

Untitled

a guest
Jul 11th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Single User
  2. <#
  3. $User = Get-ADUser -Identity Test -Properties *
  4.  
  5. $Output = [PSCustomObject]@{
  6.         GivenName = $User.GivenName
  7.         Surname = $User.Surname
  8.         Title = $User.Title
  9.         Mail = $User.Mail
  10.         Mobile = $User.Mobile
  11.         Company = $User.Company
  12.         Location = $User.location
  13.         Manager = $User.Manager.ToString()
  14.     }
  15.  
  16. Return $Output
  17.  
  18. $Output | Export-Csv C:\Export.csv -NoTypeInformation -Encoding UTF8  
  19. #>
  20.  
  21. #Define CSV Output
  22. $CSVOutput = New-Object System.Collections.ArrayList
  23.  
  24. $Users = Get-ADUser -Filter {(mail -ne "null") -and (Enabled -eq "true")} -Properties *
  25. Foreach ($User in $Users) {    
  26.    
  27.    
  28.  
  29.     $Output = [PSCustomObject]@{
  30.         GivenName = $User.GivenName
  31.         Surname = $User.Surname
  32.         Title = $User.Title
  33.         Mail = $User.Mail
  34.         Mobile = $User.Mobile
  35.         Company = $User.Company
  36.         Location = $User.location
  37.         Manager = $User.Manager
  38.         ProxyAddresses = $User.proxyAddresses -join ";"        
  39.     }
  40.    
  41.     $CSVOutput.Add($Output)  
  42.  
  43. }
  44.  
  45.  
  46. $CSVOutput | Export-CSV C:\ExportCSV.csv -NoTypeInformation -Encoding UTF8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement