Invoke OSD Task sequence remotely with Powershell

 

Earlier blog posts on invoking Installations:

Applications 

Software Updates

 

This is a continuation on how to invoke or trigger installations in Software center remotely with the help of Powershell. This blog post came about after i got a question from a user called Sonik on the Application post i did.

 

Question:

Will this work to install Operating System as well? I have the operating system image available in the software center and It works when I manually select and install. But not with this script. Any idea?

 

Answer:

Hey, No it won’t work because Configuration Manager uses different built in functions to trigger OSD then applications. I don’t know which WMI class it is right now but i will take a look and see if i can figure it out.

 

And below is the result on how to do it. Hope this will help you Sonik.

 

What do we want to Achieve?

 

We wan’t to be able to invoke an installation of an available OSD Task Sequence in Software Center remotely on a system.

One might wonder why and it’s pretty simple, it saves us time and we are lazy 😀

1

 

The Script

 


function Invoke-OSDInstall
{
Param
(
[String][Parameter(Mandatory=$True, Position=1)] $Computername,
[String][Parameter(Mandatory=$True, Position=2)] $OSDName

)
Begin
{

$CIMClass = (Get-CimClass -Namespace root\ccm\clientsdk -ComputerName $Computername -ClassName CCM_ProgramsManager)
$OSD = (Get-CimInstance -ClassName CCM_Program -Namespace "root\ccm\clientSDK" -ComputerName $Computername | Where-Object {$_.Name -like "$OSDName"})

$Args = @{PackageID = $OSD.PackageID
ProgramID = $OSD.ProgramID
}
}

Process
{

Invoke-CimMethod -CimClass $CIMClass -ComputerName $Computername -MethodName "ExecuteProgram" –Arguments $Args

}
End {}
}

 

The script is also available for download over at Technet https://gallery.technet.microsoft.com/Invoke-Installation-of-OSD-ff6f2eb0

 

Example

 

Until next time, cheers Timmy !

You can find me over at