This may be addressed with newer versions but for those still on 3.2.0......
While working with cm12 r2 clients and the install-sccmsoftwareupdates it would simply not work. After some digging I found that on line ~4748 the error out code line was wrong
Write-Log "Trigger SCCM Install Updates failed: " + $_.Exception.Message
It would always wing an error but changing it to
Write-Log "Trigger SCCM Install Updates failed: $($_.Exception.Message)"
solved that problem but now the error tells me that the System.Management.ManagementObject class does not contain installupdates.
The code originally pointed to:
$SmsSoftwareUpdates = [wmiclass]"ROOT\ccm:SMS_Client"
which does not contain the right stuff.
However,
$SmsSoftwareUpdates = [wmiclass]"ROOT\ccm\ClientSDK:CCM_SoftwareUpdatesManager"
does and now looks to be all happy happy.
Below is the whole function as I have it today.
Function Install-SCCMSoftwareUpdates {
<#
.SYNOPSIS
.LINK
While working with cm12 r2 clients and the install-sccmsoftwareupdates it would simply not work. After some digging I found that on line ~4748 the error out code line was wrong
Write-Log "Trigger SCCM Install Updates failed: " + $_.Exception.Message
It would always wing an error but changing it to
Write-Log "Trigger SCCM Install Updates failed: $($_.Exception.Message)"
solved that problem but now the error tells me that the System.Management.ManagementObject class does not contain installupdates.
The code originally pointed to:
$SmsSoftwareUpdates = [wmiclass]"ROOT\ccm:SMS_Client"
which does not contain the right stuff.
However,
$SmsSoftwareUpdates = [wmiclass]"ROOT\ccm\ClientSDK:CCM_SoftwareUpdatesManager"
does and now looks to be all happy happy.
Below is the whole function as I have it today.
Function Install-SCCMSoftwareUpdates {
<#
.SYNOPSIS
Scans for outstanding SCCM updates to be installed and installed the pending updates
.DESCRIPTIONScans for outstanding SCCM updates to be installed and installed the pending updates
This function can take several minutes to run
.EXAMPLEInstall-SCCMSoftwareUpdates
.PARAMETER ContinueOnErrorContinue if an error is encountered
.NOTES.LINK
Http://psappdeploytoolkit.codeplex.com
>
Param (
[boolean] $ContinueOnError = $true
)
# Scan for updates
Write-Log "Scanning for SCCM Software Updates..."
Invoke-SCCMTask -ScheduleId "SoftwareUpdatesScan"
Write-Log "Sleeping 180 seconds..."
Sleep -Seconds 180
Write-Log "Installing pending software updates..."
Try {
#$SmsSoftwareUpdates = [wmiclass]"ROOT\ccm:SMS_Client"
$SmsSoftwareUpdates = [wmiclass]"ROOT\ccm\ClientSDK:CCM_SoftwareUpdatesManager"
$SmsSoftwareUpdates.InstallUpdates([System.Management.ManagementObject[]] (Get-WmiObject -Query “SELECT * FROM CCM_SoftwareUpdate” -Namespace “ROOT\ccm\ClientSDK”)) | Out-Null
}
Catch [Exception] {
If ($ContinueOnError -eq $true) {
Write-Log "Trigger SCCM Install Updates failed: $($_.Exception.Message)"
}
Else {
Throw "Trigger SCCM Install Updates failed: $($_.Exception.Message)"
}
}
}