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 run…it’s not recognizing them.
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?
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 cmdlets…it’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…
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.
root
-private
–OperationsManager folder (portable cmdlets)
-public
–Invoke-ConfigMgrSoftwareUpdates.ps1
–Start-OpsMgrMaintenanceMode.ps1
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?
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.