{"id":997,"date":"2010-09-10T13:30:41","date_gmt":"2010-09-10T13:30:41","guid":{"rendered":"https:\/\/www.wapshere.com\/missmiis\/?p=997"},"modified":"2010-09-10T13:30:41","modified_gmt":"2010-09-10T13:30:41","slug":"a-script-to-remove-training-spaces-from-public-folder-names","status":"publish","type":"post","link":"https:\/\/www.wapshere.com\/missmiis\/a-script-to-remove-training-spaces-from-public-folder-names","title":{"rendered":"A script to remove training spaces from public folder names"},"content":{"rendered":"<p>I am completely sick of the sight of this error:<\/p>\n<p>WARNING: Object \\<em>public folder path\u00c2\u00a0\u00c2\u00a0<\/em>\u00c2\u00a0has been corrupted and it is in an inconsistent state. The following validation errors have occurred:<br \/>\nWARNING: The Name property contains leading or trailing whitespace, which must be removed.<\/p>\n<p>So here&#8217;s powershell script to find and rename the offending folders. (Why exactly Outlook\u00c2\u00a0allows people to\u00c2\u00a0name them with a space at the end I DO NOT KNOW!)<!--more--><\/p>\n<div><\/div>\n<p><code><\/p>\n<pre>$getpfcmd = \"get-publicfolder -Recurse -resultsize unlimited\"\r\ninvoke-expression $getpfcmd | foreach {\r\n    if ($_.Name -ne $null -and $_.Name.substring($_.Name.length - 1,1) -eq \" \")\r\n\t{\r\n\t    write-host $_.Name\r\n\t    $newname = $_.Name.Trim()\r\n             $pfid = $_.identity.MapiEntryId.tostring()\r\n\t    Set-PublicFolder -Identity $pfid  -Name $newname\r\n\t}\r\n}<\/pre>\n<p>\u00c2\u00a0<\/p>\n<p><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am completely sick of the sight of this error: WARNING: Object \\public folder path\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0has been corrupted and it is in an inconsistent state. The following validation errors have occurred: WARNING: The Name property contains leading or trailing whitespace, which must be removed. So here&#8217;s powershell script to find and rename the offending folders. (Why&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":[]},"categories":[26,23],"tags":[],"class_list":["post-997","post","type-post","status-publish","format-standard","hentry","category-exchange2007","category-powershell"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pkp1o-g5","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/997","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/comments?post=997"}],"version-history":[{"count":5,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/997\/revisions"}],"predecessor-version":[{"id":1002,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/997\/revisions\/1002"}],"wp:attachment":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/media?parent=997"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/categories?post=997"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/tags?post=997"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}