Powershell - Match DisplayName to PrimarySMTPAddress
Hello, I am trying to change the DisplayName value of all mailboxes in our organization to match the PrimarySMTPAddress. I am a bit of a novice in PowerShell but below is the syntax I've tried to use in my lab, as well as the error messages I've received. I am hoping someone can help me figure out the correct syntax? Code: [PS] C:\Windows\system32>Get-Mailbox | foreach ($_){Set-Mailbox -DisplayName = $_.PrimarySMTPAddress} Error Message: Cannot process argument transformation on parameter 'Identity'. Cannot convert the "RNagle@contoso.local" value of type "Microsoft.Exchange.Data.SmtpAddress" to type "Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter". + CategoryInfo : InvalidData: (:) [Set-Mailbox], ParameterBindin...mationException + FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-Mailbox Thanks!
July 12th, 2012 10:05am

Hi I can't get this to work as a one-liner (not sure why and don't have a gap to find out right now) but it's an easy two-liner: $mb = Get-Mailbox foreach ($n in $mb) {Set-Mailbox $n.name -DisplayName $n.primarysmtpaddress} Cheers, Steve
Free Windows Admin Tool Kit Click here and download it now
July 12th, 2012 10:25am

Works for me. Thanks!
July 12th, 2012 10:46am

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

Other recent topics Other recent topics