I'm trying to get SCCM applications to install/uninstall remotely via WMI queries from a .Net app.
Code I have is below:
Dim wmiLoc As ManagementScope = New ManagementScope("\\" & Target & "\root\ccm\ClientSDK", Options)
Dim wmiProcPath As ManagementPath = New ManagementPath("CCM_Application")
Dim mc As ManagementClass = New ManagementClass(wmiLoc, wmiProcPath, Nothing)
Dim inParams As ManagementBaseObject = mc.GetMethodParameters("Install")
inParams("EnforcePreference") = "0"
inParams("Id") = ThisID
inParams("IsMachineTarget") = ThisIMT
inParams("IsRebootIfNeeded") = "False"
inParams("Priority") = "High"
inParams("Revision") = ThisRev
Dim outParams As ManagementBaseObject = mc.InvokeMethod("Install", inParams, Nothing)
Console.WriteLine("Job Id: {0}, Return: {1}", outParams("JobId"), outParams("ReturnValue"))
I suppose you can assume the Rev#, ID, and IsMachineTarget are correct given I pull them from the information I query before this from the machine.
** When I send this particular request to the machine, it logs it into CCM/Logs AppDiscovery only. It shows it in 4 lines: it got the request (not for uninstall specifically but the query), performing detection, discovered app, and detected app deployment.
After it logs this, it does nothing. It's almost as if it didn't get the "Uninstall" or "Install" part of it. **
Anyone have any experience handling this? I know there are other solutions out there but I'm trying to work in my own. I can probably do this via powershell but I'd rather not if possible.