Script creating duplicate folders
get-distributiongroupmember "Mailbox Archiving" -resultsize unlimited | Set-Mailbox -managedfoldermailboxpolicy "Evault" -managedfoldermailboxpolicyallowed -confirm:$false I am using the script above to create a managed folder for all users of the distribution group "Mailbox Archiving". I run this everytime a new user is added to the distro and for some reason when I run it it creates another "Managed Folder" in user's mailboxes that already have a managed folder it just tacks a number on to the end of it. For example I see Managed Folders in my mailbox today and then if I were to run the script again because I added a new user to the distro I will see Managed Folders1 in my mailbox. Some users are seeing Managed Folders1,2,3,etc as I have to run this to create the folder for each new hire we have. The script says that "No changes were made" to accounts that already have the policy but that's just not the case. Is there something I can add to say if a mailbox has the folder already to skip it? Is there something I'm doing wrong? Thanks for any help.
February 17th, 2011 4:42pm

mtropser, Use this script instead to prevent duplicates. get-distributiongroupmember "Mailbox Archiving" -resultsize unlimited | Where-Object {$_.ManagedFolderMailboxPolicy -ne "managedfoldermailboxpolicy"} | Set-Mailbox -managedfoldermailboxpolicy "Evault" -managedfoldermailboxpolicyallowed -confirm:$false Of course, replace the "managedfoldermailboxpolicy" with your actual policy name.
Free Windows Admin Tool Kit Click here and download it now
February 17th, 2011 6:47pm

Thank you for the response, however, it's still doing the same thing.
February 18th, 2011 4:19pm

Sorry to hear it didn't work in your favor, another way to approach it is how to filter instead of using my first suggestion of any mailbox that does not equal, try setting the filter to equal null like below: Get-DistributionGroupMember -Identity "Mailbox Archiving" | Where-Object {$_.ManagedFolderMailboxPolicy -eq $null} | Set-Mailbox -ManagedFolderMailboxPolicy "Evault" -ManagedFolderMailboxPolicyAllowed -Confirm $false This should now identify all mailboxes associated with the distribution group "Mailbox Archiving" that do not have a managed folder policy set, and set the one you specify, which is "Evault".
Free Windows Admin Tool Kit Click here and download it now
February 18th, 2011 5:16pm

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

Other recent topics Other recent topics