PowerShell DSC Journey – Day 11

So yesterday I finished work on Get-TargetResource. I use that term very loosely because I don’t believe in any way that it is actually going to work when I try to test it using the Resource Designer or with an actual Configuration. Either way it seems to “work” for now, so now we are going to move on to the Test-TargetResource function.

I am having a hard time wrapping my brain around this Test-TargetFunction, but lets get to work and see what we can break here. Looking at various existing DSC Resources, in my extremely simple example here I don’t think I need to really do anything beyond what I have already besides return $True or $False.

First thing that I do is that I copy the stuff from Get-TargetResource function to my Test-TargetFunction, so what I have looks like this.

I think the only thing that needs to be done right now is to change the check for the Hardware Profile to return $True or $False, so I modified it to look like this. I based this off of the xVMHyperV Resource.

So, with that being done, let’s add some tests here and see what happens. Again, copying from the tests I used for Get-TargetResource.

Test 1! I AM A DSC WIZARD!!!!!!!!!

Clearly, I am not a DSC Wizard. Far from it, but I am pretty excited my screen didn’t explode with red text :).



That’s exactly what should happen, since that server doesn’t exist. Tomorrow we are going to explore the Set-TargetResource function, even though right now I don’t believe I have anything that needs to be set. However, I will have stuff that will need to be set eventually so I suppose I should get started on it anyways.

Should also mention that there is still no sign of Depends On, so not real sure what is going on there yet.