Powershell Syntax for Bulk Operations on Mailboxes
I have a text (CSV) file with a list of mailboxes I want to perform an operation on. I have found examples for bulk moving mailboxes, but none for what I want to do. Before I move the mailboxes I need to clear the flag on the Email Addresses tab called
"Automatically Update Email Addresses Based on Recipient Policy." Can I do that in bulk from a CSV file in Powershell? Thanks in advance. ChrisExchange Freak | @ntpro | http://geekswithblogs.net/ntpro
May 8th, 2010 6:53am
Hi
Try Export-csv "filename.csv" | foreach-object { whatever function you want to do }
Thanks
Shiv
Free Windows Admin Tool Kit Click here and download it now
May 8th, 2010 12:52pm
I have a text (CSV) file with a list of mailboxes I want to perform an operation on. I have found examples for bulk moving mailboxes, but none for what I want to do. Before I move the mailboxes I need to clear the flag on the Email Addresses tab
called "Automatically Update Email Addresses Based on Recipient Policy." Can I do that in bulk from a CSV file in Powershell? Thanks in advance. Chris
Exchange Freak | @ntpro | http://geekswithblogs.net/ntpro
You will have to use import-csv rather than Export-csv "filename.csv" like this
Import-csv "C:\\filename.csv" | foreach {set-mailbox $_.PrimarySmtpAddress -EmailAddressPolicyEnabled $false}
I suppose that you csv is placed on C:\\ path and your CSV file contains the PrimarySmtpAddress for each mailbox.
IF instead of PrimarySmtpAddress you have some other attribute in your csv file then replace it in above command.
Regards,Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM)
www.HostingController.com
May 8th, 2010 1:16pm
yikes...i meant import-csv.
Anyways, i am just done with a script to move few of my users from one server to another using the below by invoking shell through a scheduled task.
C:\alias_move.csv" - This is the filename and location where alias of users have been listed.
Import-csv "C:\alias_move.csv" | Foreach-Object { move-mailbox -Identity $_.Alias -BadItemLimit '10' -TargetDatabase 'Srvername\Storagegroup\db' -GlobalCatalog 'xelcplc01.local.com' -DomainController 'xelcplc01.local.com' -Confirm: $false }
Paste the command in a notepad file and change the extension to .ps1 (Say you save this as Movemailbox.ps1 in location f:\exchange 2007\bin\scripts folder)
This .ps1 file can be invoked though a scheduled task by creating a batch file with the below command in it.
PowerShell.exe -PSConsoleFile "F:\spf\exchange2007\Bin\ExShell.Psc1" -Command "f:\exchange 2007\scripts\Movemailbox.ps1"
So, what i am trying to understand why would we have to disable the option of automatically updating the email address on every mailbox which is being moved ??
Thanks
Shiv
Free Windows Admin Tool Kit Click here and download it now
May 8th, 2010 1:29pm
Because when we move the mailbox from e2k3 to e2k10 there is a bug (or behavior we don't want) where the RUS again stamps the mailbox as per the policy when it is being moved. The user's custom SMTP address is then no longer the default and he has a new
address after he is moved.Exchange Freak | @ntpro | http://geekswithblogs.net/ntpro
May 8th, 2010 2:42pm
That's "by design", and it's not the RUS because there's no RUS in Exchange 2010. Have you tried deselecting "Automatically update e-mail addresses based on recipient policy" prior to moving the mailbox? Try that with a test
mailbox and see if it works.
If it does work, you can also do something like:
Get-Mailbox -Server Old_Server_Name | Set-Mailbox -Identity Mailbox_Name -EmailAddressPolicyEnabled:$False
to clear that checkbox for all users on the old server prior to moving them to Exchange 2010.
--
Ed Crowley MVP
"There are seldom good technological solutions to behavioral problems."
.
"Chris Haaker" wrote in message
news:31972817-54b2-4587-9be8-5db7d29edd7c...
Because when we move the mailbox from e2k3 to e2k10 there is a bug (or behavior we don't want) where the RUS again stamps the mailbox as per the policy when it is being moved. The user's custom SMTP address is then no longer the default and he has a new address
after he is moved.
Exchange Freak | @ntpro | http://geekswithblogs.net/ntproEd Crowley MVP "There are seldom good technological solutions to behavioral problems."
Free Windows Admin Tool Kit Click here and download it now
May 9th, 2010 4:08am
Assuming the scv file has a 'UserName' header (where UserName is the identity for each mailbox):
Import-Csv c:\mailbox.csv | Foreach-Object { Set-Mailbox -Identity $_.UserName
-EmailAddressPolicyEnabled:$false }Shay Levy [MVP]
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar
May 13th, 2010 2:00pm