SCCM Web Service for Machine Variables 1.0

So I have been playing around with setting up an OpenStack implementation and wanted to automate the deployment of operating systems.  The first thing that came to mind is that the default hyper-visor is Linux KVM which obviously is on the Linux operating system.  What I needed to do is pre-populate some Machine variables that SCCM could use to select the correct OS, PC Name, Networking Speed, AV install, etc and just boot the machine and everything would be zero touch.  My first implementation was a powershell script that used the SCCM powershell module to connect to our SCCM primary and add those variables.  The problem I ran into is that since I am supporting OSD on a Non-Windows platform, I needed some other way besides powershell. I am already a user and Fan of Maik Koster’s Deployment Web service. I already knew that Maik had not written any methods for the machine variables in his service. So I searched around on the internet to see if anyone had picked this request up and to my surprise, no one had written this one up.

Now Maik’s Service is written in VB Language but I haven’t coded in VB in at least 15 years. So I decided to attempt to write a service in C# since that is what I have been working with the past 6 years. Web services are pretty much standard coding except for the data you are querying. After a ton of Cheetos, Doritos, Root-beer, Sierra Mist, ho-hos, Christmas Tree Cakes, Santa Brownies, and red velvet Christmas tree cakes I created this….

SCCM_MV

I have created 3 methods to use, DeleteMachineVariable, GetMachineVariable, and SetMachineVariable. The Get and Set Machine Variables are pretty straight forward, they will return 0 for success and a 1 for failure. For the GetMachineVariable method I added all three parts of the variable. These are the Name, Value, and IsMasked. The IsMasked field accepts $true or $false.  In the screenshot below you can see some powershell calls to retrieve results from the web service.

Powershell_MS_CreateThe results of those commands are show in the console output and can be used in anyway you use normal powershell code.

Powershell_MS_Create_Results

In the results screenshot you can see that there is a variable with a IsMasked that is set to True and the Value for that variable is empty. this seems to be by design. I’m not sure why you would want to use a Masked variable but if you do just know that its not readable by the web service for the value information.

This web service is intended to be an supplement to Maik’s web service. If you want to submit machine variables from the client, you will have to first call GetResourceID method in Maik’s web service to get that resourceID associated with the MAC address of the client.

Setting the web service up is the same as Maik’s and even the logging folder is similar. you will have to modify the Web.config file and change the SiteServer, SiteCode, ADAccount, and ADPassword settings to access your SCCM Primary or CAS. I run a CAS and three primaries and have the web service pointed at the CAS and it works just fine with replication. You could install the web service on each Primary if you like.  Additionally, this web service is written in .NET 4.0. You may ask why 4.0 and not 3.0/2.0? The answer is simple, SCCM 2012 R2 is leveraging .NET 4.0 and I wanted to keep things consistent. Besides, who wants to use tech almost 10 years ago…..

Maik’s website
Maik’s Web Service on CodePlex

Download:   SCCM_MV

Leave a Reply

Your email address will not be published. Required fields are marked *


*