System.Management.Automation.IncompleteParseException for a PowerShell script from my Management Pack
I’m currently working on a management pack that I’m hoping to be released to public very soon. In one of the workflows in the MP, I got an error logged in the Operations Manager event log on the target agent:
The PowerShell script failed with below exception
System.Management.Automation.IncompleteParseException: Missing closing ‘}’ in statement block. at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) at Microsoft.EnterpriseManagement.Common.PowerShell.RunspaceController.RunScriptT
Needless to say, the script runs just fine manually on the agent, so it is bug free. Took me a while to day to figure out what the issue is.
The script ended like this:
The last line is commented out, I’d uncomment it when test run it in powerShell prompt on an agent. When the MP is built in VSAE, it looked like this:
It’s on the same line as the CDATA close tag. After I started a new line at the end of the script, the MP started working:
From now on, I’ll remember to end the PowerShell script with an empty line. Interestingly, another VBScript in the MP doesn’t have this issue…
Leave a comment