TL;DR: How do I run SCCM PowerShell cmdlets (link) inside a Docker Container?
I'm developing a Web interface to manage SCCM resources. I use docker to run my applications (Database, Webserver etc.) and I need to use the SCCM PowerShell cmdlets (link) from inside this environment.
My plan was to create a Docker container running a PowerShell script that listens for commands, runs them, and then returns the result. The problem with that is that I wasn't able to import the SCCM module without a running installation of the SCCM management console.
My Question: How can I run SCCM PowerShell cmdlets from inside a Docker container, is this even possible.
My setup:
I have a Docker environment with 3 containers, 1 Database that contains all the data, 1 Webserver, including a Express.js app that should be able to run the PowerShell cmdlets, including getting and setting data, and 1 PowerShell "worker" that doesn't work at the moment.
The PowerShell worker runs the following script
# Import the ConfigurationManager.psd1 module
if((Get-Module ConfigurationManager) -eq $null) {
Import-Module "ConfigurationManager.psd1" @initParams
}
# Connect to the site's drive if it is not already present
if((Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue) -eq $null) {
New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams
}
Set-Location "$($SiteCode):\" @initParams
while ($true) {
sleep 1
}
But this doesn't seem to import the SCCM Module.
I am quite lost right now and any help would be appreciated. Am I even on the right path?