Script Connect-Mailbox help
Hi all, domain A (resource forest) and domain B (account forest) in domain A, exchange SP2 : ex: domain name: A user logon account: sam1 User dispaly name: D1 exchange server name: mail in domain B: ex: dommain name: B user logon account: A1 Connect-Mailbox -Identity "D1" -Database 'mail.a.local\1st Storage Group\Mailbox Database' -User 'A\sam1' -Alias 'A1' -LinkedDomainController 'dc1.b.local' -LinkedMasterAccount 'B\A1' -LinkedCredential $credential I need to do this for 800 users and I thought I create the txt file with sourcedisplayName, Database, sourcelogon, Alias, linkedmasteraccount then use excel to create 800 above lines. Connect-Mailbox -Identity "D1" -Database 'mail.a.local\1st Storage Group\Mailbox Database' -User 'A\sam1' -Alias 'A1' -LinkedDomainController 'dc1.b.local' -LinkedMasterAccount 'B\A1' -LinkedCredential $credential Connect-Mailbox -Identity "D2" -Database 'mail.a.local\1st Storage Group\Mailbox Database' -User 'A\sam2' -Alias 'A2' -LinkedDomainController 'dc1.b.local' -LinkedMasterAccount 'B\A2' -LinkedCredential $credential ------ Is there a better way to script with powershell? Thank you.
November 17th, 2010 11:53am

I need to do this for 800 users and I thought I create the txt file with sourcedisplayName, Database, sourcelogon, Alias, linkedmasteraccount then use excel to create 800 above lines. Connect-Mailbox -Identity "D1" -Database 'mail.a.local\1st Storage Group\Mailbox Database' -User 'A\sam1' -Alias 'A1' -LinkedDomainController 'dc1.b.local' -LinkedMasterAccount 'B\A1' -LinkedCredential $credential Connect-Mailbox -Identity "D2" -Database 'mail.a.local\1st Storage Group\Mailbox Database' -User 'A\sam2' -Alias 'A2' -LinkedDomainController 'dc1.b.local' -LinkedMasterAccount 'B\A2' -LinkedCredential $credential ------ Is there a better way to script with powershell? Thank you. Create your file in Excel, then save it as .csv (eg c:\somedir\userlist.csv) In Powershell, import-csv c:\somedir\userlist.csv | foreach-object { Connect-Mailbox -Identity $_.sourcedisplayname -Database $_.database -User $_.sourcelogon -Alias $_.alias -LinkedDomainController 'dc1.b.local' -LinkedMasterAccount $_.linkedmasteraccount -LinkedCredential $credential } When you import-csv, you get a collection of custom objects, one for each row. Each object will have a set of property names that match the column headings, and the values will be the content of the cell for that column of the row. Avoid using embedded spaces in your column headings. If a column heading has embedded spaces, you end up with a property name with embedded spaces and then you have to qoute the property name to keep from confusing the parser - eg if you use a column heading of "linked master account", then you have to reference it as $_."linked master account" in your script.[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Free Windows Admin Tool Kit Click here and download it now
November 17th, 2010 12:59pm

Hi John, Please refer to Mjolinor’s reply. Please do not hesitate to let me know if you have any questions. Best regards, Serena best regards, serena
November 21st, 2010 9:01pm

Hi Mjolinor, You are a life saver. It worked like a charm. Thank you so much for your help.
Free Windows Admin Tool Kit Click here and download it now
November 22nd, 2010 11:09am

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

Other recent topics Other recent topics