Question

I'm looking for a way to install missing SCCM updates on remote computers using PowerShell.

I came across this function but can't get it to run on a remote computer any ideas?

    function Install-MissingUpdate {

    param (
    $computer = "Remote-Computer"
    )
        ([wmiclass]'ROOT\ccm\ClientSDK:CCM_SoftwareUpdatesManager').InstallUpdates([System.Management.ManagementObject[]] (
         Get-WmiObject -Query 'SELECT * FROM CCM_SoftwareUpdate' -namespace 'ROOT\ccm\ClientSDK'))
    }
Was it helpful?

Solution

That code doesn't even take into account the $Computer parameter. I've updated the code to use the computer name parameter.

function Install-MissingUpdate {
    [CmdletBinding()]
    param (
        $ComputerName = "Remote-Computer"
    )
    $UpdateList = [ManagementObject[]](Get-WmiObject -ComputerName $ComputerName -Query 'SELECT * FROM CCM_SoftwareUpdate' -Namespace ROOT\ccm\ClientSDK);
    ([wmiclass]"\\$ComputerName\ROOT\ccm\ClientSDK:CCM_SoftwareUpdatesManager").InstallUpdates($UpdateList);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top