What is the Powershell command line to apply a Managed Folder Mailbox Policy to an mailbox with specific Custom Attribute.
What is the Powershell command line to apply a Managed Folder Mailbox Policy to an mailbox with specific Custom Attribute.
July 28th, 2011 9:53am

get-mailbox -resultsize unlimited | where {$_.customattribute9 -eq "<test value>"} | set-mailbox -managedfoldermailboxpolicy "<policy name>"[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Free Windows Admin Tool Kit Click here and download it now
July 28th, 2011 10:11am

Thanks the PS command. Actully i have scenario where i have to create 3 policies which i have already created and working fine. Three policies are Normal users retention period is 90 days Consultants retention period is 30 days and Executive users retention period is 180 days. Now can i use the PS script with CSV import file to apply different policies to different users (more than one user). If i can get a script for this it will really help me in implementation. Shahid
July 28th, 2011 10:44am

Create a .csv with 2 columns e.g. "Name" and "ManagedFolderMailboxPolicy". Put the user names in the "Name" column, and the name of the policy you want them to have in the "ManagedFolderMailboxPolicy" column. Then assuming your .csv is c:\Retention_Policies\policies.csv : import-csv c:\Retention_Policies\policies.csv | foreach-object { set-mailbox $_.name -managefoldermailboxpolicy $_.managedfoldermailboxpolicy } Edit: If you want a csv with the user names and existing policy settings pre-populated to start with: get-mailbox -resultsize unlimited | select name,managedfoldermailboxpolicy | export-csv c:\Retention_Policies\policies.csv -notype Then just open that up in Excel. make sure you save it as type .csv when you're done, and feed it back into the set-mailbox script. [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Free Windows Admin Tool Kit Click here and download it now
July 28th, 2011 11:26am

Thanks mjolinor. I will test out the script you provided in my lab environment and let you know. Again thank you very much for your time and help.Shahid
July 28th, 2011 7:36pm

Thanks mjolinor, the command worked wonderfully. If you can assist with couple more things, i would really appreciate. 1. with existing shell cmdlet you provided above, how can i overirde "Confirmation" message it prompts while applying the policy to each mailboxes. it keeps prompting for each users. 2. How can i revert back the mailbox policy settings on all mailboxes with shell cmdlet to its original state with csv import file? Thanks again in advance for your great support.Shahid
Free Windows Admin Tool Kit Click here and download it now
July 29th, 2011 5:30am

You can add the -confirm:$false parameter to the set-mailbox cmdlet to suppress the prompts. As far as reverting back, If you keep a copy of the .csv file you exported orignially, running that back through the set-mailbox script will change the policies back to the original settings.[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
July 29th, 2011 6:32am

I tried following cmdlet but it is still prompting. import-csv c:\Retention_Policies\policies.csv | foreach-object {set-mailbox $_.name -managedfoldermailboxpolicy $_.managedfoldermailboxpolicy -Confirm:$false} what am i doing wrong?Shahid
Free Windows Admin Tool Kit Click here and download it now
July 29th, 2011 7:38am

I'll test it on my systems when I get to work, and get back to you. You should be able to suppress that.[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
July 29th, 2011 7:41am

i tried putting something like this also but ended getting error. import-csv c:\Retention_Policies\policies.csv | foreach-object {set-mailbox $_.name -managedfoldermailboxpolicy $_.managedfoldermailboxpolicy -ManagedFolderMailboxPolicyAllowed -Confirm:$false}Shahid
Free Windows Admin Tool Kit Click here and download it now
July 29th, 2011 7:44am

import-csv c:\Retention_Policies\policies.csv | foreach-object {set-mailbox -ManagedFolderMailboxPolicyAllowed -Confirm:$false $_.name -managedfoldermailboxpolicy $_.managedfoldermailboxpolicy} this one worked......Shahid
July 29th, 2011 9:00am

That's kind of weird. I'd have expected the parameter to work anywhere in the command, but I'm glad you got it to work.[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Free Windows Admin Tool Kit Click here and download it now
July 29th, 2011 9:10am

This is last thing i needed to test as i have not exported out the user details as explained in your earlier thread. So if i want to roll back the policy setting from the mailbox using the same import file which was used to set the policy, what needs to be done. I tried various options without any luck. And frankly speaking i hardly have any knowledge on PS and scripting. I would be really thankful to you if you get this last thing working as this is very important for me to present to my seniors.Shahid
July 29th, 2011 9:19am

You can't "roll back" those settings if you don't have a record of what they were before you changed them. If you need rollback capability, run the script to export the settings to csv, and save that file somewhere. Make a copy of it to use for doing the updates. If you need to roll back the updates, go back and get the original csv file you exported and run that back through the script, and it will change the policies back to what they were originally when you did that export.[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Free Windows Admin Tool Kit Click here and download it now
July 29th, 2011 9:50am

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

Other recent topics Other recent topics