module loading issue

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.

You might try re-installing the SCOM admin tools to let it set the path, and then see what that actually is. I don’t have a machine I can try it on; from what you’re saying, it seems like what you’ve done should work, but there’s obviously a bit missing.

C:\Program Files\Microsoft System Center 2012 R2\Operations Manager\Powershell\OperationsManager

was the wrong path to put in the module path. powershell wants the module path to be

C:\Program Files\Microsoft System Center 2012 R2\Operations Manager\Powershell

but then that path needs to contain a folder with the same name as the module, ie “operationsmanager.”