PowerShell DSC Journey – Day 13

When I left off yesterday I had a functioning Custom Resource. By functioning I mean that I can run some tests without errors (unless it should error) and that it can create a new Hardware Profile name if one doesn’t exist. Other than that, it’s pretty much worthless. So, let’s add in a few more properties to the Resource and then update the Get, Set, and Test functions accordingly. I am going to out on a limb here and say that this isn’t all going to happen today.

I am going to add 3 additional Properties to my Resource. I should also mention that I got rid of Depends On, because nothing seems to use it.

And of course it wouldn’t be a blog of mine if it didn’t immediately start off with an error.

Alright, so I can’t use CPU’s but I can use CPUs. Got it. That seems kind of silly to me, but whatever. 2/2 on errors so far.

Alright, so I guess I need to include all the properties when I update it. Truth be told I couldn’t remember if I needed to or not so I decided to just wing it.
So, I run that with all the properties and it seems to work. However, when I open the .psm1 file, nothing has changed. That does not give me a warm and fuzzy feeling. After I do some looking around, the schema.mof has been updated with the new values, but not the .psm1 file, which I guess makes sense.

While looking at this, I realize that I need to change all 3 of those from an attribute of Read to an attribute of write, because I may need to write those attributes if it’s a new Hardware Profile.
So, I make that change and update the Resource and here’s the new Schema.MOF.

I am trying to figure out if I need to add in all the Parameters into the Get-TargetResource function, and it looks like I only need to declare the Parameters that are Mandatory, which I already have. All I think I need to do is add some logic for getting my other new parameters and returning those values. After poking around the xVMHyperV Resource this is what I come up with to add to the Get-TargetResource Function.

I am somewhat concerned that this probably shouldn’t go in the body of the Function, but probably in the section where I test for the Hardware Profile, but for right now I am going to leave it. I should mention at this time that I also made this change to the section where I test for the VMM Server.

The else part is not needed since it will just error out anyways if the server is incorrect, but for right now I am going to leave it.

I then make these changes to the returnValue section to return the correct values (or I hope at least).

I am fully expecting this to blow up in my face and it’s near the end of the day, so I am going to stop here and pick up on this again tomorrow.