If you work with SCOM and custom management packs, you are most likely using SCOM PowerShell modules. By default, these modules are installed with the console using SCOM setup. But one of my customers needed to install these modules on a Gateway Server installed on a Windows Server 2016 Core running custom PowerShell rules.
In order to install SCOM 2016 PowerShell Modules on a Windows Server or even on a Windows Client without having to install SCOM console and its prerequisites, follow the following steps.
First, you need to copy the PowerShell Modules source folder from a computer with the SCOM console installed to your target computer.
Additionally, to avoid any future error with the import of the OperationsManager, you have to create two additional empty folders (Console and Server) as below.
Then, you have to copy these 3 DLLs from the same source computer to a temporary folder on your target computer:
Once you copied these DLLs, you need to register them to your local GAC (Global Assembly Cache). The easiest way to accomplish this is to open a PowerShell session as Administrator and run these commands (replacing your temporary folder path if needed).
[Reflection.Assembly]::LoadWithPartialName("System.EnterpriseServices") | Out-Null
[System.EnterpriseServices.Internal.Publish] $publish = New-Object System.EnterpriseServices.Internal.Publish
Finally, you need to set the module path to the local environment variables (as always modify path accordingly to your environment). It will simplify the import of these modules in your future PowerShell sessions.
$CurrentValue = [Environment]::GetEnvironmentVariable("PSModulePath", "Machine")
[Environment]::SetEnvironmentVariable("PSModulePath", $CurrentValue + ";D:\Program Files\Microsoft System Center 2016\Operations Manager\Powershell", "Machine")
Import-Module Operations Manager
And it’s done… As you can see above you can now import Operations Manager PowerShell modules easily.