Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Single User
- <#
- $User = Get-ADUser -Identity Test -Properties *
- $Output = [PSCustomObject]@{
- GivenName = $User.GivenName
- Surname = $User.Surname
- Title = $User.Title
- Mail = $User.Mail
- Mobile = $User.Mobile
- Company = $User.Company
- Location = $User.location
- Manager = $User.Manager.ToString()
- }
- Return $Output
- $Output | Export-Csv C:\Export.csv -NoTypeInformation -Encoding UTF8
- #>
- #Define CSV Output
- $CSVOutput = New-Object System.Collections.ArrayList
- $Users = Get-ADUser -Filter {(mail -ne "null") -and (Enabled -eq "true")} -Properties *
- Foreach ($User in $Users) {
- $Output = [PSCustomObject]@{
- GivenName = $User.GivenName
- Surname = $User.Surname
- Title = $User.Title
- Mail = $User.Mail
- Mobile = $User.Mobile
- Company = $User.Company
- Location = $User.location
- Manager = $User.Manager
- ProxyAddresses = $User.proxyAddresses -join ";"
- }
- $CSVOutput.Add($Output)
- }
- $CSVOutput | Export-CSV C:\ExportCSV.csv -NoTypeInformation -Encoding UTF8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement