Long time, no post.
Expect a bunch more action on this blog, I'm working on a project that is based on System Center Orchestrator and ConfigMgr 2012 SP1 - as such, I'm writing a custom Orchestrator Integration Pack to contain a bunch of (what I think) are useful actions. Anyway, onto the post...
I have been trying to write an Orchestrator action to inject Drivers into a specified boot image. But hey, that's all detailed in the ConfigMgr SDK right? Well... kind of!
The SDK shows you how to import the driver to the package - However when you run the RefreshPkgSource method of the SMS_BootImagePackage class with the following:
bootImagePackage.ExecuteMethod("RefreshPkgSource",null);An SMSException is raised, and in the SMS Provider logs you will notice an eror along the lines of: *~*~Null parameter object! ~*~*
Annoying!
So I checked the paramters of the RefreshPkgSource method here - It has a ContextID parameter defined as optional. I then checked the ContextID property of an instance of the SMS_BootImagePackage class, and saw a blank entry. Putting two and two together, it seems it is expecting something other than null to actually run the method.
So I created a Dictionary object to hold the blank parameter instead of specifying a null parameter and YOWZA - success!
Full code is as follows:
Configurations.WQLConnect wql = new Configurations.WQLConnect(); WqlConnectionManager connection = wql.Connect(Credentials.siteServer, Credentials.User, Credentials.Password); try { // Get the boot image package. IResultObject bootImagePackage = connection.GetInstance(@"SMS_BootImagePackage.packageId='" + request.Inputs["Boot Image Package ID"].AsString() + "'"); // Get the driver. IResultObject driver = connection.GetInstance("SMS_Driver.CI_ID=" + request.Inputs["Driver CI"].AsString()); // Get the drivers that are referenced by the package. ListreferencedDrivers = bootImagePackage.GetArrayItems("ReferencedDrivers"); // Create and populate an embedded SMS_Driver_Details. This is added to the ReferencedDrivers array. IResultObject driverDetails = connection.CreateEmbeddedObjectInstance("SMS_Driver_Details"); driverDetails["ID"].IntegerValue = request.Inputs["Driver CI"].AsInt32(); driverDetails["SourcePath"].StringValue = driver["ContentSourcePath"].StringValue; // Add the driver details to the array. referencedDrivers.Add(driverDetails); // Add the array to the boot image package. bootImagePackage.SetArrayItems("ReferencedDrivers", referencedDrivers); // Commit the changes. bootImagePackage.Put(); Dictionary inParams = new Dictionary (); inParams.Add("ContextID", ""); IResultObject result = bootImagePackage.ExecuteMethod("RefreshPkgSource", inParams);
Hope that helps someone, and saves you a little bit of time!
I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work Call Center Management
ReplyDelete