I go to a lot of customers where when I launch the Operations Manager Shell (PowerShell Interface for SCOM) the shortcut is broken.
This is often caused by a user installing SCOM to a drive other then the C drive. I’m sure there a many other possible reasons but lets just focus on fixing it.
First I Open up a new PowerShell Command Prompt as administrator.
Then I run $env:PSModulePath
Then I run the same command on my SCOM Management Server that I know that the Operations Manager Shell works.
I notice a big difference in the modules listed for my PowerShell environment.
I can manually fix the Environment Variable by going to the Advanced System Settings
**Note you will have to reboot after fixing this as its not the running config**
Just like there is no crying in football there is no GUIs in PowerShell so I wrote this PowerShell script to fix it..
Here is the script I wrote to fix it with comments
#Get the Current Environment Variable PSModulePath Path
$current = [Environment]::GetEnvironmentVariable("PSModulePath", "Machine")
#Set the Missing Paths **Note** This may be a different drive or location depending on where you installed SCOM
$path1 = "C:\Program Files\Microsoft System Center 2012 R2\Operations Manager\Powershell\;"
$path2 = "C:\Program Files\Microsoft System Center 2012 R2\Operations Manager\Server\PowerShell\;"
$path3 = "C:\Program Files\Microsoft System Center 2012 R2\Operations Manager\Powershell\"
#Combine the Missing Paths with the Current PSModulePath Path
$FixedPath = $current + ";" + $path1 + $path2 + $path3
#Set the new Environment Variable Path for PSModulePath
[Environment]::SetEnvironmentVariable("PSModulePath", $FixedPath, "Machine")
#Set the current running PSModulePath to the stored path **Note** You can also just reboot
$env:PSModulePath = [Environment]::GetEnvironmentVariable("PSModulePath", "Machine")
Now when I run the shell it works.
You can download the script here. https://www.scom2k7.com/downloads/FixOMShell.txt