Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

SCCM install update via command line

function trigger-AvailableSupInstall
{
 Param
(
 [String][Parameter(Mandatory=$True, Position=1)] $Computername,
 [String][Parameter(Mandatory=$True, Position=2)] $SupName
 
)
Begin
{
 $AppEvalState0 = "0"
 $AppEvalState1 = "1"
 $ApplicationClass = [WmiClass]"rootccmclientSDK:CCM_SoftwareUpdatesManager"
}
 
Process
{
If ($SupName -Like "All" -or $SupName -like "all")
{
 Foreach ($Computer in $Computername)
{
 $Application = (Get-WmiObject -Namespace "rootccmclientSDK" -Class CCM_SoftwareUpdate -ComputerName $Computer | Where-Object { $_.EvaluationState -like "*$($AppEvalState0)*" -or $_.EvaluationState -like "*$($AppEvalState1)*"})
 Invoke-WmiMethod -Class CCM_SoftwareUpdatesManager -Name InstallUpdates -ArgumentList (,$Application) -Namespace rootccmclientsdk -ComputerName $Computer
 
}
 
}
 Else
 
{
 Foreach ($Computer in $Computername)
{
 $Application = (Get-WmiObject -Namespace "rootccmclientSDK" -Class CCM_SoftwareUpdate -ComputerName $Computer | Where-Object { $_.EvaluationState -like "*$($AppEvalState)*" -and $_.Name -like "*$($SupName)*"})
 Invoke-WmiMethod -Class CCM_SoftwareUpdatesManager -Name InstallUpdates -ArgumentList (,$Application) -Namespace rootccmclientsdk -ComputerName $Computer
 
}
 
}
}
End {}
}
Source by timmyit.com #
 
PREVIOUS NEXT
Tagged: #SCCM #install #update #command #line
ADD COMMENT
Topic
Name
9+4 =