"The 'finally' keyword is not supported" error in CheckMaxConcurrentAPI.ps1 in SCOM 2007 R2

Symptoms
When the CheckMaxConcurrentAPI.ps1 Windows PowerShell script fails in Microsoft System Center Operations Manager (SCOM) 2007 R2, the MaxConCurrentAPI monitor generates an error message that resembles the following:

The PowerShell script failed with below exception
System.Management.Automation.ParseException: The 'finally' keyword is not supported in this version of the language.
At line:148 char:8
+ finally
<<<<{
at System.Management.Automation.Parser.finallyStatementRule(Tokenizer tok)
at System.Management.Automation.Parser.statementRule(Tokenizer tok)
at System.Management.Automation.Parser.statementListRule(Tokenizer tok)
at System.Management.Automation.Parser.cmdletBodyRule(Tokenizer tok, Token fnName, Boolean isFilter, ParameterDeclarationNode parameters, Boolean scriptMode)
at System.Management.Automation.Parser.functionDeclarationRule(Tokenizer tok)
at System.Management.Automation.Parser.statementRule(Tokenizer tok)
at System.Management.Automation.Parser.statementListRule(Tokenizer tok)
at System.Management.Automation.Parser.Parse(String input, Int32 cursorPosition)
at System.Management.Automation.AutomationEngine.Parse(String script, Boolean interactiveCommand)
at System.Management.Automation.ShellFunctionCommandProcessor..ctor(String script, ExecutionContext context, Boolean isFilter, Boolean useLocalScope, Boolean interactiveCommand)
at System.Management.Automation.Runspaces.Command.CreateCommandProcessor(ExecutionContext executionContext, CommandFactory commandFactory, Boolean addToHistory)
at System.Management.Automation.Runspaces.LocalPipeline.CreatePipelineProcessor()
at System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper()
at System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc()

Script Name: CheckMaxConcurrentAPI.ps1

One or more workflows were affected by this.

Workflow name: Microsoft.Windows.Server.2008.MaxConcurrentAPI.Monitor
Instance name: Microsoft Windows Server 2008 Standard without Hyper-V
Instance ID: <Instance ID>
Management group: <MG name>
Note This issue occurs after you import the System Center Management Pack for Windows Server Operating System version 6.0.7026.0 into a System Center Operations Manager 2007 R2 management group.
Cause
This issue occurs because System Center Operations Manager 2007 R2 and its management pack use a version of Windows PowerShell 2.0 that doesn’t support the "finally" keyword.
Workaround
To work around this issue without installing the Windows PowerShell 2.0 update, use one of the following methods: 
Properties

Article ID: 2856250 - Last Review: 09/27/2013 22:29:00 - Revision: 5.0

Microsoft System Center Operations Manager 2007 R2

  • KB2856250
Feedback