Question

I have a PowerShell function where I'm getting a strange parsing error (it won't compile, both PowerGUI (the editor I use), and PowerShell (when I try to Import-Module)), give me a Parsing error.

Here's a link to pastebin with my code: My Function @ Pastebin

Here's a link to a picture showing the parsing-error-message: Error message @ Imgur

Anyone familiar with this parsing error? I tried deleting the Write-Verbosestatements it complained about, but that didn't help any, it just jumped to the next one, even if it was inside a completely different codeblock. (E.G. Process{...} vs End{...}).

Was it helpful?

Solution

You're missing a backtick before on the quote before 'Any Errors' on line 161:

Write-Error "`"Could not connect to remote computer $server!`"`n`t`t`t`t`t`t`t`t      "Any errors on line 109 relates to this fact.`""

Should be:

Write-Error "`"Could not connect to remote computer $server!`"`n`t`t`t`t`t`t`t`t      `"Any errors on line 109 relates to this fact.`""

That caused some mismatched quotes which then caused the last quote in your script, i.e. the one at the end of "Returning Hashtable..." on line 247, to throw an error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top