PowerShell and WMI to rename Public Folders on Exchange2003 RRS feed

  • Question

  • I need to rename a large number of Public Folders that contain "/" character.  The plan is to replace "/" with "-"

    How do I invoke the 'Rename' method for the WMI class 'Exchange_PublicFolder' using PowerShell?

    I want to use PowerShell to list all folders with the special character:

    Get-WmiObject -Namespace 'root/MicrosoftExchangeV2' -ComputerName 'servername' -Credential $cred -Class Exchange_PublicFolder | where-object { $_.Name -like '*/*'  }

    Can I send this output to an 'Invoke-WmiMethod' loop to rename all of these folders?  Can anyone provide any examples of how to invoke the rename method using powershell?


    • Edited by sio_spc Wednesday, June 5, 2013 12:56 AM code
    Wednesday, June 5, 2013 12:55 AM

All replies

  • I've done some more digging.  Does this look plausible?

    $PFs = (Get-WmiObject -Namespace 'root/MicrosoftExchangeV2' -ComputerName 'servername' -Credential $cred -Class Exchange_PublicFolder | where-object { $_.Name -like '*/*' })
    $PFsRenamed = $PFs | Foreach-Object { $_.Name -replace "/","-" }
    $PFs | Invoke-WmiMethod -Name Rename -ArgumentList $PFsRenamed

    On initial testing it appears to be okay.  Let me rinse this a few more times over in the lab...


    • Edited by sio_spc Wednesday, June 5, 2013 8:50 AM remove server name
    Wednesday, June 5, 2013 6:44 AM