Author Posts

December 22, 2017 at 5:57 pm


I'm attempting to nest the Operations Manager manifest/module into a custom module. I've organized the OpsMgr module to make it portable per this post –

The OpsMgr folder is located under the private folder of the module (.\Private\OperationsManager\PowerShell\OperationsManager). In the main module, I've tried dot sourcing the OpsMgr manifest and/or module. I've also specified the OpsMgr manifest in the "NestedModules" section of the main manifest. Importing the main manifest with the verbose switch appears that all of the OpsMgr cmdlets are being imported, however when's not recognizing them.

Source code is located on GitHub –

Any help to get in the right direction is much appreciated!

Thank you!

December 27, 2017 at 5:58 pm

Sorry for taking so long to reply on this. Holidays.

When you say, "not working," what do you mean? Do you mean that you're unable to run the OpsMgr command independently once your "outer" module is loaded?

December 28, 2017 at 4:43 pm

No worries!

Correct. The "main" module functions include cmdlets from the OpsMgr module. Importing the "main" module with the verbose switch indicates that the OpsMgr cmdlets are being loaded. However, when the functions call the OpsMgr's saying they're not recognized.

Importing the main manifest which references the OpsMgr manifest in the nestedmodules section –
VERBOSE: Importing cmdlet 'New-SCManagementGroupConnection'.

Running one of the functions which calls the OpsMgr cmdlets –
The term 'New-SCOMManagementGroupConnection' is not recognized as the name of a cmdlet....

December 28, 2017 at 4:56 pm

I also tested that the portable OpsMgr cmdlets work as intended. Importing that independently/explicitly, I'm able to run the cmdlets successfully.

December 28, 2017 at 11:16 pm

Not sure if it's a post issue, but your verbose output shows the function name missing an OM:




December 29, 2017 at 1:54 am

Sorry....I copied the wrong line. It is loading the correct alias for the cmdlet.

VERBOSE: Importing alias 'New-SCOMManagementGroupConnection'.

January 2, 2018 at 8:44 pm

I've done a bit more testing....I'm still at a loss, but here are the results.

Here is how the module is laid out for testing.
–OperationsManager folder (portable cmdlets)

Here is the intended flow of the module and how it is "supposed" to work running Invoke-ConfigMgrSoftwareUpdates.
Invoke-ConfigMgrSoftwareUpdates calls Start-OpsMgrMaintenanceMode. Start-OpsMgrMaintenanceMode includes the cmdlets from the
OperationsManager module (New-SCOMManagementGroupConnection).

The above fails with "The term 'New-SCOMManagementGroupConnection' is not recognized..."

Running Start-OpsMgrMaintenanceMode directly runs successfully and executes the opsmgr cmdlets from the private module.

So it seems that calling the Start-OpsMgrMaintenanceMode function from another function breaks the underlying cmdlets. Is this a scope issue?

January 4, 2018 at 8:20 pm

I finally figured this out. I originally was breaking out multiple functions from a PS workflow into this new module. The issue turned out to be the workflow calling the function and not importing the OpsMgr cmdlets explicitly to use in that session (not really anything to do with nesting the OpsMgr module).

Importing the modules explicitly as below, everything works as expected.

Import-Module "$using:PSWorkflowRoot\Private\Start-OpsMgrMaintenanceMode.ps1"
Import-Module "$using:PSWorkflowRoot\Private\OperationsManager\PowerShell\OperationsManager\OperationsManager.psd1"
Start-OpsMgrMaintenanceMode -ServerName $using:Server -Minutes 15 -Comment "Patching"