PowerShell scripting a Parsing error – TerminatorExpectedAtEndOfString

I’ve been diving into PowerShell recently as you can see from my recent blog posts on setting Exchange 2010 virtual directory settings and on redirecting the OWA URL from http to https.

The inspiration has been my project to write up an article detailing a simple Exchange install for a single server Exchange 2010 environment. The aim was to provide a simple set of steps for small IT shops to follow, which lead my to try and automate a few things.

Whilst doing writing a script with user interaction to set the logon format for OWA I kept getting the below error:

[PS] C:\Users\administrator.GAOTS\Desktop>.\SetOWALogonFormat.ps1
The string starting:
At C:\Users\administrator.GAOTS\Desktop\SetOWALogonFormat.ps1:56 char:55
+         Write-host "Nothing has been changed, script quit <<<< " -foregroundcolor $WarningForeground -backgroundcolor
is missing the terminator: ".
At C:\Users\administrator.GAOTS\Desktop\SetOWALogonFormat.ps1:61 char:18
+ iisreset /noforce <<<<
    + CategoryInfo          : ParserError: ( -foregroundcol…sreset /noforce:String) [], ParseException
    + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

Well it turned out that a couple of things were the problem.

Firstly I checked for any “ that were in the wrong place (or in my case additional ones!)

Then I did a find and replace on all “ in the script which seemed to make the parser happy! I guess maybe this was the age old copy and paste problem with smart quotes from word??

Hope that helps a little!