Forum Discussion

Sidaramappa's avatar
Sidaramappa
Copper Contributor
Mar 11, 2024

updating content of the application in SCCM using WMI

Hi,

I wan to Call Update Content API on Application in Sccm  using WMI Object.

 

I tried with below code 

ManagementPath MgmtPath1 = new ManagementPath($"SMS_SoftwareUpdatesPackage.PackageID='{applicationID}'");
ManagementClass ProcessClass1 = new ManagementClass(Scope, MgmtPath1, null);

ManagementObject managementObject = ProcessClass1.CreateInstance();
if (managementObject != null)
{
var inParams = managementObject.GetMethodParameters("AddUpdateContent");
inParams.Properties["ContentIDs"].Value = new UInt32[] { };
inParams.Properties["ContentSourcePath"].Value =
new String[] { @"\\LocalHost\publish\7-Zip (x64)\16\4\" };
inParams.Properties["bRefreshDPs"].Value = false;

ManagementBaseObject outParams1 = managementObject.InvokeMethod("AddUpdateContent", null, null); ///An Exception is thrown here
}

 

But it is throwing an Error "Invalid Method Param(s)" or "Not Found" Exception .

Am I Missing here anything? what would be the best way to call it?

 

 

 

 

Resources