I suspect that when I upgraded my windows 2008 R2 SCOM 2012 R2 servers to powershell 5.1, something happened with psmodulepath. I had some scheduled tasks calling ps scripts, importing the operationsmanager module, and those tasks stopped working.
this morning when I tested ‘ipmo operationsmanager’ on any of my three scom servers, I got the “not loaded because no valid module file was found” error.
the module “operationsmanager.psm1” lives in C:\Program Files\Microsoft System Center 2012 R2\Operations Manager\Powershell\OperationsManager.
checking $env:psmodulepath showed that path was indeed missing. on my windows 8.1 workstation, which has the scom console installed, that path is present in psmodulepath, and ipmo operationsmanager works.
on the scom server, if I use the full path to the module, “ipmo ‘C:\Program Files\Microsoft System Center 2012 R2\Operations Manager\Powershell\OperationsManager\operationsmanager.psm1’”, the module imports without error.
so I added C:\Program Files\Microsoft System Center 2012 R2\Operations Manager\Powershell\OperationsManager to hklm/…psmodulepath in the registry of the scom server. now $env:psmodulepath now correctly shows the path.
PS C:> $env:psmodulepath
\sisfpsp4\users\john.curtiss\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\syste
m32\WindowsPowerShell\v1.0\Modules;C:\Program Files\Microsoft System Center 2012 R2\Operations Manager\Powershell\Operat
ionsManager
and yet, “ipmo operationsmanager” still throws the “not loaded because no valid module was found” error.