1

I'm trying to run:

```

Sync-MailPublicFolders.ps1 -Credential (Get-Credential) -CsvSummaryFile "sync_summary.csv"

```

from https://docs.microsoft.com/en-us/exchange/collaboration-exo/public-folders/set-up-legacy-hybrid-public-folders , in Windows Server 2008 R2 (which doesn't appear to have Powershell ISE).

Without the backticks I get errors such as:

WARNING: Property expression "<public folder name>" isn't valid. Valid values are: Strings formed with characters from A to Z (uppercase or  lowercase), digits from 0 to 9, !, #, $, %, &, ', *, +, -, /, =, ?, ^, _, `, {, |, } or ~.
One or more periods may be embedded in an alias, but each period should be preceded and followed by at least one of the other characters. Unicode characters from U+00A1 to U+00FF are also valid in an alias, but they will be mapped to a best-fit US-ASCII string in the e-mail address, which is generated from such an alias.

With it in the form below (won't run without .\), I also get the same errors.

```.\Sync-MailPublicFolders.ps1 -Credential (Get-Credential) -CsvSummaryFile "sync_summary.csv"```

... both runs with errors I suspect is due to the backticks that are supposed to escape the spaces in the Public Folder names, but happy to be wrong about their purpose.

If the backticks are necessary, how does one use them?

user66001
  • 185
  • 2
  • 16

2 Answers2

1

As you mentioned, the error is prompted causes that space is in the public folders alias. If you rename the alias. You may need to check all public folder aliases to make sure that they don’t have invalid characters. After this, you can resume the synchronization.

You could run the following cmdlet to have a list with all the ones with spaces, and export it into a csv file. Note: On the cmdlet below, if you’re problem is not limited to spaces on the alias, you can change the where-object filtering to try and find other invalid characters.

Get-MailPublicFolder | Where-Object {$_.Alias -like "* *"} | Select-Object alias, identity |export-csv [CSV file path and name]

After getting a csv file with all the mail enabled public folders with invalid aliases, execute the following cmdlet:

Get-MailPublicFolder [Public Folder Name] |Set-MailPublicFolder -Alias [PublicFolderAlias]

Reconfigure directory synchronization

.\Sync-MailPublicFolders.ps1 -Credential (Get-Credential) -CsvSummaryFile:[CSV file path and name]

For more information, refer the following links:

https://mymicrosoftexchange.wordpress.com/2015/02/11/public-folder-migration-request-error-creating-the-public-folder-hierarchy-property-expression-property-name-isnt-valid/

https://social.technet.microsoft.com/Forums/exchange/en-US/466106c8-33a4-4474-83eb-2f6451e0d4eb/2010-2013-public-folder-migration-failed-property-expression-isnt-valid?forum=exchangesvrdeploy

Kelvin_D
  • 191
  • 3
  • Thanks Kelvin_D. Can you suggest why the MS webpage I linked to specifically had 3 lines including 2 with ``` as you seem to be suggesting that they aren't required? – user66001 Feb 19 '19 at 03:58
  • @Trix, I AM putting legacy public folders in hybrid mode (as is the purpose of the link I provided), and `` is a PLACEHOLDER for an actual Public Folder Name. – user66001 Feb 19 '19 at 08:02
0

Adding to Kelvin_D Use the generated CSV file, then use this javascript (using jquery) to paste into Exchange PowerShell

$(".jqConvertAlias").click(function (e) {
    e.preventDefault();
    var script = 'Get-MailPublicFolder -Identity "|0|" | Set-MailPublicFolder -Alias "|1|"';
    var source = $(".jqSource").val().split('\n');
    var items = [];
    $.each(source, function (index, item) {
        if (item.length > 0) {
            var displayName = item.substring(0, item.indexOf('",'));
            displayName = displayName.replace(/"/g, '');
            var newAlias = displayName.replace(/([() '&,])/g, "");
            items.push(script.replace("|0|", displayName).replace("|1|", newAlias));
        }
    });

    $(".jqResults").val(items.join("\n"));
});

A form with 2 textareas, and a button. Paste the notepad view of the csv (from Kelvin_D post above) into the source, and click convert button, copy the results output, paste into powershell. I see that ampersand is acceptable, however didnt want them.

AdamRoof
  • 25
  • 1
  • 3
  • Also... the Exchange Sync-MailPublicFolders.ps1 doesnt like ending periods, like " Company, Inc. ", so i used the query Where-Object {$_.Alias -like "*."} to get all that end in a period. – AdamRoof Feb 25 '22 at 22:32