0

In an ActiveDirectory Export I want the mail adresses in all lowercase, I know about ToLower() but I'm struggling putting it in the right place:

(Powershell)

Get-ADUser 
-SearchBase "OU=11-something,DC=somethingelse,DC=somethingelser" 
-Filter {somefilters} -Properties name,mail
|Select-Object  Name,(mail).ToLower()
| Export-Csv -Path "D:\Path" 
 -Encoding UTF8 -NoTypeInformation

Is it even possible with Get-ADUser ?

chris
  • 181
  • 2
  • 18

1 Answers1

6

You can customize the Select-Object output using a calculated property:

Get-ADUser -SearchBase "OU=11-something,DC=somethingelse,DC=somethingelser" 
-Filter {somefilters} -Properties name,mail
|Select-Object Name,@{N="Email";E={$_.mail.ToLower()}}
| Export-Csv -Path "D:\Path" 
 -Encoding UTF8 -NoTypeInformation

See: Select-Object Documentation

mklement0
  • 382,024
  • 64
  • 607
  • 775
Avshalom
  • 8,657
  • 1
  • 25
  • 43