Freigeben über


SCOM Operations Manager Shell PowerShell Error When Launched as Administrator

Sometimes when the Operations Manager Shell is opened as an Administrator you will see the error in the screenshot below. I believe this has to do with how User Account Control (or UAC) is configured. The “Start in” parameter on the shortcut is ignored and the shortcut is unable to locate the startup scripts.

shortcut

 

".\OperationsManager\Functions.ps1 : The term '.\OperationsManager\Functions.ps1' 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:34
+ ... t-Module OperationsManager; .\OperationsManager\Functions.ps1; .\Oper ...
+                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (.\OperationsManager\Functions.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

.\OperationsManager\Startup.ps1 : The term '.\OperationsManager\Startup.ps1' 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:69
+ ... r; .\OperationsManager\Functions.ps1; .\OperationsManager\Startup.ps1
+                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (.\OperationsManager\Startup.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

PS C:\Windows\system32> "

LaunchErrors

 

Here’s one easy workaround to fix the problem: simply run the line of code in ANY elevated PowerShell console (as Administrator). This will add a very simple command to your general profile that will set the location of the prompt so that the OpsMan startup scripts can be located by the shortcut. You only need to run this PowerShell code (below) once on each server where the Console is installed.

 $CMD = '$SCOMInstallPath = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup" -Name "InstallDirectory").InstallDirectory; Set-Location $SCOMInstallPath\..\PowerShell'
Add-Content -Path $profile.AllUsersAllHosts -Value $CMD -verbose –Force

 

Simply copy and paste into an elevated console:
SetProfile

If your Opsman shell is open, close it. Reopen it as Administrator. Problem solved. Shell_Is_Happy

 

To view your profile paths use this command:

 $profile | Select-Object -Property *