Displayname to SamAccountName
Hello, I am using Exchange 2007 / windows server 2003. I sometimes use the get-content command to extract information from a list of SamAccountName (eg:Get-Content c:\SAN.txt | Get-Mailbox) However, it occurs that I receive displayname instead of SAN like 'user name'. An it doesn't allow me to use the get-content command. Is there any chance to make it work with a displayname?? Thanks, Graig
May 21st, 2010 12:49pm

Hi, Put your value in double quotes in your test file like this "user name" and then check. If it doesnt work then change the extension of your file into .CSV and then use import-CSV command but dont forget to put duouble quotes around your values in csv file. Regards,Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
Free Windows Admin Tool Kit Click here and download it now
May 21st, 2010 1:34pm

Works for me with both displayname and samaccountname. What format are your displaynames in?$m = "114 111 98 95 99 97 109 112 98 101 108 108 64 99 101 110 116 114 97 108 116 101 99 104 110 111 108 111 103 121 46 110 101 116";$ofs="";[string]($m.Split() |% {[char][int]$_})
May 21st, 2010 3:33pm

Alot of times people have both the Alias and the SamAccountName as the same value, so if that is not the case for you try appending your domain\SamAccountName and see if that helps. -Identity <MailboxIdParameter> The Identity parameter identifies the mailbox. You can use one of the following values: * GUID * Distinguished name (DN) * Domain\Account * User principal name (UPN) * LegacyExchangeDN * SmtpAddress * AliasExchange & Powershell Geek MCITP: Enterprise Messaging Administrator MCITP: Enterprise Messaging Administrator 2010
Free Windows Admin Tool Kit Click here and download it now
May 21st, 2010 4:44pm

Hi, Any updates? I also works with both SAN and displayname. You can also post the error message : "it doesn't allow me to use the get-content command."Frank Wang
May 24th, 2010 9:03am

Sorry for late reply: import-CSV c:\test.csv | get-mailbox Does not work I also tried: Get-content c:\test.txt | Get-mailbox Does not work The txt or csv file= "firstname lastname"
Free Windows Admin Tool Kit Click here and download it now
May 25th, 2010 12:45pm

Sorry for late reply: import-CSV c:\test.csv | get-mailbox Does not work I also tried: Get-content c:\test.txt | Get-mailbox Does not work The txt or csv file= "firstname lastname" Sorry double quotes wont work with text files. I put display name without the double quotes in text file and command ran successfully The txt file= firstname lastname1 firstname lastname2 Get-content c:\test.txt | Get-mailbox For CSV File, put a heading on top of the column like this DisplayName "firstname lastname1" "firstname lastname2" And then run the command. import-csv c:\test.csv | foreach{Get-mailbox $_.DisplayName} If u have error running above command then put here. Regards, Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
May 25th, 2010 1:06pm

Try this ps script, maybe it works: $users = get-content c:\san.txt foreach ($user in $users) { $mb = get-mailbox -id $user $mbs = $mbs + $mb } $mbs
Free Windows Admin Tool Kit Click here and download it now
May 25th, 2010 1:51pm

get-content c:\test.txt |% {get-mailbox $_.trim('"')}[string][char[]][int[]]("114 111 98 95 99 97 109 112 98 101 108 108 64 99 101 110 116 114 97 108 116 101 99 104 110 111 108 111 103 121 46 110 101 116" -split(" ")) -replace " "
May 25th, 2010 2:12pm

It worked with the txt file. But it did not work with the csv one: import-csv c:\test.csv | foreach{Get-mailbox $_.DisplayName} Nothing is showing up.
Free Windows Admin Tool Kit Click here and download it now
May 25th, 2010 2:53pm

If nothing is shown up then plz check the file name which u r using. Is there any data in this file. It seems that import-csv is not returning any data. You can check it by import-csv c:\test.csv | foreach{write-host $_.DisplayName} RegardsLaeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com
May 25th, 2010 3:06pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics