SCOM Event Connector Bi-directional error CommandNotFoundExceptionIssue Issue: SCOM Event Connector Bi-directional error status with Command Not Found Exception when running Invoke-UpdateAlert.ps1 PowerShell Script on MID Server Host. Error Message: BI-DIRECTIONAL ------------------------------------------------------------- . : The term 'D:\ServiceNow\Mid Server Test\mid.orlando-12-11-2019__patch9b-02-04-2021_02-05-2021_2157.windows.x86-64 ' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:7 + & { . D:\ServiceNow\Mid` Server` Test` ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (D:\ServiceNow\Mid` Server` Test` 4 :String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Invoke-UpdateAlert : The term 'Invoke-UpdateAlert' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:167 + ... scripts\Powershell\Invoke-UpdateAlert.ps1; Invoke-UpdateAlert false s ... + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Invoke-UpdateAlert:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Steps to Reproduce: 1. Create a MID Server with parentheses in the MID's full path to install directory Example: D:\ServiceNow\Mid Server Test (1)\agent\scripts\Powershell\Invoke-UpdateAlert.ps1 2. Configure an SCOM Connector instance with Bi-Directional enabled. 3. Test the Connector 4. Check the Bi-Directional Last Status field for the Error message.ReleaseMID Server installed on Windows - any version Platform Release - AllCauseThe CommandNotFoundException is caused by a set of parentheses in the path to the Mid Server's agent directory. Example: D:\ServiceNow\Mid Server Test (1)\agent\ 1. The accent-grave ` is used as an escape character by PowerShell used the same way we would use a backslash as an escape "\" in any other scripting language. 2. The SCOM Connector uses the MID Script Include "ScomJS" to create the below command with the full path to Invoke-UpdateAlert.ps1 in the agent/scripts directory before executing Invoke-UpdateAlert on the next command line of the PowerShell script. powershell -executionpolicy unrestricted -noninteractive -command "& { . D:\ServiceNow\Mid Server Test (1)\agent\scripts\Powershell\Invoke-UpdateAlert.ps1; Invoke-UpdateAlert false ***** ***** 10.35.0.165 D:\ServiceNow\Mid Server Test (1)\agent 2012 '[{\"id\":\"e742eaf9-d38b-414a-a736-a94b007f0ada\",\"command\":\"ticket_id\",\"ticket_id\":\"INC1916581\"}]' } 2. In the MID Script Include "ScomJS" in the sendAlerts function on lines 118 and 119 we do escape whitespace characters in the path to script and the path to dll which are replaced with a back tick preceding the whitespaces to escape them. Thus the white-spaces in D:\ServiceNow\Mid Server Test (1)\agent\ will be replaced with "` " resulting in D:\ServiceNow\Mid` Server` Test` (1)\agent\ 3. However, the whitespace is the only special character that the ScomJS MID Script Include evaluates to escape. In the above full path we have a set of parentheses that should have been escaped with accent-graves as well which is causing the full path to be interpreted as D:\ServiceNow\Mid` Server` Test` a. Not escaping any Special Character causes PowerShell to throw the CommandNotFoundException due to an incomplete full path being interpreted as the full path.ResolutionEscaping the each of parentheses characters with an accent-grave allows the the command to run properly. D:\ServiceNow\Mid` Server` Test` `(1)`\agent Full Command will run as: powershell -executionpolicy unrestricted -noninteractive -command "& { . D:\ServiceNow\Mid` Server` Test` `(1`)\agent\scripts\Powershell\Invoke-UpdateAlert.ps1; Invoke-UpdateAlert false ***** ***** 10.35.0.165 D:\ServiceNow\Mid` Server` Test` `(1`)\agent 2012 '[{\"id\":\"e742eaf9-d38b-414a-a736-a94b007f0ada\",\"command\":\"ticket_id\",\"ticket_id\":\"INC1916581\"}]' }