What do we want to achieve ?
You have application X deployed (or like in this case Google chrome) as available to your client and you wan’t to trigger the installation remotely without needing to actually go in to software center on that remote computer like this

Perfect if you want to save time and last but not least its cool to run scripts 😀 !
This could be a perfect help for either service desk or if your a sysadmin and have a lot of servers that you maintain.
Script also available over at Technet
Powershell Script
Function Trigger-AppInstallation { Param ( [String][Parameter(Mandatory=$True, Position=1)] $Computername, [String][Parameter(Mandatory=$True, Position=2)] $AppName, [ValidateSet("Install","Uninstall")] [String][Parameter(Mandatory=$True, Position=3)] $Method ) Begin { $Application = (Get-CimInstance -ClassName CCM_Application -Namespace "root\ccm\clientSDK" -ComputerName $Computername | Where-Object {$_.Name -like $AppName}) $Args = @{EnforcePreference = [UINT32] 0 Id = "$($Application.id)" IsMachineTarget = $Application.IsMachineTarget IsRebootIfNeeded = $False Priority = 'High' Revision = "$($Application.Revision)" } } Process { Invoke-CimMethod -Namespace "root\ccm\clientSDK" -ClassName CCM_Application -ComputerName $Computername -MethodName $Method -Arguments $Args } End {} }
Dissecting the script
We start out with naming the function Trigger-AppInstallation (tho it also will uninstall) I’m just bad at making up names lol.
there’s 3 parameters that needs to be specified when running the function and those are
Computername (states the computer name for example SD010)
Appname (The applicaiton you would like to install or uninstall)
Method (Is defined with either Install or Uninstall depending on what you want and it can the parameter will only accept those 2 different strings and if you would write anything else it will just prompt an error msg)
Function Trigger-AppInstallation { Param ( [String][Parameter(Mandatory=$True, Position=1)] $Computername, [String][Parameter(Mandatory=$True, Position=2)] $AppName, [ValidateSet("Install","Uninstall")] [String][Parameter(Mandatory=$True, Position=3)] $Method )
Next up is the Begin block where we are just getting the CIM instance for that specific application from the remote computer after that we gather the necessary arguments that we need later when we are going to invoke the CIM method in the process block. The only 2 arguments i kept static was IsRebootIfNeeded = $False meaning that it will not reboot when installing or uninstalling the application, if you set this one to $True it will reboot. and Priority i kept as “High” because why not right ?
Begin { $Application = (Get-CimInstance -ClassName CCM_Application -Namespace "root\ccm\clientSDK" -ComputerName $Computername | Where-Object {$_.Name -like $AppName}) $Args = @{EnforcePreference = [UINT32] 0 Id = "$($Application.id)" IsMachineTarget = $Application.IsMachineTarget IsRebootIfNeeded = $False Priority = 'High' Revision = "$($Application.Revision)" } }
The process block, here we are calling the method that’s either Install or Uninstall on the specific CIM instance. Passing through computername, method and arguments from earlier. Information about the method it self you can find over at Microsoft https://msdn.microsoft.com/en-us/library/jj902785.aspx but sadly sometimes the documentation there doesn’t seem to be 100% correct but nether the less its a great starting point.
Process { Invoke-CimMethod -Namespace "root\ccm\clientSDK" -ClassName CCM_Application -ComputerName $Computername -MethodName $Method -Arguments $Params }
Examples
If you trigger the function below you will install the the app Google chrome on computer SD010
Trigger-AppInstallation -Computername SD010 -AppName "Google Chrome" -Method Install
If the script was invoked succesfully you will get back the following return value 0

and the installation is triggered on the remote client

If you want to uninstall the same application, just change the -Method parameter to Uninstall instead of install.
Trigger-AppInstallation -Computername SD010 -AppName "Google Chrome" -Method Uninstall
And the following will happen on the client

Thats all for now, until next time !
Cheers Timmy
Since the wmi info will only hold applications that are targeted to devices, is there any way to force an application that is targeted to a user or user group?
With the new software center, not sure this is possible but thought i would ask if anyone tried.
Thanks for the tip!
Good question and in theory i think it would work but i havent tried it out yet but i will certainly do. Will get back to you with the result.
For some reason it is not working for me. When I run the script after modifying the computer name – I get a message do you want to run the script – I select Run Once – After that nothing happens on the remote machine and there is no message in PS window.
I am currently on SCCM 2012 R2 SP1. I can install Google Chrome from SC.
You also have to modify the name of the application, it has to be exatcly the same as you have named it in SCCM. Let me know if that helped ?
If you want to run locally, remote computername parameter from function, and then it will work.
Yes I checked the application name – it is Google Chrome – Yet nothing happens. I will try a different application and see the result. Will keep you posted.
I tried with 7Zip, Winrar, VLC Player. I am not able to get the PS script to work. The applications name are exactly as they are listed in SCCM Application.
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?
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.
timmyit, I am trying to use your code to help me with a task I need to accomplish that this script would be perfect! Unfortunately when I try running it I’m getting the following error and I’m not sure where to go from here? Can you help me?
PS I:> Trigger-AppInstallation -Computername NR8B5YFTHOU -AppName “AutoCAD Architectural 2017” -Method UnInstall
Invoke-CimMethod : The WinRM client cannot process the request. Property
“IsMachineTarget” with MI type MI_STRING does not match the expected type from the
schema: MI_BOOLEAN. Specify the correct type and retry the operation.
At line:28 char:1
+ Invoke-CimMethod -Namespace “rootccmClientSDK” -ClassName CCM_Appli …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : MetadataError: (rootccmClientSDK:CCM_Application:Str
ing) [Invoke-CimMethod], CimException
+ FullyQualifiedErrorId : HRESULT 0x803381e1,Microsoft.Management.Infrastructure
.CimCmdlets.InvokeCimMethodCommand
+ PSComputerName : NR8B5YFTHOU
Mike-
I received the same errors myself. What version of powershell is on the machine? I had to tweak the script quite a bit to get it to run on Powershell 2.0 but I think Powershell 4.0 also needs some tweaks.
what tweaks are needed to get it to run under 3.0 or 4.0? I keep getting the same error and cant get past it. it runs fine if I put the computername of my local computer but errors on a remote computer.
did anyone get this to work remotely?
Yes. For that error I had to cast the string to bool.
The line to change within $Args should be:
IsMachineTarget = [System.Convert]::ToBoolean($Application.IsMachineTarget)
Another gotcha I found was that I had to be logged in to the remote machine with my admin account just because I don’t have an account with permissions to do it without remote session established.
Kind of a pain for my case, but I threw in a quick call to MSTSC and a Start-Sleep to work around it.
Depending on the Server type you might trigger where the $Application is an array with 2 “True” entry which the system cant process. I fixed it by doing this:
first making sure the application name is exact (still can get doubles but reduced other possible false entries)
IsMachineTarget = $Application.IsMachineTarget[0]
Hi Mike,
What tweek that you have made on this script? can you please share your script so that i will make changes. Please note the script is running on PS version 4.0
Thanks,
VJ
I often visit your page and have noticed that you don’t update it
often. More frequent updates will give your
page higher rank & authority in google. I know that writing content takes a lot
of time, but you can always help yourself with miftolo’s tools which will
shorten the time of creating an article to a couple of seconds.
I run this script and no application is return. But I have one application available in software center
I have optional software in the software center, but it is not installing by this script. Do I need to change anything to get optional software too.
Hello,
I am getting the below error message when i used it in my server, but…. when I use it from my regular computer (workstation), it works.. but it does not install anything….
Suggestions?
Thank you
Get-CimInstance : The client cannot connect to the destination specified in the request. Verify that
the service on the destination is running and is accepting requests. Consult the logs and
documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If
the destination is the WinRM service, run the following command on the destination to analyze and
configure the WinRM service: “winrm quickconfig”.
At line:14 char:17
+ $Application = (Get-CimInstance -ClassName CCM_Application -Namespace “rootccm …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ConnectionError: (rootccmclientSDK:CCM_Application:String) [Get-CimIns
tance], CimException
+ FullyQualifiedErrorId : HRESULT 0x80338012,Microsoft.Management.Infrastructure.CimCmdlets.GetCim
InstanceCommand
+ PSComputerName :
Invoke-CimMethod : The client cannot connect to the destination specified in the request. Verify that
the service on the destination is running and is accepting requests. Consult the logs and
documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If
the destination is the WinRM service, run the following command on the destination to analyze and
configure the WinRM service: “winrm quickconfig”.
At line:29 char:1
+ Invoke-CimMethod -Namespace “rootccmclientSDK” -ClassName CCM_Application -Com …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ConnectionError: (rootccmclientSDK:CCM_Application:String) [Invoke-Cim
Method], CimException
+ FullyQualifiedErrorId : HRESULT 0x80338012,Microsoft.Management.Infrastructure.CimCmdlets.Invoke
CimMethodCommand
+ PSComputerName :
Hi Miguel
Add a Start-Service -inputObject Winrm in the begging of your script. Service is not running. Also add Stop-Service at the end to put the client back into the state it was
I’m getting an error at the Invoke-CimMethod line.
Invoke-CimMethod : The WS-Management service cannot process the request. The WMI provider returned an ‘invalid parameter’ error.
At line:30 char:1
+ Invoke-CimMethod -Namespace “rootccmclientSDK” -ClassName CCM_Appli …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (rootccmclientSDK:CCM_Application:String) [Invoke-CimMethod], CimException
+ FullyQualifiedErrorId : HRESULT 0x8033811e,Microsoft.Management.Infrastructure.CimCmdlets.InvokeCimMethodCommand
In my case the issue was, that the package had multiple revisions. tried to provide with where object to take the latest revision of the package and it was installed successfull.
Hi TimmyIT,
thanks for the tip it will be very usefull!
Hi,
i am looking for powershell script which can install the TS under Operating Systems in Software center.
Above code works for Applications, but not for Programs under Operating Systems.
Looking help on this.
thanks
Thanga
Tried above to trigger repair remotely and it works well if cache has the latest content. Is there any way to download latest content in cache prior to triggering repair method?
Downloadcontents method of ccm_application does not seem to work
Any pointers would be helpful
Yes! Finally something about springboard data science.
Everything looks like it’s working – the $Application and $args populated correctly, even returns a JobID and Return value of 0, but doesn’t actually invoke anything…anybody have any ideas? Tried running as standard user and admin user, no difference
Win10 1809
SCCM 1810
No sorry can’t recall seeing this, I just tested on Win10 1809 and ConfigMgr 1902 and it was working fine for me. On the client side do you see any indication that the application started to Install in the AppEnforce.log located in C:\windows\ccm\logs ?
Hey Timmy
Does this only work on software that is locally cached on a remote computer, or does it prompt the remote computer to download the software from the server?
I can download chrome no problem since it’s locally cached but no other software. I am using the exact name as it is in SCCM.
I keep receiving this error:
Invoke-CimMethod : The WinRM client cannot process the request. Property “IsMachineTarget” with MI type MI_STRING does not match the expected type from the schema: MI_BOOLEAN.
Any help would be much appreciated.
Hey,
If the application is available for the remote computer it downloads the content just as it would do if you clicked on “Install” from software center. As for the “IsMachineTarget” property, are you deploying the application to a device group or user group? Its a couple of years ago I created this script but if I remember correctly it only works if you target devices, but I could be wrong. Under Deployment types -> properties -> User Experience are you installing the software for SYSTEM or User?
Hey,
I spoke with the application team and they said whether it’s deployed to a machine or user is based on the application.
However, when I just run $Application = (Get-CimInstance -ClassName CCM_Application -Namespace “root\ccm\clientSDK” -ComputerName $Computername | Where-Object {$_.Name -like $AppName}) to see if it filled the $application variable is filled, it’s empty.
If I run that line with an application that’s already installed, the variable is filled. I checked the properties of the installed applications and they all say IsMachineTarget = $false.
I’m assuming that you can’t push out the install if it’s targeted to a user or user group, correct?
I’m trying this script in Powershell 5
I keep getting this error regardless of what I pass for AppName
Invoke-InstallSCCMApplication -AppName “Quip” -Method Install
Invoke-InstallSCCMApplication : Unable to invoke CIM Method for localhost:’Quip’: No instance found with given property values.
At line:1 char:1
+ Invoke-InstallSCCMApplication -AppName “Quip” -Method Install
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-InstallSCCMApplication
if I run Get-CimInstance -ClassName CCM_Application -Namespace “root\ccm\clientSDK” -ComputerName “localhost” | Where-Object {$_.Name -like “Quip”} for instance I get
ContentSize :
Deadline :
Description :
ErrorCode : 0
EstimatedInstallTime :
EvaluationState : 3
FullName : Quip
Name : Quip
NextUserScheduledTime :
PercentComplete : 0
Publisher : Quip
Type : 1
AllowedActions : {Install}
AppDTs :
ApplicabilityState : Applicable
ConfigureState : NotNeeded
DeploymentReport :
EnforcePreference : 2
FileTypes :
HighImpactDeployment :
Icon : iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALESURBVFhHvZfLThRBFIZZQhT37hiQBBMYL1FXOu5QHBlFm
uhCtwoYkKA8ghB9AUffwPfAwMJLYEiIs5TEu4AZHJkh6fL/y66hevqgzUwXnXyLOnXq1J/u06dOtezMjMRiPtNxGHjgGVgAH0EV/AZfAlse3ALtUgwJ0WiDYCnwApSAikkZPAddUkwb0UiwuBXMggrQgZev9qkPty
+o73f71dbkNQU/TXnqulofHVBrdzLwSatXF1NGCNc+Aa12bBvRiAWd4B3QgVaHTqvSRK624f/YmsyponfOFlIAKcxF9ooY4NgLPnHhm0s9amNsQNwkDj/vZxHjuBHBPDkFe2i/0AAOR8EaF6zkTqjt6WEx8H5gjJX
cSSPiK+iEPSoAE21gkY7cvPrIEwM2AmNZIvhp22CPCJijw+v+Hqi+IQZqBr4J63M8hm1XAAz81apMmo2xK2KAJNgcz5rEZP3QSWkE8D9X74fPiAuTpOidNW8hj3ELNz8CdJEpTQyKi/zColK+r2I/8OUaKRZ/0UAA
9zxEASM0LGV7xQXEX327fwFYI8UihcG0EeFRAOs3Ktx50dkFrJiBgDwF6F/vx73LorMLWNwCAQsU8JmDXw92a7trylNDRsA3CtjhoPIwXHj84lLwQZt/GMuOzcIUCKhQwPZfAeGym6yA5VBsEghQFMD6rI/UeieX2
AJ0Eq6PHlwSElsAOxfdaEiOrrAFsIdDIeoTHUmSldBgC2gH7OH27HqSroSkJgADijiww8hQL6Ab6ON4c9zdcWwTEkAweEoD+0AXDUk9kgC24execVol25JJRAQQGI4BXZgowuWbEAUQGNNAH1D8HK5yYk8BBBNdQF
9MmJhso9jJYC4x/imAYJJtOq9mbCC1M69drJi8hvHsaCZPTExxcxs4NXI5jYsvbioBZ17PbwKeHTzAmKy1t9MA/nym4+Ufh75CUjFYoSgAAAAASUVORK5CYII=
Id : ScopeId_6C900AD6-A53B-4C44-B96C-1002E20C5DF9/Application_fb7b7b4f-943e-4bf7-983b-15b78b4a03e9
InformativeUrl :
InProgressActions : {}
InstallState : NotInstalled
IsMachineTarget : False
IsPreflightOnly : False
LastEvalTime : 11/23/2019 10:34:47 AM
LastInstallTime : 6/22/2019 12:35:45 PM
NotifyUser : False
OverrideServiceWindow : False
RebootOutsideServiceWindow : False
ReleaseDate :
ResolvedState : Available
Revision : 38
SoftwareVersion : 5.4.32
StartTime : 6/14/2019 12:45:00 PM
SupersessionState : None
UserUIExperience : True
PSComputerName : localhost
So it’s there as Quip but gives the previous error. Am I doing something wrong? Or is there additional changes that need to be made to the script to get it working with Powershell 5?
I run this and it does nothing. It doesn’t even do anything to the log file. But I get no error.
If you want to run this script locally, remove ComputerName Parameter. It will work.
Thank you very much. All other howtos I tried mentioned CCM_Program insteadl of CCM_Application and did not work.
On the remote computer itself, is it possible to start installing (including reboot) of the updates available?
i want to try to do this but locally after a fresh image laptop i want to run a script that will automated a list of software available in software center
I want to run this as @creyes3 from an sd card and logging to the SDcard back … If use PSScriptRoot loging and generating a random string that is giving the hostname like ($PCname = hostname) and i still got an error massage
Modded to install all available from Ansible Automation win_shell without function if you need it:
$hostname=hostname
$Applications = (Get-CimInstance -ClassName CCM_Application -Namespace “root\ccm\clientSDK” -ComputerName $hostname)
ForEach ($Application in $Applications) {
$Args = @{EnforcePreference = [UINT32] 0
Id = “$($Application.id)”
IsMachineTarget = $Application.IsMachineTarget
IsRebootIfNeeded = $False
Priority = ‘High’
Revision = “$($Application.Revision)”}
Invoke-CimMethod -Namespace “root\ccm\clientSDK” -ClassName CCM_Application -ComputerName $hostname -MethodName Install -Arguments $Args}
Thanks for the help!
This is a nice Script but it doesn’t force the uninstall process.
Was looking for how to unstuck the forever installing loop in Software center.
What is your detection method? When SC does a continuous install like that it is usually a bad detection method.
I Have no idea, I’m just a poor tier 1 support trying to get my life easier 😀
Just went through all the documentation for detection method, I cannot get to this property in SCCM, is it accessible only when you create the application ?
How can you modify it from application already deployed ?
That’s a good point, I was struggling to figure out where is the point of communication between SC and SCCM, tried a lot of different things with scripts but none solved my issue ( I got a hands a nice tools tho like this one above !)
Open the application in SCCM. At the bottom there is a “Deployment Types” amd a “Deployments” tab when you have the application selected in the console.
In the Deployment Types tab you will see the deployment method for the application. Right click it and select “Properties” That is where you will see the “Detection Method” tab.
If you cannot see any of this. I suggest finding the admin that created the package and letting them know their detection method is broken.
Script on page https://gist.github.com/mwallner/9bb87e460dec1e4eec2c70217b1ec6ae is very usefull.
Download the ps1 file. At the bottom, add a new line with text Install-SCCMUpdates (this calls the procedure in the ps-file).
Where do we list the computers, in other words where or how are the computer names referenced in the command??
Your script for Apps in Software Center; I’m trying to install Windows 10 that has been downloaded but awaiting for user input to install. How do I automate the installation of the Operating System?
For “security reasons” Microsoft removed the capability to remotely force that through WMI when its available. Instead what you need to do is to run a task in the users context to be able to kick it of. Many years ago I created a .exe file that just did that. Today I would probably use Powershell Application Deployment Toolkit to do the same thing.
Wow great post. I tweaked the script abit to be able to use a List.txt of computers. And also
accepting wildcard application names. But is it possible to make the command run on ALL applications stuck in Software Center. Ive tried adjusting code but i just cant get it to work without specifying an application name.
Please help
Yes that can be done. Here’s a quick example I tested in my lab.
$Computername = “localhost”
$Method = “Install”
$Applications = (Get-CimInstance -ClassName CCM_Application -Namespace “root\ccm\clientSDK” -ComputerName $Computername)
Foreach ($application in $Applications) {
$Args = @{EnforcePreference = [UINT32] 0
Id = “$($Application.id)”
IsMachineTarget = $Application.IsMachineTarget
IsRebootIfNeeded = $False
Priority = ‘High’
Revision = “$($Application.Revision)” }
Invoke-CimMethod -Namespace “root\ccm\clientSDK” -ClassName CCM_Application -ComputerName $Computername -MethodName $Method -Arguments $Args
}
I tested the code works good thank you very much Timmy. This blog post was very helpful. The only thing missing for me is that i cant get the Uninstall switch to do anything at all. Install works great triggering runspace matching packageid. But uninstall applications is just not working. Are there a command for “repair” /reinstall aswell that i could test? :/
Regards
How did you modify the script to accept wildcards?
is it more than simply….
Example: Trigger-AppInstallation -AppName “Acrobat Reader DC*” -Method Install
?
Thanks!