Find Exchange 2007 Public Folders with trailing spaces

Author Message
turranx

  • Total Posts : 59
  • Scores: 0
  • Reward points : 0
  • Joined: 2/7/2006
  • Location: Cincinnati, OH
  • Status: offline
Find Exchange 2007 Public Folders with trailing spaces Friday, June 27, 2008 10:45 AM (permalink)
0
We had a couple hundred Public Folders (PF) on our Exchange 2000 server.  These all needed to be migrated to the Exchange 2007 server.  I added the Ex2007 server as a replica to each PF and waited about a week while the replication took place.  While reading http://msexchangeteam.com/archive/2007/06/25/445429.aspx to learn how to remove the Ex2000 server from the replication list, I found that a number of the PFs had trailing spaces upon them; Ex2007 doesn't like this at all.  [sm=s14.gif]   I whipped up this one-liner to list out which PFs had this problem so I could manually correct it.  This run successfully on my Ex2007 SP1 server within the Exchange Management Shell.

 Get-PublicFolder -recurse | 
 foreach 
 {
     if ($_.name.endswith(' ')) 
     { 
         if ($_.ParentPath -ne $null) 
         { 
             if ([int]$($_.ParentPath.get_length()) -gt 1)
              {
                 $i = $_.ParentPath + "\" + $_.name
             } 
             else 
             {
                 $i = "\" + $_.name
             }
         };
         $i
     }
 }
 


 Get-PublicFolder -recurse | foreach {if ($_.name.endswith(' ')) { if ($_.ParentPath -ne $null) { if ([int]$($_.ParentPath.get_length()) -gt 1) {$i = $_.ParentPath + "\" + $_.name} else {$i = "\" + $_.name}};$i}}
 

I know this pales in comparison to some of the VBS stuff I churned out in the past, but I am brand spanking new to PowerShell.  Start small, work my way to gargantuan.

Microsoft Windows 2000 Scripting Guide - The best book for newbie scripters
http://www.myspace.com/Evil__Overlord
 
#1
    dm_4ever

    • Total Posts : 3687
    • Scores: 82
    • Reward points : 0
    • Joined: 6/29/2006
    • Location: Orange County, California
    • Status: offline
    RE: Find Exchange 2007 Public Folders with trailing spaces Saturday, June 28, 2008 8:32 AM (permalink)
    0
    Thanks for sharing....we're not using Exchange 2007 at work yet, but this may come in handy when we finally do.
    dm_4ever

    My philosophy: K.I.S.S - Keep It Simple Stupid
    Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
    Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9