microsoft / CSS-Exchange

Exchange Server support tools and scripts
MIT License
1.21k stars 333 forks source link

[Issue] FindFrontEndActivity fails when SamAccountName contains a period #1986

Closed bill-long closed 5 months ago

bill-long commented 5 months ago

Describe the issue Something about having a period in the SamAccountName causes us to fail to replace the $SamAccountName variable with the escaped values. And we can't pre-escape it because of the parameter validation:

[PS] C:\Users\administrator.CONTOSO\Downloads>.\FindFrontEndActivity.ps1 -SamAccountName "user1.foo"

cmdlet FindFrontEndActivity.ps1 at command pipeline position 1
Supply values for the following parameters:
ServerName[0]: exch1
ServerName[1]:
The variable cannot be validated because the value System.String[] is not a valid value for the SamAccountName variable.
At C:\Users\administrator.CONTOSO\Downloads\FindFrontEndActivity.ps1:144 char:5
+     $SamAccountName = $SamAccountName | ForEach-Object { [Regex]::Esc ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : MetadataError: (:) [], ValidationMetadataException
    + FullyQualifiedErrorId : ValidateSetFailure

[PS] C:\Users\administrator.CONTOSO\Downloads>.\FindFrontEndActivity.ps1 -SamAccountName "user1foo"

cmdlet FindFrontEndActivity.ps1 at command pipeline position 1
Supply values for the following parameters:
ServerName[0]: exch1
ServerName[1]:
[PS] C:\Users\administrator.CONTOSO\Downloads>