I want to install particular package on the server via powershell.
Get-WmiObject -Namespace ROOT\ccm\ClientSDK -Class CCM_Application -ComputerName Y31056 | Select-Object AllowedActions, Fullname
And i can list which software are installed or not installed on the server. So i want to install only specific package on the software center.
AllowedActions Fullname
-------------- --------
{Install} CMTrace
{Install} SCCMpackageV1
{Install} SQL Server 2014 SP2
I want run the script to install the SCCMpackageV1 via powershell, but little bit confused how to achieve it.
$SoftwareApp = Get-WmiObject -Namespace ROOT\ccm\ClientSDK -Class CCM_Application -ComputerName Y31056 | Select-Object AllowedActions, Fullname
$SoftwareApp.install.SCCMpackageV1
I've google it that simple install command should work, but i did not received any output. Software as well not installed.
The Install method for CCM_Application objects needs parameters to be supplied. Microsoft official document contains really detailed information regarding each parameter and you can refer below link: https://msdn.microsoft.com/en-us/library/jj902785.aspx
See below code as an example to install application on client machine:
$ComputerName = "Y31056"
$AppName = "SCCMPackageV1"
$s = New-PSSession -ComputerName $ComputerName
Invoke-Command -Session $s -Argu $ComputerName,$AppName -ScriptBlock `
{
param ($ComputerName,$AppName)
write-host "Getting Parameters for '$AppName' on $ComputerName"
$Application = Get-WmiObject -computername $ComputerName -Namespace "root\ccm\ClientSDK" -Class CCM_Application | where {$_.Name -like "$AppName"} | Select-Object Id, Revision, IsMachineTarget
$AppID = $Application.Id
$AppRev = $Application.Revision
$AppTarget = $Application.IsMachineTarget
([wmiclass]'ROOT\ccm\ClientSdk:CCM_Application').Install($AppID, $AppRev, $AppTarget, 0, 'Normal', $False) | Out-Null
}
Remove-PSSession $s