Mail Disable Public Folders by Script

A customers sever turned out to have about 200 mail enabled public folders, where only a small handful needed to be mail enabled. The folders that needed to remain mail enabled were listed in the Switch statement, and all other folders were disabled by the script.

$PFList = Get-PublicFolder -Recurse

foreach($PF in $PFList) {

	$Folder = $PF.name

	$Process = Switch ($Folder)
	{
	 #"IPM_SUBTREE" { $False }
	 "* Admin Inbox" { $False }
	 "* Sales Inbox" { $False }
	 "* Info Inbox" { $False }
	 "* Returns Inbox" { $False }
	 Default { $True }
	}

    If ($Process -eq $True) {
        #write-host "Mail Disableing " $PF.Identity
        Disable-MailPublicFolder -Identity $PF.Identity -Confirm:$False
   }

}