Sometimes, it can be useful to execute an Application / Package in the SCCM Software Center using Powershell.
For example, if an application is only available, not required, in the deployment and you want to install several package without logging to the computer.
Unfortunately, there is no built-in powershell cmdlet to do this. We must call method with a specific dll.
Rzander created a library used in SCCM Client Center to automate some actions, it developped in C# and you can download sccmclictr.automation.dll.
But this version doesn’t work with Powershell, you will get 0x80131515 dependancy, if you try to import it.
To resolve this issue, we will use the old version, smsclictr.automation.dll
First thing to do, import the DLL in Powershell:
#SCCM Client Automation Import-Module ".\smsclictr.automation.dll"
To be sure that your SCCM Client is up to date with his policy, we force a Request Machine Policy:
$RemoteSMSClient = New-Object -TypeName smsclictr.automation.SMSClient("ComputerName") $SMSClient.RequestMachinePolicy()
To run the application, we will use the SoftwareDistribution.RerunAdv function. Parameters are:
The full script:
Import-Module "smsclictr.automation.dll" $RemoteSMSClient = New-Object -TypeName smsclictr.automation.SMSClient("ComputerName") $RemoteSMSClient.RequestMachinePolicy() $RemoteSMSClient.SoftwareDistribution.RerunAdv("AdvID","PkgID","ProgramName")
If you want to download SCCM Client Center for SCCM 2012, it is available here.