PowerShell Desired State Configuration (DSC) Journey – Day 16

When I started this original project my intention was to work through all of the individual DSC Resources one at a time, hoping that I could get through them all before they released some more.  Well, that didn’t happen.  On Friday the PowerShell Team released DSC Resource Kit Wave #3, which is freaking awesome.  So, instead of working through the rest on my list, I am just going to start working on a project I probably should have been working on anyways.  I want to build a Configuration to replace using Virtual Machine Manager Templates, with the goal being to be able to deploy multiple, identically configured servers at one time.  I want to do this for a demo I am going to be doing (hopefully before I leave for the PowerShell Summit).

The information on the Hyper-V module can be found here, and I will also be referencing this post on building Composite DSC Resources.  After a lot of time spent looking at the documentation, I am just going to follow along with the example on the TechNet page in creating the various parameters and pieces of the Hyper-V portion of my Configuration.

First, let’s start with the xVMSwitch Resource.

PS C:\Scripts> Get-DscResource -Name xVMSwitch | Select-Object -ExpandProperty Properties

Name                                            PropertyType                                                                        IsMandatory Values                                         
----                                            ------------                                                                        ----------- ------                                         
Name                                            [string]                                                                                   True {}                                             
Type                                            [string]                                                                                   True {External, Internal, Private}                  
AllowManagementOS                               [bool]                                                                                    False {}                                             
DependsOn                                       [string[]]                                                                                False {}                                             
Ensure                                          [string]                                                                                  False {Absent, Present}                              
NetAdapterName                                  [string]                                                                                  False {}

Here is what I started off my Configuration with.

Configuration BuildTestVM
{

Import-DscResource -Module xHyper-V

Param{

    [Parameter(Mandatory)]
    [ValidateNotNullorEmpty()]
    [String]$SwitchName,

    [Parameter(Mandatory)]
    [ValidateNotNullorEmpty()]
    [String]$SwitchType

}

    xVMSwitch DSCSwitch
    {
        Name = $SwitchName
        Ensure = "Present"
        Type = $SwitchType
        AllowManagementOS = "True"
    }

}

ProTip:  Don’t import the Module before declaring your parameters like I did above.  It will fail miserably.  I should also mention that all of these examples will be done on my PC using Hyper-V Manager because I don’t have access to a functional lab that will allow me to do what I want to do here.  I Invoke the Configuration and get a .MOF file for my PC.

BuildTestVM -SwitchName DSCTest -SwitchType Internal

I then push out that Configuration file to my PC using this command.

Start-DscConfiguration -Wait -Verbose -Path .\BuildTestVM

Here is the Verbose output and a screenshot showing the completed switch.  It amazes me how fast this completed.  If I create a new VMSwitch through the GUI and select the “Use Guest OS” option my computer literally locks up for 5 minutes.

PS C:\scripts> Start-DscConfiguration -Wait -Verbose -Path .\BuildTestVM
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' =
root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer localhost with user sid S-1-5-21-738551990-92959840-526660263-26310.
VERBOSE: [localhost]: LCM:  [ Start  Set      ]
VERBOSE: [localhost]: LCM:  [ Start  Resource ]  [[xVMSwitch]DSCSwitch]
VERBOSE: [localhost]: LCM:  [ Start  Test     ]  [[xVMSwitch]DSCSwitch]
VERBOSE: [localhost]:                            [[xVMSwitch]DSCSwitch] Checking if Switch DSCTest is Present ...
VERBOSE: [localhost]:                            [[xVMSwitch]DSCSwitch] Switch DSCTest is not Present
VERBOSE: [localhost]: LCM:  [ End    Test     ]  [[xVMSwitch]DSCSwitch]  in 10.1500 seconds.
VERBOSE: [localhost]: LCM:  [ Start  Set      ]  [[xVMSwitch]DSCSwitch]
VERBOSE: [localhost]:                            [[xVMSwitch]DSCSwitch] Switch DSCTest is not Present.
VERBOSE: [localhost]:                            [[xVMSwitch]DSCSwitch] Creating Switch ...
VERBOSE: [localhost]:                            [[xVMSwitch]DSCSwitch] Switch DSCTest is now Present.
VERBOSE: [localhost]: LCM:  [ End    Set      ]  [[xVMSwitch]DSCSwitch]  in 5.7440 seconds.
VERBOSE: [localhost]: LCM:  [ End    Resource ]  [[xVMSwitch]DSCSwitch]
VERBOSE: [localhost]: LCM:  [ End    Set      ]
VERBOSE: [localhost]: LCM:  [ End    Set      ]    in  17.3600 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 17.558 seconds

dsc27

Tomorrow I will work on creating the .VHDX file(s) that are required.

PowerShell Desired State Configuration (DSC) Journey – Day 15

Yesterday I explored the Archive Resource.  Today I am going to look at the Role Resource.  When you look at Get-DSCResource it isn’t called Role.  It’s called WindowsFeature.  Make complete sense right?  Here are the expanded properties.

Name                                            PropertyType                                                                        IsMandatory Values                                         
----                                            ------------                                                                        ----------- ------                                         
Name                                            [string]                                                                                   True {}                                             
Credential                                      [PSCredential]                                                                            False {}                                             
DependsOn                                       [string[]]                                                                                False {}                                             
Ensure                                          [string]                                                                                  False {Absent, Present}                              
IncludeAllSubFeature                            [bool]                                                                                    False {}                                             
LogPath                                         [string]                                                                                  False {}                                             
Source                                          [string]                                                                                  False {}

Alright.  Let’s do this.  You can find plenty of examples where people have installed one or two features using DSC.  Am I going to do that?  Absolutely not.  Let’s put this thing to the test.  To get a list of all the Windows Features available to install run this command.

Get-WindowsFeature -ComputerName ServerName

Alright.  Let’s try to break some stuff.  Here is all the code that I added to my ServerConfig Configuration.  I immediately want to see if I can include multiple names in one Resource block.  I am also trying to break the LogPath Property.  It says to specify a path to a log file, so I am including a log file name in here so we will see what happens with that.

        WindowsFeature MyServerFeatures
        {
            Name = "RSAT-SNMP,Remote-Assistance,BranchCache,PowerShellRoot"
            Ensure = "Present"
            IncludeAllSubFeature = $True
            LogPath = "C:\Scripts\MyServerFeatures.txt"

        }

The Consistency scheduled task on DSCTest didn’t run nearly long enough for this to have worked.  Let’s go to the log and see what I broke.

Trace-cDscOperation -ComputerName oma-dsctest-01 -SequenceID 1 | Select-Object -ExpandProperty Message

And.  This is taking a long time to return anything.  That’s usually a sign that DSC itself is doing something.  Nope.  It came back right as I finished typing that.  Of course :).

This event indicates that failure happens when LCM is trying to get the configuration from pull server using download manager WebDownloadManager. ErrorId is 0x1. ErrorDetail is The SendConfig
urationApply function did not succeed.
DSC Engine Error : 
	 Error Message The SendConfigurationApply function did not succeed. 
	Error Code : 1 
This event indicates that failure happens when LCM is processing the configuration. ErrorId is 0x1. ErrorDetail is The SendConfigurationApply function did not succeed.. ResourceId is [Windows
Feature]MyServerFeatures and SourceInfo is C:\Users\jacob.benson\SkyDrive\PowerShell\DSC\ServerConfig.ps1::112::9::WindowsFeature. ErrorMessage is PowerShell provider MSFT_RoleResource  faile
d to execute Test-TargetResource functionality with error message: The requested feature RSAT-SNMP,Remote-Assistance,BranchCache,PowerShellRoot is not found on the target machine. .
Deleting file from C:\Windows\System32\Configuration\Pending.mof

Alright, it clearly didn’t like my Feature Names.  Let’s change the formatting a bit and try again.

Name = "RSAT-SNMP","Remote-Assistance","BranchCache","PowerShellRoot"

It likes that even less (which completely makes sense, but I had to check!).  Here is the error.

Write-NodeMOFFile : Invalid MOF definition for node 'OMA-DSCTEST-01.NFM.COM': Exception calling "ValidateInstanceText" with "1" argument(s): "Convert property 'Name' value from type 
'STRING[]' to type 'STRING' failed
 At line:165, char:2
 Buffer:
leVersion = "1.0";
};^
ins
"
At C:\windows\system32\windowspowershell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:1425 char:17
+                 Write-NodeMOFFile $name $mofNode $Script:NodeInstanceAliases[$mo ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Write-Error], InvalidOperationException
    + FullyQualifiedErrorId : InvalidMOFDefinition,Write-NodeMOFFile

Alright, let’s try this instead.

            Name = "RSAT-SNMP"
            Name = "Remote-Assistance"

PowerShell ISE right away gives the second Name definition a squiggly which if you mouse over it plainly tells you that “Duplicate property resource definitions are not allowed in an instance definition”.  Well that certainly solves that.  Here is my new Configuration.

        WindowsFeature RSAT
        {
            Name = "RSAT-Role-Tools"
            Ensure = "Present"
            IncludeAllSubFeature = $True
            LogPath = "C:\Scripts\RSATFeatures.txt"

        }

        WindowsFeature PowerShell
        {
            Name = "PowerShellRoot"
            Ensure = "Present"
            IncludeAllSubFeature = $True
            LogPath = "C:\Scripts\PowerShellFeatures.txt"

        }

        WindowsFeature IISManagementTools
        {
            Name = "Web-Mgmt-Tools"
            Ensure = "Absent"
            IncludeAllSubFeature = $True
            LogPath = "C:\Scripts\IISMgmtToolsFeatures.txt"

        }

And the scheduled task is running.  While it is doing that, I am going to work on something else.  I imagine that’s going to take a while.

Checking back, I don’t see any of my Roles installed, but when I open the Add Roles and Features wizard it plainly tells me that the server has a pending restart.  Good sign!  I also check the C:\Scripts folder and see all of my specified text files in there, and it does look like everything ran.  Exciting stuff.

dsc26Time to reboot the server!  After the reboot, looking at the LocalConfigurationManager on DSCTest, it is set to reboot if needed, I wonder why it didn’t do that.  Or if I just didn’t wait long enough for it to reboot?  Either way, all the things got installed.

Now let’s install some IIS Management Tools and see if DSC will remove them.

Add-WindowsFeature -ComputerName servername.domain.com -Name "Web-Mgmt-Console" -LogPath C:\Scripts\WebConsole.txt
Success Restart Needed Exit Code      Feature Result                               
------- -------------- ---------      --------------                               
True    No             Success        {IIS Management Console, Management Tools,...

I double check using Get-WindowsFeature and it is installed.  So let’s run our scheduled task and see if it gets removed.

Before:

[X] Management Tools                                Web-Mgmt-Tools                 Installed
[X] IIS Management Console                      Web-Mgmt-Console               Installed

After:

[ ] Management Tools                                Web-Mgmt-Tools                 Available
[ ] IIS Management Console                      Web-Mgmt-Console               Available

If you are curious here is what my log file looks like when the IIS Management Tools were removed.

1760: 2014-03-27 14:47:54.926 [ServerManagerPS]           Complete initializing log file.
1760: 2014-03-27 14:47:54.926 [ServerManagerPS]           0c73a939-c0b0-496a-b087-178445f4dd1b Enumerate server component started. Component names: Web-Mgmt-Tools
1760: 2014-03-27 14:47:54.941 [ServerManagerPS]           0c73a939-c0b0-496a-b087-178445f4dd1b Enumerate server component ended with InProgress. The progress is 21.
1760: 2014-03-27 14:47:55.969 [ServerManagerPS]           0c73a939-c0b0-496a-b087-178445f4dd1b Get enumeration state ended with InProgress. The progress is 57.
1760: 2014-03-27 14:47:56.976 [ServerManagerPS]           0c73a939-c0b0-496a-b087-178445f4dd1b Get enumeration state ended with InProgress. The progress is 92.
1760: 2014-03-27 14:47:57.979 [ServerManagerPS]           0c73a939-c0b0-496a-b087-178445f4dd1b Get enumeration state ended with InProgress. The progress is 92.
1760: 2014-03-27 14:48:00.328 [ServerManagerPS]           0c73a939-c0b0-496a-b087-178445f4dd1b Get enumeration state ended with Completed.

1760: 2014-03-27 14:48:00.328 [ServerManagerPS]           Complete initializing log file.
1760: 2014-03-27 14:48:00.328 [ServerManagerPS]           1c9cab0e-4dea-459c-b116-1c658ca0391b Enumerate server component started. Component names: Web-Mgmt-Console
1760: 2014-03-27 14:48:00.594 [ServerManagerPS]           1c9cab0e-4dea-459c-b116-1c658ca0391b Enumerate server component ended with Success.

1760: 2014-03-27 14:48:00.625 [ServerManagerPS]           Complete initializing log file.
1760: 2014-03-27 14:48:01.500 [ServerManagerPS]           511f1a0d-a53b-4501-9e44-38c6a613cac0 Enumerate server component ended with Success.

1760: 2014-03-27 14:55:32.243 [ServerManagerPS]           Complete initializing log file.
1760: 2014-03-27 14:55:32.243 [ServerManagerPS]           7f1b990f-7950-470f-825d-91343ed04d02 Enumerate server component started. Component names: Web-Mgmt-Tools
1760: 2014-03-27 14:55:32.275 [ServerManagerPS]           7f1b990f-7950-470f-825d-91343ed04d02 Enumerate server component ended with InProgress. The progress is 21.
1760: 2014-03-27 14:55:33.294 [ServerManagerPS]           7f1b990f-7950-470f-825d-91343ed04d02 Get enumeration state ended with InProgress. The progress is 57.
1760: 2014-03-27 14:55:34.310 [ServerManagerPS]           7f1b990f-7950-470f-825d-91343ed04d02 Get enumeration state ended with InProgress. The progress is 92.
1760: 2014-03-27 14:55:35.317 [ServerManagerPS]           7f1b990f-7950-470f-825d-91343ed04d02 Get enumeration state ended with InProgress. The progress is 92.
1760: 2014-03-27 14:55:36.620 [ServerManagerPS]           7f1b990f-7950-470f-825d-91343ed04d02 Get enumeration state ended with Completed.

1760: 2014-03-27 14:55:36.636 [ServerManagerPS]           Complete initializing log file.
1760: 2014-03-27 14:55:36.933 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Enumerate server component ended with Success.
1760: 2014-03-27 14:55:39.101 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Alter server component started. Component names: Web-Mgmt-Tools,Web-Mgmt-Console,Web-Server
1760: 2014-03-27 14:55:39.118 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Alter server component ended with InProgress. The progress is 20
1760: 2014-03-27 14:55:40.127 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Alter server component started. Component names: Web-Mgmt-Tools,Web-Mgmt-Console,Web-Server
1760: 2014-03-27 14:55:40.143 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Get alteration state ended with InProgress. The progress is 24.
1760: 2014-03-27 14:55:41.158 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Alter server component started. Component names: Web-Mgmt-Tools,Web-Mgmt-Console,Web-Server
1760: 2014-03-27 14:55:41.190 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Get alteration state ended with InProgress. The progress is 32.
1760: 2014-03-27 14:55:42.205 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Alter server component started. Component names: Web-Mgmt-Tools,Web-Mgmt-Console,Web-Server
1760: 2014-03-27 14:55:42.221 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Get alteration state ended with InProgress. The progress is 44.
1760: 2014-03-27 14:55:43.237 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Alter server component started. Component names: Web-Mgmt-Tools,Web-Mgmt-Console,Web-Server
1760: 2014-03-27 14:55:43.283 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Get alteration state ended with InProgress. The progress is 49.
1760: 2014-03-27 14:55:44.299 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Alter server component started. Component names: Web-Mgmt-Tools,Web-Mgmt-Console,Web-Server
1760: 2014-03-27 14:55:44.330 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Get alteration state ended with InProgress. The progress is 56.
1760: 2014-03-27 14:55:45.346 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Alter server component started. Component names: Web-Mgmt-Tools,Web-Mgmt-Console,Web-Server
1760: 2014-03-27 14:55:45.362 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Get alteration state ended with InProgress. The progress is 57.
1760: 2014-03-27 14:55:46.377 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Alter server component started. Component names: Web-Mgmt-Tools,Web-Mgmt-Console,Web-Server
1760: 2014-03-27 14:55:46.752 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Get alteration state ended with InProgress. The progress is 90.
1760: 2014-03-27 14:55:47.761 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Alter server component started. Component names: Web-Mgmt-Tools,Web-Mgmt-Console,Web-Server
1760: 2014-03-27 14:55:47.761 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Get alteration state ended with InProgress. The progress is 90.
1760: 2014-03-27 14:55:48.769 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Alter server component started. Component names: Web-Mgmt-Tools,Web-Mgmt-Console,Web-Server
1760: 2014-03-27 14:55:48.769 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Get alteration state ended with InProgress. The progress is 90.
1760: 2014-03-27 14:55:49.790 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Alter server component started. Component names: Web-Mgmt-Tools,Web-Mgmt-Console,Web-Server
1760: 2014-03-27 14:55:49.790 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Get alteration state ended with InProgress. The progress is 90.
1760: 2014-03-27 14:55:50.806 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Alter server component started. Component names: Web-Mgmt-Tools,Web-Mgmt-Console,Web-Server
1760: 2014-03-27 14:55:50.806 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Get alteration state ended with InProgress. The progress is 91.
1760: 2014-03-27 14:55:51.821 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Alter server component started. Component names: Web-Mgmt-Tools,Web-Mgmt-Console,Web-Server
1760: 2014-03-27 14:55:51.837 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Get alteration state ended with InProgress. The progress is 91.
1760: 2014-03-27 14:55:52.853 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Alter server component started. Component names: Web-Mgmt-Tools,Web-Mgmt-Console,Web-Server
1760: 2014-03-27 14:55:52.868 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Get alteration state ended with InProgress. The progress is 91.
1760: 2014-03-27 14:55:53.884 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Alter server component started. Component names: Web-Mgmt-Tools,Web-Mgmt-Console,Web-Server
1760: 2014-03-27 14:55:53.884 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Get alteration state ended with InProgress. The progress is 91.
1760: 2014-03-27 14:55:54.890 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Alter server component started. Component names: Web-Mgmt-Tools,Web-Mgmt-Console,Web-Server
1760: 2014-03-27 14:55:54.890 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Get alteration state ended with InProgress. The progress is 91.
1760: 2014-03-27 14:55:55.906 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Alter server component started. Component names: Web-Mgmt-Tools,Web-Mgmt-Console,Web-Server
1760: 2014-03-27 14:55:56.469 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Get alteration state ended with InProgress. The progress is 91.
1760: 2014-03-27 14:55:57.484 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Alter server component started. Component names: Web-Mgmt-Tools,Web-Mgmt-Console,Web-Server
1760: 2014-03-27 14:55:57.484 [ServerManagerPS]           e14cb45d-d0a0-403c-b430-052f5440e747 Get alteration state ended with Completed.

I am off tomorrow but I will pick back up next week.  I think it’s time for some more Custom Resources.  Hyper-V Anyone?

Orchestrator Runbook Fails – Failed to get members of collection. The SMS Provider reported an error

The TechNet Forum thread is here if you are interested, but I wanted to write a quick blog for my reference in the future.

I created an Orchestrator Runbook that would get all the devices in an SCCM collection, and then put them into Maintenance Mode in SCOM.  However, every time I ran the runbook and put in the collection name, it failed with this error:

Full Error is:  “Failed to get members of collection ‘{Collection Name from “Initialize Data”}’.”. The SMS Provider reported an error. Details: Generic failure

After my SCCM admin and I exhausted all the options we could think of, I went to the forums.  The answer turned out to be surprisingly simple.

I had just typed the text {Collection Name from “Initialize Data”}.  What I needed to do was in the Collection, Right Click, Subscribe, Published Data and select Collection Name.  Once I did that for the Get Collection Member and Start/Stop Maintenance Mode, it ran perfectly!

PowerShell Desired State Configuration (DSC) Journey – Day 14

On Monday I ran into some issues with the Environment Resource (I am not done with that either, I just need some time to setup my home lab).  Today I am going to mess around with the Archive Resource.  And in a weird, ongoing issue, the Consistency scheduled task is still running.  So let’s reboot the server like usual before we start.

Archive Resource information can be found here.  The Properties of the Resource are shown below.

Name                                            PropertyType                                                                        IsMandatory Values                                         
----                                            ------------                                                                        ----------- ------                                         
Destination                                     [string]                                                                                   True {}                                             
Path                                            [string]                                                                                   True {}                                             
Checksum                                        [string]                                                                                  False {CreatedDate, ModifiedDate, SHA-1, SHA-256...} 
DependsOn                                       [string[]]                                                                                False {}                                             
Ensure                                          [string]                                                                                  False {Absent, Present}                              
Force                                           [bool]                                                                                    False {}                                             
Validate                                        [bool]                                                                                    False {}

I have a .zip file of PowerShell scripts that I want to unzip and ensure always exist in the C:\Scripts directory.  Here is the code that I added to my Configuration script.  I chose to include the Checksum Property because that pretty much ensures that I will break something.

        Archive MyScripts
        {
            Destination = "C:\Scripts"
            Path = "\\servername\scripts\MyScripts.zip"
            DependsOn = "[File]ScriptFolder"
            Checksum = "modifiedDate"

        }

And I was right!  Here is the relevant information in the Trace-cDSCOperation output.

This event indicates that failure happens when LCM is processing the configuration. ErrorId is 0x1. ErrorDetail is The SendConfigurationApply function did not succeed.. ResourceId is [Archive
]MyScripts and SourceInfo is C:\Users\jacob.benson\SkyDrive\PowerShell\DSC\ServerConfig.ps1::63::9::Archive. ErrorMessage is PowerShell provider MSFT_ArchiveResource  failed to execute Test-T
argetResource functionality with error message: Specifying a Checksum without requesting content validation (the Validate parameter) is not meaningful
Parameter name: Checksum .

Fair enough.  The TechNet article lists a Validate Property but it has no description, and their example doesn’t use it.  This should be fun.  If I type the word Validate in ISE, highlight it, and do Ctrl + Right Click + Start Intellisense it tells me that it is looking for a bool value.  New code is below.

        Archive MyScripts
        {
            Destination = "C:\Scripts"
            Path = "\\servername\scripts\MyScripts.zip"
            DependsOn = "[File]ScriptFolder"
            Checksum = "modifiedDate"
            Validate = $True

        }

Great Success!  Here is the contents of my Scripts folder.

dsc24

My Checksum is based on the modifiedDate, so let’s modify the .Zip file by removing some scripts and see what happens.  I removed the first 5-7 scripts from the .Zip file and forced DSCTest to Pull it’s Configuration again.  There shouldn’t be any changes because the files that are currently in the .Zip file already exist.  And…..I was correct!  There were no changes to the contents of the C:\Scripts folder.

One last test before I head to a meeting.  Let’s set Ensure = “Absent” and let’s see what happens.  What should happen is that every script that currently resides in the .Zip file should be removed.  Boom!

dsc25

Good day today!  Looking at the Built-In DSC Resource List, I think tomorrow I will explore the DSC Role Resource.

 

PowerShell Desired State Configuration (DSC) Journey – Day 13

When we left off last week I was messing around with the Log resource and found out some interesting things about the Package resource and non MSI application installation.

Today I am going to explore using the Archive and Environment resources.  I am getting a little adventurous here attempting to tackle two at a time but I feel like I am confident enough with the DSC Resources at this point that it shouldn’t be an issue.

First up is the Environment Resource.  The Environment Resource has the Properties Name, DependsOn, Ensure, Path, and Value.  Only Name is mandatory.  Which is interesting.  I don’t know why you would Name an Environmental Variable and then not set anything else for it.  Everything is pretty self explanatory except for the Path Property.  The TechNet article says this about the Property.  “Defines the environment variable that is being configured. Set this property to $true if the variable is the Path variable; otherwise, set it to $false. The default is $false. If the variable being configured is the Path variable, the value provided through the Value property will be appended to the existing value.”  So, let’s test this both ways, with the path variable both $true and $false.

Here is the code I have added to my ServerConfig Configuration.

        Environment DSCTestEnvironment
        {
            Name = "DSCTest"
            Ensure = "Present"
            Path = "$True"
            Value = "C:\Scripts"

        }

        Environment DSCTestEnvironment2
        {
            Name = "DSCTest2"
            Ensure = "Present"
            Path = "$False"
            Value = "C:\Scripts"

        }

So, if this does what I want it to, it should add C:\Scripts to the $path variable on DSCTest as well as add an environmental variable for C:\Scripts.  Here is what I have currently for my $env:Path variable.

PS C:\Windows\system32> $env:Path
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\

I Invoke the Configuration and go to run the Scheduled Task to force a Pull and once again it’s running.  And has been since Friday night basically.  Awesome.  Is anyone else seeing this kind of behavior from the Scheduled Task?

Anyways, after the reboot the DSCRestartBootTask completed successfully.  However, the $env:path variable doesn’t have C:\Scripts listed.  However, this did happen.

Well, that’s not what was supposed to happen.  Seems pretty clear.  “Set this property to $true if the variable is the Path variable; otherwise, set it to $false. If the variable being configured is the Path variable, the value provided through the Value property will be appended to the existing value.”  Lies!  Let’s try using the Program Files directory and see if that works.  And yes, the C:\Scripts does exist, my Configuration script ensures that :).

        Environment DSCTestEnvironment
        {
            Name = "DSCTest"
            Ensure = "Present"
            Path = "$True"
            Value = "C:\Program Files"

        }

No dice.  It did this instead, since I didn’t delete the Environmental Variables I created previously, which is good to know.

dsc23

Alright, that didn’t work.  So.  Uh.  I guess let’s just try it without the Ensure value.  Which shouldn’t matter at all, but let’s try it anyways.  I change my code to this, and try it again.

        Environment DSCTestEnvironment
        {
            Name = "DSCNewTest"
            Path = "$True"
            Value = "C:\Program Files"
	}

And not surprisingly it just added it to the System Variables list.  I am going to try something really wacky before I head to Google to see what is out there about this.

        Environment DSCTestEnvironment
        {
            Name = "C:\Program Files"
            Path = "$True"

        }

Nope, it just created a System Variable with that name.  Let’s go to the logs!  Here is the relevant information below.  There doesn’t appear to be any errors.

oma-dsctest-01 VERBOSE      3/24/2014 1:38:37 PM  [OMA-DSCTEST-01]: LCM:  [ Start  Test     ]  [[Environment]DSCTestEnvironment]                                                               
oma-dsctest-01 VERBOSE      3/24/2014 1:38:37 PM  [OMA-DSCTEST-01]: LCM:  [ Start  Resource ]  [[Environment]DSCTestEnvironment]                                                               
oma-dsctest-01 DEBUG        3/24/2014 1:38:37 PM  Method Exec_PSProvider started with parameters ...                                                                                           
oma-dsctest-01 DEBUG        3/24/2014 1:38:37 PM  Moving the resource [Environment]DSCTestEnvironment of class MSFT_EnvironmentResource to desired state.                                      
oma-dsctest-01 DEBUG        3/24/2014 1:38:37 PM  Getting a registration instance for MSFT_EnvironmentResource                                                                                 
oma-dsctest-01 ANALYTIC     3/24/2014 1:38:37 PM  Executing operations for PS Provider MSFT_EnvironmentResource with resource name [Environment]DSCTestEnvironment                             
oma-dsctest-01 DEBUG        3/24/2014 1:38:37 PM  Method ExecuteProviderCommand started.                                                                                                       
oma-dsctest-01 DEBUG        3/24/2014 1:38:37 PM  Method ExecuteProviderCommand started.                                                                                                       
oma-dsctest-01 DEBUG        3/24/2014 1:38:37 PM  Getting a registration instance for MSFT_EnvironmentResource                                                                                 
oma-dsctest-01 VERBOSE      3/24/2014 1:38:37 PM  [OMA-DSCTEST-01]: LCM:  [ End    Test     ]  [[Environment]DSCTestEnvironment]  in 0.0160 seconds.                                           
oma-dsctest-01 VERBOSE      3/24/2014 1:38:37 PM  [OMA-DSCTEST-01]: LCM:  [ Skip   Set      ]  [[Environment]DSCTestEnvironment]                                                               
oma-dsctest-01 VERBOSE      3/24/2014 1:38:37 PM  [OMA-DSCTEST-01]: LCM:  [ End    Resource ]  [[Environment]DSCTestEnvironment]                                                               
oma-dsctest-01 VERBOSE      3/24/2014 1:38:37 PM  [OMA-DSCTEST-01]: LCM:  [ Start  Resource ]  [[Environment]DSCTestEnvironment2]                                                              
oma-dsctest-01 ANALYTIC     3/24/2014 1:38:37 PM  Executing operations for PS Provider MSFT_EnvironmentResource with resource name [Environment]DSCTestEnvironment2                            
oma-dsctest-01 DEBUG        3/24/2014 1:38:37 PM  Method Exec_PSProvider started with parameters ...                                                                                           
oma-dsctest-01 DEBUG        3/24/2014 1:38:37 PM  Moving the resource [Environment]DSCTestEnvironment2 of class MSFT_EnvironmentResource to desired state.                                     
oma-dsctest-01 VERBOSE      3/24/2014 1:38:37 PM  [OMA-DSCTEST-01]:                            [[Environment]DSCTestEnvironment] (FOUND) Environment variable 'C:\Program Files' with value '' 
oma-dsctest-01 VERBOSE      3/24/2014 1:38:37 PM  [OMA-DSCTEST-01]: LCM:  [ Start  Test     ]  [[Environment]DSCTestEnvironment2]                                                              
oma-dsctest-01 DEBUG        3/24/2014 1:38:37 PM  Moving the resource [Log]ScriptFolder of class MSFT_LogResource to desired state.                                                            
oma-dsctest-01 VERBOSE      3/24/2014 1:38:37 PM  [OMA-DSCTEST-01]: LCM:  [ End    Test     ]  [[Environment]DSCTestEnvironment2]  in 0.0150 seconds.                                          
oma-dsctest-01 VERBOSE      3/24/2014 1:38:37 PM  [OMA-DSCTEST-01]: LCM:  [ Skip   Set      ]  [[Environment]DSCTestEnvironment2]                                                              
oma-dsctest-01 VERBOSE      3/24/2014 1:38:37 PM  [OMA-DSCTEST-01]: LCM:  [ End    Resource ]  [[Environment]DSCTestEnvironment2]                                                              
oma-dsctest-01 VERBOSE      3/24/2014 1:38:37 PM  [OMA-DSCTEST-01]: LCM:  [ Start  Resource ]  [[File]ScriptFolder]                                                                            
oma-dsctest-01 VERBOSE      3/24/2014 1:38:37 PM  [OMA-DSCTEST-01]:                            [[Environment]DSCTestEnvironment2] (FOUND) Environment variable 'DSCTest2' with value 'C:\Scr...

Then, I have an idea.  An idea that makes me feel dumb, but I do it and share it with you anyways.

        Environment DSCTestEnvironment
        {
            Name = "DSCNewTest"
            Path = $True
            Value = "C:\Program Files"

        }

Nope, not even that did the trick.  I thought for sure that removing the $True from within double quotes would do the trick.  That maybe since DSC couldn’t recognize the bool value inside of quotes it was just defaulting to $False.  I add the Ensure = “Present” line to the code and try that.  Nope.  Still just adds a new environmental variable.

At this point I am completely out of ideas, and Google is no help on this issue at all.  I am probably doing something wrong but I have no idea what it is.  Any suggestions are more than welcome 🙂 .  Looks like the Archive resource is going to have to wait until tomorrow.

PowerShell Desired State Configuration (DSC) Journey – Day 12

Today I am going to do some work with the Log Resource.  The TechNet Article for Resource is pretty straightforward.  I have been thinking about how I would use this for a day now, and I really haven’t come up with anything useful because as I covered here the DSC Diagnostics Module provides some really good logging.  I feel like this is a Resource that was built for the future (and maybe it works better for Custom Resources??) than for using the out of box ones.  Nevertheless, let’s do some logging!

First thing to note is that the Log Message will appear in the Microsoft-Windows-Desired State Configuration/Analytic Event Log.  There are only 2 Properties, Message and Depends on.  Pretty straightforward.  Let’s add a couple of Logs to the Configuration I have been using and see what happens.  Here are the lines that I added.

        Log ScriptFolder
        {
            Message = "Script Folder has been created at C:\Scripts on Computer $ComputerName"
            DependsOn = "[File]ScriptFolder"

        }

        Log DNSAddress
        {
            Message = "$DNSServerAddress has been set on $ComputerName"
            DependsOn = "[cDNSServerAddress]SetDNSAddress"            
        }

        Log Success
        {
            Message = "$ComputerName has successfully pulled its Configuration"
        }

I intentionally used Parameter names in the Message blocks to see if it actually uses them.  It looks like it should work in the ISE Editor, so lets find out.  I Invoke the Configuration, send it to the Pull Server, and force DSCTest to pull its Configuration.

While doing this, I noticed that for the second day in a row the Consistency scheduled task on DSCTest had been running non stop since 2:38AM this morning.  Yesterday I rebooted the server and it fixed the problem.  Today I ended the task and set it to kill itself if it ran for more than an hour.  It was set to 3 days by default, which I don’t agree with at all.  I start the scheduled task again and it just runs and never does anything.  Typically it runs for about 15 seconds and then it’s done.  It’s scheduled to run on it’s own in 3 minutes so I will just wait for that and see what happens.  It started, but then it doesn’t stop.  It had been running for a good 5 minutes now before I end it.

I also tried doing it the way Don Jones suggested in the comments to this post.

$params = @{
Namespace = ‘root/Microsoft/Windows/DesiredStateConfiguration’
ClassName = ‘MSFT_DSCLocalConfigurationManager’
MethodName = ‘PerformRequiredConfigurationChecks’
Arguments = @{
 Flags = [uint32] 1
 }
 }

Invoke-CimMethod @params

And I just got this error message for my trouble.

Invoke-CimMethod : Access denied 
At line:10 char:1
+ Invoke-CimMethod @params
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (root/Microsoft/...gurationManager:String) [Invoke-CimMethod], CimException
    + FullyQualifiedErrorId : HRESULT 0x80041003,Microsoft.Management.Infrastructure.CimCmdlets.InvokeCimMethodCommand

Which doesn’t make any sense because I am using PowerShell as a Domain Admin and I have rights to do everything else I have ever needed to do.  Time for the magical reboot server trick!

After the reboot the DSCRestartBootTask ran successfully and I was able to get this information.

PS C:\Scripts> Get-cDscOperation -ComputerName oma-dsctest-01 -Newest 5

ComputerName   SequenceId TimeCreated           Result   JobID                                 AllEvents            
------------   ---------- -----------           ------   -----                                 ---------            
oma-dsctest-01 1          3/20/2014 2:49:07 PM  Failure  c2c247c1-0e7b-4ba7-941b-f9535394402a  {@{Message=Reading...
oma-dsctest-01 2          3/20/2014 2:04:37 AM  Success  556363a9-5b01-4c39-9a90-19d26d9d6513  {@{Message=Configu...
oma-dsctest-01 3          3/20/2014 1:51:10 AM  Failure  361bd089-957f-4c8e-9d81-a1a50e4bf92e  {@{Message=Configu...
oma-dsctest-01 4          3/20/2014 12:51:15 AM Failure  cf32b0f8-efb2-4f6e-b59b-6845eaba09ab  {@{Message=Configu...
oma-dsctest-01 5          3/19/2014 11:35:49 PM Failure  4f516a92-81b7-4a06-917b-47d4d8aecaf2  {@{Message=Configu...

Which is interesting.  So then let’s do this.  I have shortened the output to show the interesting parts.

PS C:\Scripts> Trace-cDscOperation -ComputerName oma-dsctest-01 -SequenceID 1 | Select-Object 
Setting resources in order. Number of resources: 9
Getting a registration instance for MSFT_FileDirectoryConfiguration
Moving the resource [File]ScriptFolder of class MSFT_FileDirectoryConfiguration to desired state.
Method Exec_WMIv2Provider started with parameters 
 	 Class name: MSFT_FileDirectoryConfiguration 
 	 Resource ID: [File]ScriptFolder 
 	 Flags: 0 
 	 Execution Mode: 192 
 	 Provider Namespace: NULL 
Validating Schema of class PSHOrg_cDNSServerAddress which is class index 0 in an array of classes of size 1
Method SendConfigurationApply started with parameters 
 	 Class name: OMI_ConfigurationDocument 
 	 Resource ID:  
 	 Flags: 0 
 	 Execution Mode: 192 
 	 Provider Namespace: NULL 
Reading the file content from C:\Program Files\WindowsPowerShell\Modules\cNetworking\DscResources\PSHOrg_cIPAddress\PSHOrg_cIPAddress.schema.mof
Parsing the configuration to apply.
Executing operations for WMIv2 Provider MSFT_FileDirectoryConfiguration with resource name [File]ScriptFolder
Invoking session and getting result for namespace root/microsoft/windows/DesiredStateConfiguration, classname MSFT_FileDirectoryConfiguration for method TestTargetResource
Method Exec_PSProvider ended successfully
Method Exec_WMIv2Provider started with parameters 
 	 Class name: MSFT_FileDirectoryConfiguration 
 	 Resource ID: [File]BGInfo 
 	 Flags: 0 
 	 Execution Mode: 192 
 	 Provider Namespace: NULL 
Moving the resource [File]BGInfo of class MSFT_FileDirectoryConfiguration to desired state.
Getting a registration instance for MSFT_FileDirectoryConfiguration
Method Exec_PSProvider started with parameters 
 	 Class name: MSFT_LogResource 
 	 Resource ID: [Log]ScriptFolder 
 	 Flags: 0 
 	 Execution Mode: 192 
 	 Provider Namespace: NULL 
Moving the resource [Log]ScriptFolder of class MSFT_LogResource to desired state.
Getting a registration instance for MSFT_LogResource
Executing operations for WMIv2 Provider MSFT_FileDirectoryConfiguration with resource name [File]BGInfo
Invoking session and getting result for namespace root/microsoft/windows/DesiredStateConfiguration, classname MSFT_FileDirectoryConfiguration for method TestTargetResource
Executing operations for PS Provider MSFT_LogResource with resource name [Log]ScriptFolder
Method ExecuteProviderCommand started.
Method Exec_PSProvider started with parameters 
 	 Class name: MSFT_PackageResource 
 	 Resource ID: [Package]BGInfoInstall 
 	 Flags: 0 
 	 Execution Mode: 192 
 	 Provider Namespace: NULL 
Executing operations for PS Provider MSFT_PackageResource with resource name [Package]BGInfoInstall
Moving the resource [Package]BGInfoInstall of class MSFT_PackageResource to desired state.
Getting a registration instance for MSFT_PackageResource
Method ExecuteProviderCommand started.
Getting a registration instance for PSHOrg_cDNSServerAddress
Method Exec_PSProvider ended successfully
Method Exec_PSProvider started with parameters 
 	 Class name: PSHOrg_cDNSServerAddress 
 	 Resource ID: [cDNSServerAddress]SetDNSAddress 
 	 Flags: 0 
 	 Execution Mode: 192 
 	 Provider Namespace: NULL 
Executing operations for PS Provider PSHOrg_cDNSServerAddress with resource name [cDNSServerAddress]SetDNSAddress
Method ExecuteProviderCommand started.
Moving the resource [cDNSServerAddress]SetDNSAddress of class PSHOrg_cDNSServerAddress to desired state.
This event indicates that failure happens when LCM is processing the configuration. ErrorId is 0x1. ErrorDetail is The SendConfigurationApply function did not succeed.. ResourceId is [Package
]BGInfoInstall and SourceInfo is C:\Users\jacob.benson\SkyDrive\PowerShell\DSC\ServerConfig.ps1::55::9::Package. ErrorMessage is PowerShell provider MSFT_PackageResource  failed to execute Se
t-TargetResource functionality with error message: Package from C:\Scripts\BGInfo\Install.cmd was installed, but the specified ProductId and/or Name does not match package details .
Getting a registration instance for PSHOrg_cIPAddress
Moving the resource [cIPAddress]SetIPAddress of class PSHOrg_cIPAddress to desired state.
Method ExecuteProviderCommand started.
Method Exec_PSProvider started with parameters 
 	 Class name: PSHOrg_cIPAddress 
 	 Resource ID: [cIPAddress]SetIPAddress 
 	 Flags: 0 
 	 Execution Mode: 192 
 	 Provider Namespace: NULL 
Executing operations for PS Provider PSHOrg_cIPAddress with resource name [cIPAddress]SetIPAddress
Moving the resource [Log]Success of class MSFT_LogResource to desired state.
Method Exec_PSProvider ended successfully
Method Exec_PSProvider ended successfully
Method Exec_PSProvider started with parameters 
 	 Class name: MSFT_LogResource 
 	 Resource ID: [Log]Success 
 	 Flags: 0 
 	 Execution Mode: 192 
 	 Provider Namespace: NULL 
Getting a registration instance for MSFT_LogResource
Method Exec_PSProvider started with parameters 
 	 Class name: MSFT_LogResource 
 	 Resource ID: [Log]DNSAddress 
 	 Flags: 0 
 	 Execution Mode: 192 
 	 Provider Namespace: NULL 
This event indicates that failure happens when LCM is trying to get the configuration from pull server using download manager WebDownloadManager. ErrorId is 0x1. ErrorDetail is The SendConfig
urationApply function did not succeed.
Getting a registration instance for MSFT_LogResource
Deleting file from C:\Windows\System32\Configuration\Pending.mof
Executing operations for PS Provider MSFT_LogResource with resource name [Log]Success
Executing operations for PS Provider MSFT_LogResource with resource name [Log]DNSAddress
DSC Engine Error : 
	 Error Message The SendConfigurationApply function did not succeed. 
	Error Code : 1 
Moving the resource [Log]DNSAddress of class MSFT_LogResource to desired state.
Saving configuration instance into C:\Windows\System32\Configuration\DSCEngineCache.mof.
Method MSFT_DSCLocalConfigurationManager_Invoke_PerformRequiredConfigurationChecks ended successfully

It appears to be failing because of this.

This event indicates that failure happens when LCM is processing the configuration. ErrorId is 0x1. ErrorDetail is The SendConfigurationApply function did not succeed.. ResourceId is [Package
]BGInfoInstall and SourceInfo is C:\Users\jacob.benson\SkyDrive\PowerShell\DSC\ServerConfig.ps1::55::9::Package. ErrorMessage is PowerShell provider MSFT_PackageResource  failed to execute Se
t-TargetResource functionality with error message: Package from C:\Scripts\BGInfo\Install.cmd was installed, but the specified ProductId and/or Name does not match package details .

I never checked back yesterday after BGInfo got installed but it clearly doesn’t like the fact that it can’t verify the ProductID.  So, let’s try something here.  Also I should note at this point that none of my messages got logged because the Configuration failed.

I set the BGInfoInstall Package Resources to Absent and try again. No dice.  Same errors.  Well.  Crap.  Clearly I will need to do some playing around with this.  For the sake of testing the Log Resource I remove those entries from my Configuration and try it again.  And it works.  Let’s check out the log file.

There are a lot of entries like the one below, but none with my actual message.  So let me try changing one to not include a parameter name.

Job {A4F3E2CA-6FCA-4517-9C39-FA65B711A5C4} : 
Executing operations for PS Provider MSFT_LogResource with resource name [Log]Success

The Trace of the DSCOperation has entries like this, but again, none with my message in them.

Executing operations for PS Provider MSFT_LogResource with resource name [Log]DNSAddress
Executing operations for PS Provider MSFT_LogResource with resource name [Log]Success

I changed my Log Success to this, and then Invoked the Configuration again.

        Log Success
        {
            Message = "THE CONFIGURATION LOGGING WORKED!"
        }

In doing this, I must have been blind previously because it did log what I had in there.  Here are some examples of what it looks like.

Event ID 4162
Job {549B3F2C-DBDC-4472-A829-0E236A4FD3EE} : 
Executing operations for PS Provider MSFT_LogResource with resource name [Log]DNSAddress

Event ID 4100
Job {549B3F2C-DBDC-4472-A829-0E236A4FD3EE} : 
Displaying messages from the engine:
	 WMI channel 1 
	 ResourceID: [Log]DNSAddress 
	 Message : [OMA-DSCTEST-01]: LCM:  [ End    Test     ]  [[Log]DNSAddress]  in 0.0000 seconds.

Event ID 4098
Job {549B3F2C-DBDC-4472-A829-0E236A4FD3EE} : 
Displaying messages from built-in providers:
	 WMI channel 1 
	 ResourceID: [Log]DNSAddress 
	 Message : [OMA-DSCTEST-01]:                            [[Log]DNSAddress] 192.168.168.252 192.168.168.253 192.168.168.254 has been set on OMA-DSCTEST-01.DOMAIN.COM

Event ID 4100
Job {549B3F2C-DBDC-4472-A829-0E236A4FD3EE} : 
Displaying messages from the engine:
	 WMI channel 1 
	 ResourceID: [Log]DNSAddress 
	 Message : [OMA-DSCTEST-01]: LCM:  [ Start  Set      ]  [[Log]DNSAddress]

Event ID 4098
Job {549B3F2C-DBDC-4472-A829-0E236A4FD3EE} : 
Displaying messages from built-in providers:
	 WMI channel 1 
	 ResourceID: [Log]Success 
	 Message : [OMA-DSCTEST-01]:                            [[Log]Success] OMA-DSCTEST-01.DOMAIN.COM has successfully pulled its Configuration

That’s all I have time for today , but I am seeing a lot of inconsistencies in the logging.  I ran the exact Configuration again, and the only thing it logged was the Log ScriptFolder Resource, there were no entries for Log Success or Log DNSServerAddress.

 

PowerShell Desired State Configuration (DSC) Journey – Day 11

Yesterday I worked with the File Resource to ensure that the path C:\Scripts existed and that my BGInfo files were inside of it.  Today I am going to attempt to use the Package resource to run the BGInfo Files.

First thing I need to do is find out what the settings for the Package Resource are.

Get-DscResource -Name Package | Select-Object -ExpandProperty Properties

There are 3 mandatory settings, Name, Path, and ProductID.  I did some digging around for information on what the ProductID requires in a situation like this, and didn’t find much.  So I am just going to make one up and see what happens.

Here is the code I added to my Configuration script.

        Package BGInfoInstall
        {
            Ensure = "Present"
            DependsOn = "[File]BGInfo"
            Name = "BGInfoInstall"
            Path = "$env:SystemDrive\Scripts\BGInfo\Install.cmd"
            ProductID = "NFM123"

        }

        Package BGInfoInstall2
        {
            Ensure = "Present"
            DependsOn = "[Package]BGInfoInstall"
            Name = "BGInfoInstall2"
            Path = "$env:SystemDrive\Scripts\BGInfo\BGInfo.bat"
            ProductID = "NFM456"

I have the server Pull this configuration and it fails.  I am not going to show the entire thing here, but this is the relevant part.

This event indicates that failure happens when LCM is processing the configuration. ErrorId is 0x1. ErrorDetail is The SendConfigurationApply function did not succeed.. ResourceId is [Package
]BGInfoInstall and SourceInfo is C:\Users\jacob.benson\SkyDrive\PowerShell\DSC\ServerConfig.ps1::48::9::Package. ErrorMessage is PowerShell provider MSFT_PackageResource  failed to execute Te
st-TargetResource functionality with error message: The specified IdentifyingNumber (NFM123) is not a valid Guid
Parameter name: NFM123 .

So like I suspected it clearly does not enjoy my ProductID, but doesn’t tell me how long it needs to be or what the format should be (although I strongly suspect I know what they should be).

The example on the TechNet page for this resource as ACDDCDAF-80C6-41E6-A1B9-8ABD8A05027E so I will just use that format but modify it in the Configuration to see if that works.

I am going to try this for the ProductID and see how it works.  NFM12345-1234-NFMN-1234-OMA123NE1234 and NFM12345-1234-NFMN-1234-OMA123NE5678.

Nope, no dice.  Same error.  This leads me down a Google rabbit hole involving MSIEXEC and ProductID searches.  Then it dawns on me that there truly is no ProductID, so what if I just use “” for the Product ID?

Boom!  Both files work and BGInfo is installed.  The proper directory in Program Files is created, the proper file is moved into the Startup folder and the BGInfo is showing on the desktop.

Here is the final version of the code.

Package BGInfoInstall
 {
 Ensure = "Present"
 DependsOn = "[File]BGInfo"
 Name = "BGInfoInstall"
 Path = "$env:SystemDrive\Scripts\BGInfo\Install.cmd"
 ProductID = ""

}

Package BGInfoInstall2
 {
 Ensure = "Present"
 DependsOn = "[Package]BGInfoInstall"
 Name = "BGInfoInstall2"
 Path = "$env:SystemDrive\Scripts\BGInfo\BGInfo.bat"
 ProductID = ""
 }

Looking at the list of built-in DSC Resources I haven’t touched yet, I think I am going to go with learning the Log Resource tomorrow.

PowerShell Desired State Configuration (DSC) Journey – Day 10

Yesterday I talked about troubleshooting what was wrong with DSCTest server being unable to pull the module file from the Pull Server.  After a couple of breaks and some reading I figured it out (the answer is at the end of the article), and everything is working great.

Today, I am going to back to the File resource that I started with originally.  As part of our server builds we put BGInfo on all the servers, and we have a .bat file that runs that configures the way we want it.  So I am going to add to my Server Config Configuration (with an eye towards using this is as a composite resource not too far down the line) to copy these files, and then use the Package resource to install it.  Hopefully.  One other thing that I should mention is that I went ahead and downloaded all of the community DSC resources from here and going forward will be using them instead of the Microsoft provided ones.

First, I need to do two things. I want to ensure that the C:\Scripts folder always exists.  Once I know that exists, I want to copy the BGInfo folder and files into that location.  Here is the code that I added into my Configuration to do this.

        File ScriptFolder
        {
            Ensure = "Present"
            Type = "Directory"
            DestinationPath = "C:\Scripts\"

        }

Nothing fancy there.  Now to test this, I need to make sure I use the same GUID that I used before when I told DSCTest which configuration to look to pull from the Pull Server.  To get this I just browse to \\PullServer\C$\Program Files\WindowsPowerShell\DSCService\Configuration, get the GUID and set $guid = GUID in PowerShell.  I Invoke the Configuration to generate the .MOF file.  I then push that .MOF file out to the PullServer.  Since it has the same GUID as before, and DSCTest knows to look for that GUID, it should automatically pick it up.  I verified it’s the right GUID by entering into a PSSession on DSCTest and running Get-DSCLocalConfigurationManager.  The ConfigurationID should match the GUID, and mine does.

And this doesn’t work.  It pulls the Configuration fine, but it says that DSCTest is in compliance and everything is fine.  I went through a lot of troubleshooting steps, double and triple checking things before I figured out what the problem was.  It’s wonderful and all that you keep the GUID the same, but if you don’t generate a new checksum it won’t matter.  Lesson learned.  Once I did that it created the file.

Now that I have ensured my Scripts folder will be present, I need to copy my BGInfo folder and files into it.  To do that I have the code below.

        File BGInfo
        {
            Ensure = "Present"
            Type = "Directory"
            Recurse = "True"
            SourcePath = "\\servername\utilities\bginfo"
            DestinationPath = "C:\Scripts\BGInfo"
            DependsOn = "[File]ScriptFolder"

        }

I Invoke the Configuration, Copy the file to the PullServer, GENERATE A NEW CHECKSUM(!!!) and run the scheduled task on DSCTest.  BAM!

dsc21

 

Lesson(s) Learned:  Even if the GUI is the same, if you update the Configuration and generate a new .MOF you need to generate a new Checksum. This can be done by using the command New-DSCChecksum -Force -Destination $dest.

Tomorrow:  I try to use the Package resource to install BGInfo.

If you are curious here is the full log of the implementation of the Configuration.  Warning.  This is long.

Reading the file content from C:\Windows\System32\Configuration\BaseRegistration\BaseResource.schema.mof
Validating provider registration against schema 
	 Number of classes: 9 
	 Number of Registrations: 1 
Validating DSC Provider registration instance for class : MSFT_CimConfigurationProviderRegistration
Reading the file content from C:\Windows\System32\Configuration\Registration\MSFT_FileDirectoryConfiguration\MSFT_FileDirectoryConfiguration.Registration.mof
Validating Schema of class MSFT_FileDirectoryConfiguration which is class index 0 in an array of classes of size 1
Validating DSC Provider schema against a class array of size 1
Reading the file content from C:\Windows\System32\Configuration\Schema\MSFT_FileDirectoryConfiguration\MSFT_FileDirectoryConfiguration.Schema.mof
Validating Schema of class MSFT_DSCMetaConfiguration which is class index 0 in an array of classes of size 1
Validating DSC Provider schema against a class array of size 1
Reading the file content from C:\Windows\System32\Configuration\BaseRegistration\MSFT_DSCMetaConfiguration.mof
Validating Class property Password for class MSFT_Credential
Validating Class property UserName for class MSFT_Credential
Validating Class property GenerationHost for class OMI_ConfigurationDocument
Validating Class property GenerationDate for class OMI_ConfigurationDocument
Validating Class property HelpInfoUri for class OMI_ConfigurationDocument
Validating Class property ContentType for class OMI_ConfigurationDocument
Validating Class property Author for class OMI_ConfigurationDocument
Validating Class property ResourceId for class OMI_BaseResource
Validating Class property SourceInfo for class OMI_BaseResource
Validating Class property DependsOn for class OMI_BaseResource
Validating Class property ModuleName for class OMI_BaseResource
Validating Class property ModuleVersion for class OMI_BaseResource
Validating Class property Copyright for class OMI_ConfigurationDocument
Validating Class property Value for class MSFT_KeyValuePair
Validating Class property Key for class MSFT_KeyValuePair
Validating Class property DSCEngineCompatVersion for class MSFT_BaseConfigurationProviderRegistration
Validating Class property DSCModuleVersion for class MSFT_BaseConfigurationProviderRegistration
Validating Class property Namespace for class MSFT_CimConfigurationProviderRegistration
Validating Class property ModuleName for class MSFT_PSConfigurationProviderRegistration
Validating Class property Version for class OMI_ConfigurationDocument
Validating Class property ClassName for class MSFT_BaseConfigurationProviderRegistration
Validating infrastructure schema
Validating Class property SourceInfo for class OMI_BaseResource
Reading the file content from C:\Windows\System32\Configuration\BaseRegistration\BaseResource.schema.mof
Validating infrastructure schema
Validating Class property ResourceId for class OMI_BaseResource
Validating Class property DependsOn for class OMI_BaseResource
Validating Class property ModuleVersion for class OMI_BaseResource
Validating Class property ConfigurationModeFrequencyMins for class MSFT_DSCMetaConfiguration
Validating Class property RebootNodeIfNeeded for class MSFT_DSCMetaConfiguration
Validating Class property Credential for class MSFT_DSCMetaConfiguration
Validating Class property ConfigurationMode for class MSFT_DSCMetaConfiguration
Validating Class property RefreshMode for class MSFT_DSCMetaConfiguration
Validating Class property CertificateID for class MSFT_DSCMetaConfiguration
Validating infrastructure schema
Validating Class property ConfigurationID for class MSFT_DSCMetaConfiguration
Validating Class property AllowModuleOverwrite for class MSFT_DSCMetaConfiguration
Reading the file content from C:\Windows\System32\Configuration\MetaConfig.mof
Reading the file content from C:\Windows\System32\Configuration\DSCEngineCache.mof
Getting Metaconfiguration details.
Getting Metaconfiguration details.
Reading the file content from C:\Windows\System32\Configuration\Current.mof.checksum
Validating Class property DownloadManagerCustomData for class MSFT_DSCMetaConfiguration
Validating Class property ModuleName for class OMI_BaseResource
Reading the file content from C:\Windows\System32\Configuration\BaseRegistration\MSFT_DSCMetaConfiguration.mof
Validating Class property UserName for class MSFT_Credential
Validating Class property Key for class MSFT_KeyValuePair
Validating Class property Value for class MSFT_KeyValuePair
Validating Class property ClassName for class MSFT_BaseConfigurationProviderRegistration
Validating Class property DSCEngineCompatVersion for class MSFT_BaseConfigurationProviderRegistration
Validating Class property DSCModuleVersion for class MSFT_BaseConfigurationProviderRegistration
Validating Class property Namespace for class MSFT_CimConfigurationProviderRegistration
Validating Class property Password for class MSFT_Credential
Validating Class property ModuleName for class MSFT_PSConfigurationProviderRegistration
Validating Class property Author for class OMI_ConfigurationDocument
Validating Class property Copyright for class OMI_ConfigurationDocument
Validating Class property HelpInfoUri for class OMI_ConfigurationDocument
Validating Class property ContentType for class OMI_ConfigurationDocument
Validating Class property GenerationDate for class OMI_ConfigurationDocument
Validating Class property GenerationHost for class OMI_ConfigurationDocument
Validating Class property Version for class OMI_ConfigurationDocument
Validating Class property RefreshFrequencyMins for class MSFT_DSCMetaConfiguration
Validating Class property DownloadManagerName for class MSFT_DSCMetaConfiguration
Configuration is sent from computer NULL by user sid S-1-5-18.
Attempting to get the action from pull server using Download Manager WebDownloadManager. Configuration Id is a0a95372-66de-4937-896d-ac3489ab05d0. Checksum is 204D0ACA80DE79997DD28597D23ABE8C
A0859629836BBAF991AC1572306E43D8. Compliance status is true.
WebDownloadManager for configuration a0a95372-66de-4937-896d-ac3489ab05d0 Do-DscAction command with server url: http://mdc-psweb-01.nfm.com:8080/PSDSCPullServer.svc.
WebDownloadManager for configuration a0a95372-66de-4937-896d-ac3489ab05d0 Do-DscAction command, GET Url: PSDSCPullServer.svc/Action(ConfigurationId='a0a95372-66de-4937-896d-ac3489ab05d0')/Get
Action.
WebDownloadManager for configuration a0a95372-66de-4937-896d-ac3489ab05d0 Do-DscAction command, GET call result: GetConfiguration.
Successfully got the action GetConfiguration from pull server using Download Manager WebDownloadManager.
Attempting to get the configuration from pull server using Download Manager WebDownloadManager.Configuration Id is a0a95372-66de-4937-896d-ac3489ab05d0.
Attempting to get the configuration a0a95372-66de-4937-896d-ac3489ab05d0 from pull server with Server Url http://mdc-psweb-01.nfm.com:8080/PSDSCPullServer.svc using Web Download Manager.
WebDownloadManager for configuration a0a95372-66de-4937-896d-ac3489ab05d0 Get-DscDocument command, GET Url: PSDSCPullServer.svc/Action(ConfigurationId='a0a95372-66de-4937-896d-ac3489ab05d0')/
ConfigurationContent.
WebDownloadManager for configuration a0a95372-66de-4937-896d-ac3489ab05d0 Get-DscDocument command, File save result: C:\Windows\TEMP\635307563386177231\localhost.mof.
The checksum validation for configuration a0a95372-66de-4937-896d-ac3489ab05d0 completed with status code 0.
The checksum validation for configuration C:\Windows\TEMP\\635307563386177231\localhost.mof completed with status code 0.
WebDownloadManager for configuration a0a95372-66de-4937-896d-ac3489ab05d0 Get-DscDocument command, File save result: C:\Windows\TEMP\635307563386177231\localhost.mof.checksum.
WebDownloadManager for configuration a0a95372-66de-4937-896d-ac3489ab05d0 Get-DscDocument command, GET call result: Ok.
Skipping pulling module PSDesiredStateConfiguration with version 1.0 as it already exists in this location C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDes
iredStateConfiguration.psd1.
Validating Class property ModuleName for class OMI_BaseResource
Skipping pulling module cNetworking with version 2.0 as it already exists in this location C:\Program Files\WindowsPowerShell\Modules\cNetworking\cNetworking.psd1.
Skipping pulling of modules since all modules specified in configuration C:\Windows\TEMP\\635307563386177231\localhost.mof are available.
Successfully got the configuration from pull server using Download Manager WebDownloadManager.
Module manager is loading instance document from location C:\Windows\System32\Configuration\Pending.mof
Reading the file content from C:\Windows\System32\Configuration\BaseRegistration\BaseResource.schema.mof
Validating infrastructure schema
Validating Class property ResourceId for class OMI_BaseResource
Validating Class property SourceInfo for class OMI_BaseResource
Validating Class property DependsOn for class OMI_BaseResource
Validating Class property ModuleVersion for class OMI_BaseResource
Validating Class property Value for class MSFT_KeyValuePair
Validating provider registration against schema 
	 Number of classes: 9 
	 Number of Registrations: 1 
Validating DSC Provider registration instance for class : MSFT_CimConfigurationProviderRegistration
Reading the file content from C:\Windows\System32\Configuration\Registration\MSFT_FileDirectoryConfiguration\MSFT_FileDirectoryConfiguration.Registration.mof
Validating Schema of class MSFT_FileDirectoryConfiguration which is class index 0 in an array of classes of size 1
Reading the file content from C:\Windows\System32\Configuration\Schema\MSFT_FileDirectoryConfiguration\MSFT_FileDirectoryConfiguration.Schema.mof
Validating Schema of class MSFT_DSCMetaConfiguration which is class index 0 in an array of classes of size 1
Validating DSC Provider schema against a class array of size 1
Reading the file content from C:\Windows\System32\Configuration\BaseRegistration\MSFT_DSCMetaConfiguration.mof
Validating Class property Password for class MSFT_Credential
Validating Class property UserName for class MSFT_Credential
Validating Class property GenerationHost for class OMI_ConfigurationDocument
Validating Class property ContentType for class OMI_ConfigurationDocument
Validating Class property HelpInfoUri for class OMI_ConfigurationDocument
Validating Class property Copyright for class OMI_ConfigurationDocument
Validating Class property Author for class OMI_ConfigurationDocument
Validating Class property Version for class OMI_ConfigurationDocument
Validating Class property ModuleName for class MSFT_PSConfigurationProviderRegistration
Validating Class property Namespace for class MSFT_CimConfigurationProviderRegistration
Validating Class property DSCModuleVersion for class MSFT_BaseConfigurationProviderRegistration
Validating Class property DSCEngineCompatVersion for class MSFT_BaseConfigurationProviderRegistration
Validating Class property ClassName for class MSFT_BaseConfigurationProviderRegistration
Validating Class property Key for class MSFT_KeyValuePair
Validating DSC Provider schema against a class array of size 1
Validating Class property GenerationDate for class OMI_ConfigurationDocument
Applying configuration from C:\Windows\System32\Configuration\Pending.mof.
Clear the cache of built-in providers.
Getting PS provider schema path and registration information
Reading the file content from C:\Windows\System32\Configuration\Pending.mof
Moving the resource [File]ScriptFolder of class MSFT_FileDirectoryConfiguration to desired state.
Resolving Dependencies inside the configuration document.
Method SendConfigurationApply started with parameters 
 	 Class name: OMI_ConfigurationDocument 
 	 Resource ID:  
 	 Flags: 0 
 	 Execution Mode: 192 
 	 Provider Namespace: NULL 
Validating instance document.
Method Exec_WMIv2Provider started with parameters 
 	 Class name: MSFT_FileDirectoryConfiguration 
 	 Resource ID: [File]ScriptFolder 
 	 Flags: 0 
 	 Execution Mode: 192 
 	 Provider Namespace: NULL 
Validating Schema of class PSHOrg_cDNSServerAddress which is class index 0 in an array of classes of size 1
Validating DSC Provider schema against a class array of size 1
Reading the file content from C:\Program Files\WindowsPowerShell\Modules\cNetworking\DscResources\PSHOrg_cDNSServerAddress\PSHOrg_cDNSServerAddress.schema.mof
Validating Schema of class PSHOrg_cIPAddress which is class index 0 in an array of classes of size 1
Validating DSC Provider schema against a class array of size 1
Reading the file content from C:\Program Files\WindowsPowerShell\Modules\cNetworking\DscResources\PSHOrg_cIPAddress\PSHOrg_cIPAddress.schema.mof
Getting a registration instance for MSFT_FileDirectoryConfiguration
Validating DSC Document instance with instance array size of 5 and flags 16
Setting resources in order. Number of resources: 4
Parsing the configuration to apply.
Invoking session and getting result for namespace root/microsoft/windows/DesiredStateConfiguration, classname MSFT_FileDirectoryConfiguration for method TestTargetResource
Executing operations for WMIv2 Provider MSFT_FileDirectoryConfiguration with resource name [File]ScriptFolder
Invoking session and getting result for namespace root/microsoft/windows/DesiredStateConfiguration, classname MSFT_FileDirectoryConfiguration for method SetTargetResource
Method Exec_WMIv2Provider ended successfully
Moving the resource [File]BGInfo of class MSFT_FileDirectoryConfiguration to desired state.
Method Exec_WMIv2Provider started with parameters 
 	 Class name: MSFT_FileDirectoryConfiguration 
 	 Resource ID: [File]BGInfo 
 	 Flags: 0 
 	 Execution Mode: 192 
 	 Provider Namespace: NULL 
Invoking session and getting result for namespace root/microsoft/windows/DesiredStateConfiguration, classname MSFT_FileDirectoryConfiguration for method TestTargetResource
Executing operations for WMIv2 Provider MSFT_FileDirectoryConfiguration with resource name [File]BGInfo
Getting a registration instance for MSFT_FileDirectoryConfiguration
Invoking session and getting result for namespace root/microsoft/windows/DesiredStateConfiguration, classname MSFT_FileDirectoryConfiguration for method SetTargetResource
Method Exec_WMIv2Provider ended successfully
Moving the resource [cDNSServerAddress]SetDNSAddress of class PSHOrg_cDNSServerAddress to desired state.
Method Exec_PSProvider started with parameters 
 	 Class name: PSHOrg_cDNSServerAddress 
 	 Resource ID: [cDNSServerAddress]SetDNSAddress 
 	 Flags: 0 
 	 Execution Mode: 192 
 	 Provider Namespace: NULL 
Getting a registration instance for PSHOrg_cDNSServerAddress
Executing operations for PS Provider PSHOrg_cDNSServerAddress with resource name [cDNSServerAddress]SetDNSAddress
Method ExecuteProviderCommand started.
Moving the resource [cIPAddress]SetIPAddress of class PSHOrg_cIPAddress to desired state.
Method Exec_PSProvider started with parameters 
 	 Class name: PSHOrg_cIPAddress 
 	 Resource ID: [cIPAddress]SetIPAddress 
 	 Flags: 0 
 	 Execution Mode: 192 
 	 Provider Namespace: NULL 
Executing operations for PS Provider PSHOrg_cIPAddress with resource name [cIPAddress]SetIPAddress
Getting a registration instance for PSHOrg_cIPAddress
Method ExecuteProviderCommand started.
Copying configuration file from Current.mof to Previous.mof.
Validating Class property ModuleName for class OMI_BaseResource
Validating Class property DependsOn for class OMI_BaseResource
Saving configuration instance into C:\Windows\System32\Configuration\DSCEngineCache.mof.
Saving configuration instance into C:\Windows\System32\Configuration\DSCEngineCache.mof.
Getting Metaconfiguration details.
Saving configuration instance into C:\Windows\System32\Configuration\PullRunLog.txt.
Saving configuration instance into C:\Windows\System32\Configuration\PullRunLog.txt.
Function CallConsistencyEngine started with parameters 
 	 DataSize: 0 
 	 Flags: 0 
 	 Execution Mode: 0 
Getting Metaconfiguration details.
Module manager is loading instance document from location C:\Windows\System32\Configuration\Current.mof
Reading the file content from C:\Windows\System32\Configuration\BaseRegistration\BaseResource.schema.mof
Validating infrastructure schema
Copying configuration file from Pending.mof to Current.mof.
Validating Class property ModuleVersion for class OMI_BaseResource
[OMA-DSCTEST-01]:                            [] Starting consistency engine.
[OMA-DSCTEST-01]:                            [] Checking consistency for current configuration.
Running consistency engine.
Validating provider registration against schema 
	 Number of classes: 9 
	 Number of Registrations: 1 
Validating DSC Provider registration instance for class : MSFT_CimConfigurationProviderRegistration
Reading the file content from C:\Windows\System32\Configuration\Registration\MSFT_FileDirectoryConfiguration\MSFT_FileDirectoryConfiguration.Registration.mof
Validating Schema of class MSFT_FileDirectoryConfiguration which is class index 0 in an array of classes of size 1
Validating DSC Provider schema against a class array of size 1
Reading the file content from C:\Windows\System32\Configuration\Schema\MSFT_FileDirectoryConfiguration\MSFT_FileDirectoryConfiguration.Schema.mof
Validating Schema of class MSFT_DSCMetaConfiguration which is class index 0 in an array of classes of size 1
Validating DSC Provider schema against a class array of size 1
Validating Class property ResourceId for class OMI_BaseResource
Validating Class property Password for class MSFT_Credential
Validating Class property UserName for class MSFT_Credential
Validating Class property GenerationHost for class OMI_ConfigurationDocument
Reading the file content from C:\Windows\System32\Configuration\BaseRegistration\MSFT_DSCMetaConfiguration.mof
Validating Class property ContentType for class OMI_ConfigurationDocument
Applying configuration from C:\Windows\System32\Configuration\Current.mof.
Validating Class property GenerationDate for class OMI_ConfigurationDocument
Validating Class property Value for class MSFT_KeyValuePair
Validating Class property ClassName for class MSFT_BaseConfigurationProviderRegistration
Validating Class property DSCEngineCompatVersion for class MSFT_BaseConfigurationProviderRegistration
Validating Class property DSCModuleVersion for class MSFT_BaseConfigurationProviderRegistration
Validating Class property Key for class MSFT_KeyValuePair
Validating Class property ModuleName for class MSFT_PSConfigurationProviderRegistration
Validating Class property Version for class OMI_ConfigurationDocument
Validating Class property Author for class OMI_ConfigurationDocument
Validating Class property Copyright for class OMI_ConfigurationDocument
Validating Class property HelpInfoUri for class OMI_ConfigurationDocument
Validating Class property Namespace for class MSFT_CimConfigurationProviderRegistration
Validating Class property SourceInfo for class OMI_BaseResource
Reading the file content from C:\Windows\System32\Configuration\Current.mof
Getting PS provider schema path and registration information
Reading the file content from C:\Program Files\WindowsPowerShell\Modules\cNetworking\DscResources\PSHOrg_cIPAddress\PSHOrg_cIPAddress.schema.mof
Validating DSC Provider schema against a class array of size 1
Validating Schema of class PSHOrg_cIPAddress which is class index 0 in an array of classes of size 1
Reading the file content from C:\Program Files\WindowsPowerShell\Modules\cNetworking\DscResources\PSHOrg_cDNSServerAddress\PSHOrg_cDNSServerAddress.schema.mof
Validating DSC Provider schema against a class array of size 1
Validating Schema of class PSHOrg_cDNSServerAddress which is class index 0 in an array of classes of size 1
Validating instance document.
Setting resources in order. Number of resources: 4
Resolving Dependencies inside the configuration document.
Method SendConfigurationApply started with parameters 
 	 Class name: OMI_ConfigurationDocument 
 	 Resource ID:  
 	 Flags: 0 
 	 Execution Mode: 192 
 	 Provider Namespace: NULL 
Parsing the configuration to apply.
Validating DSC Document instance with instance array size of 5 and flags 16
Executing operations for WMIv2 Provider MSFT_FileDirectoryConfiguration with resource name [File]ScriptFolder
Invoking session and getting result for namespace root/microsoft/windows/DesiredStateConfiguration, classname MSFT_FileDirectoryConfiguration for method TestTargetResource
[OMA-DSCTEST-01]: LCM:  [ Start  Test     ]  [[File]ScriptFolder]  
[OMA-DSCTEST-01]:                            [[File]ScriptFolder] The destination object was found and no action is required.
Getting a registration instance for MSFT_FileDirectoryConfiguration
Moving the resource [File]ScriptFolder of class MSFT_FileDirectoryConfiguration to desired state.
[OMA-DSCTEST-01]: LCM:  [ Start  Resource ]  [[File]ScriptFolder]  
Method Exec_WMIv2Provider started with parameters 
 	 Class name: MSFT_FileDirectoryConfiguration 
 	 Resource ID: [File]ScriptFolder 
 	 Flags: 0 
 	 Execution Mode: 192 
 	 Provider Namespace: NULL 
[OMA-DSCTEST-01]: LCM:  [ End    Test     ]  [[File]ScriptFolder]  in 0.0000 seconds.
Getting a registration instance for MSFT_FileDirectoryConfiguration
Method ExecuteProviderCommand started.
Method Exec_PSProvider started with parameters 
 	 Class name: PSHOrg_cDNSServerAddress 
 	 Resource ID: [cDNSServerAddress]SetDNSAddress 
 	 Flags: 0 
 	 Execution Mode: 192 
 	 Provider Namespace: NULL 
Moving the resource [cDNSServerAddress]SetDNSAddress of class PSHOrg_cDNSServerAddress to desired state.
[OMA-DSCTEST-01]: LCM:  [ Skip   Set      ]  [[File]ScriptFolder]  
[OMA-DSCTEST-01]: LCM:  [ End    Resource ]  [[File]ScriptFolder]  
[OMA-DSCTEST-01]: LCM:  [ Start  Resource ]  [[File]BGInfo]  
Executing operations for WMIv2 Provider MSFT_FileDirectoryConfiguration with resource name [File]BGInfo
Invoking session and getting result for namespace root/microsoft/windows/DesiredStateConfiguration, classname MSFT_FileDirectoryConfiguration for method TestTargetResource
[OMA-DSCTEST-01]: LCM:  [ Start  Test     ]  [[File]BGInfo]  
[OMA-DSCTEST-01]:                            [[File]BGInfo] The destination object was found and no action is required.
[OMA-DSCTEST-01]: LCM:  [ End    Test     ]  [[File]BGInfo]  in 0.0000 seconds.
[OMA-DSCTEST-01]: LCM:  [ Skip   Set      ]  [[File]BGInfo]  
[OMA-DSCTEST-01]: LCM:  [ End    Resource ]  [[File]BGInfo]  
Getting a registration instance for PSHOrg_cDNSServerAddress
Executing operations for PS Provider PSHOrg_cDNSServerAddress with resource name [cDNSServerAddress]SetDNSAddress
[OMA-DSCTEST-01]: LCM:  [ Start  Test     ]  [[cDNSServerAddress]SetDNSAddress]  
[OMA-DSCTEST-01]:                            [[cDNSServerAddress]SetDNSAddress] Checking the DNS Server Address ...
Method Exec_WMIv2Provider started with parameters 
 	 Class name: MSFT_FileDirectoryConfiguration 
 	 Resource ID: [File]BGInfo 
 	 Flags: 0 
 	 Execution Mode: 192 
 	 Provider Namespace: NULL 
Moving the resource [File]BGInfo of class MSFT_FileDirectoryConfiguration to desired state.
[OMA-DSCTEST-01]:                            [[File]BGInfo] Building file list from cache.
[OMA-DSCTEST-01]: LCM:  [ Start  Resource ]  [[cDNSServerAddress]SetDNSAddress]  
Getting a registration instance for PSHOrg_cIPAddress
Method Exec_PSProvider started with parameters 
 	 Class name: PSHOrg_cIPAddress 
 	 Resource ID: [cIPAddress]SetIPAddress 
 	 Flags: 0 
 	 Execution Mode: 192 
 	 Provider Namespace: NULL 
Method ExecuteProviderCommand started.
Moving the resource [cIPAddress]SetIPAddress of class PSHOrg_cIPAddress to desired state.
[OMA-DSCTEST-01]:                            [[cDNSServerAddress]SetDNSAddress] DNS Servers are set correctly.
[OMA-DSCTEST-01]: LCM:  [ End    Test     ]  [[cDNSServerAddress]SetDNSAddress]  in 0.0150 seconds.
[OMA-DSCTEST-01]: LCM:  [ Skip   Set      ]  [[cDNSServerAddress]SetDNSAddress]  
[OMA-DSCTEST-01]: LCM:  [ End    Resource ]  [[cDNSServerAddress]SetDNSAddress]  
[OMA-DSCTEST-01]: LCM:  [ Start  Resource ]  [[cIPAddress]SetIPAddress]  
Executing operations for PS Provider PSHOrg_cIPAddress with resource name [cIPAddress]SetIPAddress
[OMA-DSCTEST-01]: LCM:  [ Start  Test     ]  [[cIPAddress]SetIPAddress]  
[OMA-DSCTEST-01]:                            [[cIPAddress]SetIPAddress] Checking the IPAddress ...
[OMA-DSCTEST-01]:                            [[cIPAddress]SetIPAddress] IPAddress is correct.
[OMA-DSCTEST-01]: LCM:  [ End    Test     ]  [[cIPAddress]SetIPAddress]  in 0.0310 seconds.
[OMA-DSCTEST-01]: LCM:  [ Skip   Set      ]  [[cIPAddress]SetIPAddress]  
[OMA-DSCTEST-01]: LCM:  [ End    Resource ]  [[cIPAddress]SetIPAddress]  
Method CallConsistencyEngine ended successfully
Consistency engine was run successfully.
[OMA-DSCTEST-01]:                            [] Consistency check completed.
Saving configuration instance into C:\Windows\System32\Configuration\DSCEngineCache.mof.
Method MSFT_DSCLocalConfigurationManager_Invoke_PerformRequiredConfigurationChecks ended successfully

 

 

 

PowerShell Desired State Configuration (DSC) Journey – Day 9

First, some DSC related links from the weekend.  I got caught up on these today, and like usual learned quite a bit from the articles.

From The Scripting Guys:

Use Configuration File to Apply PowerShell DSC to Multiple Servers

PowerShell, Network Adapters and Domain Name System

Troubleshoot with PowerShell DSC Diagnostics Module

That last link is particularly timely, because I am still struggling with being able to Pull a Configuration from my Pull Server.  I am hoping I can use the DSC Diagnostics Module to determine what is going on.  I will say this, if I copy the xNetworking Module from my Pull Server to my DSCTest Server, the Configuration is applied within minutes.  For some reason the DSCTest server doesn’t think it can find the xNetworking Module on the Pull Server.

Get-xDscOperation -ComputerName oma-dsctest-01 -Newest 3

And here are the results.  The relevant stuff is at the bottom, I am including all of it for the sake of context.

ComputerName   SequenceId TimeCreated           Result   JobID                                 AllEvents            
------------   ---------- -----------           ------   -----                                 ---------            
oma-dsctest-01 1          3/17/2014 3:34:56 PM  Failure  c97f4016-6322-4ae3-95b8-770ad180a153  {@{Message=Validat...
oma-dsctest-01 2          3/17/2014 3:06:01 PM  Success  e6ddf784-8f01-403c-8e60-ce3b39504cec  {@{Message=Configu...
oma-dsctest-01 3          3/17/2014 3:04:40 PM  Success  6266763e-4adf-49f4-9e79-85b4d3e35af6  {@{Message=Configu...

I then run the following command to get more detail about Sequence ID 1.

Trace-xDscOperation -ComputerName oma-dsctest-01 -SequenceID 1 | Select-Object -ExpandProperty Message

And here is the full Message I got from the trace. The really relevant stuff is at the bottom.

Validating DSC Provider schema against a class array of size 1
Validating Class property Value for class MSFT_KeyValuePair
Validating Class property ClassName for class MSFT_BaseConfigurationProviderRegistration
Validating Class property DSCEngineCompatVersion for class MSFT_BaseConfigurationProviderRegistration
Validating Class property DSCModuleVersion for class MSFT_BaseConfigurationProviderRegistration
Validating Class property Namespace for class MSFT_CimConfigurationProviderRegistration
Validating Class property ModuleName for class MSFT_PSConfigurationProviderRegistration
Validating Class property Version for class OMI_ConfigurationDocument
Validating Class property Author for class OMI_ConfigurationDocument
Validating Class property Copyright for class OMI_ConfigurationDocument
Validating Class property HelpInfoUri for class OMI_ConfigurationDocument
Validating Class property Key for class MSFT_KeyValuePair
Validating Class property ContentType for class OMI_ConfigurationDocument
Validating Class property GenerationHost for class OMI_ConfigurationDocument
Validating Class property UserName for class MSFT_Credential
Validating Class property Password for class MSFT_Credential
Reading the file content from C:\Windows\System32\Configuration\BaseRegistration\MSFT_DSCMetaConfiguration.mof
Validating DSC Provider schema against a class array of size 1
Reading the file content from C:\Windows\System32\Configuration\Schema\MSFT_FileDirectoryConfiguration\MSFT_FileDirectoryConfiguration.Schema.mof
Validating Schema of class MSFT_FileDirectoryConfiguration which is class index 0 in an array of classes of size 1
Reading the file content from C:\Windows\System32\Configuration\Registration\MSFT_FileDirectoryConfiguration\MSFT_FileDirectoryConfiguration.Registration.mof
Validating DSC Provider registration instance for class : MSFT_CimConfigurationProviderRegistration
Validating provider registration against schema 
	 Number of classes: 9 
	 Number of Registrations: 1 
Validating Class property GenerationDate for class OMI_ConfigurationDocument
Validating Class property ModuleVersion for class OMI_BaseResource
Validating Schema of class MSFT_DSCMetaConfiguration which is class index 0 in an array of classes of size 1
Validating Class property DependsOn for class OMI_BaseResource
Validating Class property SourceInfo for class OMI_BaseResource
Validating Class property ResourceId for class OMI_BaseResource
Validating infrastructure schema
Reading the file content from C:\Windows\System32\Configuration\BaseRegistration\BaseResource.schema.mof
Validating Class property ModuleName for class OMI_BaseResource
Validating Class property GenerationHost for class OMI_ConfigurationDocument
Validating Class property GenerationDate for class OMI_ConfigurationDocument
Validating Class property ContentType for class OMI_ConfigurationDocument
Validating Class property HelpInfoUri for class OMI_ConfigurationDocument
Validating Class property Copyright for class OMI_ConfigurationDocument
Validating Class property ModuleName for class MSFT_PSConfigurationProviderRegistration
Validating Class property Version for class OMI_ConfigurationDocument
Validating Class property UserName for class MSFT_Credential
Validating Class property Namespace for class MSFT_CimConfigurationProviderRegistration
Validating Class property DSCModuleVersion for class MSFT_BaseConfigurationProviderRegistration
Validating Class property Author for class OMI_ConfigurationDocument
Validating Class property Password for class MSFT_Credential
Validating Class property ConfigurationModeFrequencyMins for class MSFT_DSCMetaConfiguration
Validating infrastructure schema
Validating Class property DSCEngineCompatVersion for class MSFT_BaseConfigurationProviderRegistration
Validating Class property RebootNodeIfNeeded for class MSFT_DSCMetaConfiguration
Validating Class property Credential for class MSFT_DSCMetaConfiguration
Validating Class property ConfigurationMode for class MSFT_DSCMetaConfiguration
Validating Class property RefreshMode for class MSFT_DSCMetaConfiguration
Validating Class property CertificateID for class MSFT_DSCMetaConfiguration
Validating Class property ConfigurationID for class MSFT_DSCMetaConfiguration
Validating Class property DownloadManagerName for class MSFT_DSCMetaConfiguration
Validating Class property DownloadManagerCustomData for class MSFT_DSCMetaConfiguration
Validating Class property RefreshFrequencyMins for class MSFT_DSCMetaConfiguration
Validating Class property AllowModuleOverwrite for class MSFT_DSCMetaConfiguration
Reading the file content from C:\Windows\System32\Configuration\MetaConfig.mof
Reading the file content from C:\Windows\System32\Configuration\BaseRegistration\MSFT_DSCMetaConfiguration.mof
Validating Class property ClassName for class MSFT_BaseConfigurationProviderRegistration
Validating Class property ModuleVersion for class OMI_BaseResource
Validating Class property Key for class MSFT_KeyValuePair
Validating Class property ModuleName for class OMI_BaseResource
Validating Class property DependsOn for class OMI_BaseResource
Validating Class property SourceInfo for class OMI_BaseResource
Validating Class property ResourceId for class OMI_BaseResource
Validating infrastructure schema
Reading the file content from C:\Windows\System32\Configuration\BaseRegistration\BaseResource.schema.mof
Validating Class property Value for class MSFT_KeyValuePair
Reading the file content from C:\Windows\System32\Configuration\DSCEngineCache.mof
Configuration is sent from computer NULL by user sid S-1-5-18.
Getting Metaconfiguration details.
Getting Metaconfiguration details.
Reading the file content from C:\Windows\System32\Configuration\Current.mof.checksum
Attempting to get the action from pull server using Download Manager WebDownloadManager. Configuration Id is a0a95372-66de-4937-896d-ac3489ab05d0. Checksum is 0B3A20CE3BCE0055B6C70B5266AED65F
860DE9A2C3664FDCCEAA86410AB911A4. Compliance status is true.
WebDownloadManager for configuration a0a95372-66de-4937-896d-ac3489ab05d0 Do-DscAction command with server url: http://MyTargetServer.domain.com:8080/PSDSCPullServer.svc.
WebDownloadManager for configuration a0a95372-66de-4937-896d-ac3489ab05d0 Do-DscAction command, GET Url: PSDSCPullServer.svc/Action(ConfigurationId='a0a95372-66de-4937-896d-ac3489ab05d0')/Get
Action.
WebDownloadManager for configuration a0a95372-66de-4937-896d-ac3489ab05d0 Do-DscAction command, GET call result: GetConfiguration.
Successfully got the action GetConfiguration from pull server using Download Manager WebDownloadManager.
Attempting to get the configuration from pull server using Download Manager WebDownloadManager.Configuration Id is a0a95372-66de-4937-896d-ac3489ab05d0.
Attempting to get the configuration a0a95372-66de-4937-896d-ac3489ab05d0 from pull server with Server Url http://MyTargetServer.domain.com:8080/PSDSCPullServer.svc using Web Download Manager.
WebDownloadManager for configuration a0a95372-66de-4937-896d-ac3489ab05d0 Get-DscDocument command, GET Url: PSDSCPullServer.svc/Action(ConfigurationId='a0a95372-66de-4937-896d-ac3489ab05d0')/
ConfigurationContent.
WebDownloadManager for configuration a0a95372-66de-4937-896d-ac3489ab05d0 Get-DscDocument command, File save result: C:\Windows\TEMP\635306672954009100\localhost.mof.
The checksum validation for configuration C:\Windows\TEMP\\635306672954009100\localhost.mof completed with status code 0.
WebDownloadManager for configuration a0a95372-66de-4937-896d-ac3489ab05d0 Get-DscDocument command, File save result: C:\Windows\TEMP\635306672954009100\localhost.mof.checksum.
WebDownloadManager for configuration a0a95372-66de-4937-896d-ac3489ab05d0 Get-DscDocument command, GET call result: Ok.
The checksum validation for configuration a0a95372-66de-4937-896d-ac3489ab05d0 completed with status code 0.
Attempting to get the modules {(xNetworking,2.0)} from pull server with Server Url http://MyTargetServer.domain.com:8080/PSDSCPullServer.svc using Web Download Manager.
Attempting to get the modules from pull server using Download Manager WebDownloadManager. Configuration Id is a0a95372-66de-4937-896d-ac3489ab05d0. Modules are (xNetworking,2.0).
WebDownloadManager Get-DscModule command, module xNetworking, GET Url: PSDSCPullServer.svc/Module(ConfigurationId='a0a95372-66de-4937-896d-ac3489ab05d0',ModuleName='xNetworking',ModuleVersion
='2.0')/ModuleContent.
This event indicates that failure happens when LCM is trying to get the configuration from pull server using download manager WebDownloadManager. ErrorId is 0x1. ErrorDetail is Cannot find mo
dule xNetworking.2.0 from the server http://MyTargetServer.domain.com:8080/PSDSCPullServer.svc/Module(ConfigurationId='a0a95372-66de-4937-896d-ac3489ab05d0',ModuleName='xNetworking',ModuleVersion=
'2.0')/ModuleContent.
WebDownloadManager Get-DscModule command, module xNetworking, GET call result: Cannot find module xNetworking.2.0 from the server http://MyTargetServer.domain.com:8080/PSDSCPullServer.svc/Module(C
onfigurationId='a0a95372-66de-4937-896d-ac3489ab05d0',ModuleName='xNetworking',ModuleVersion='2.0')/ModuleContent..
Saving configuration instance into C:\Windows\System32\Configuration\DSCEngineCache.mof.
Method MSFT_DSCLocalConfigurationManager_Invoke_PerformRequiredConfigurationChecks ended successfully

Now, for whatever reason it doesn’t think it can find the xNetworking module to download it.  I first want to double check my Pull Server Configuration.

  xDscWebService PSDSCPullServer
        {
            Ensure                  = "Present"
            EndpointName            = "PSDSCPullServer"
            Port                    = 8080
            PhysicalPath            = "$env:SystemDrive\inetpub\wwwroot\PSDSCPullServer"
            CertificateThumbPrint   = "AllowUnencryptedTraffic"
            ModulePath              = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Modules"
            ConfigurationPath       = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Configuration"
            State                   = "Started"
            DependsOn               = "[WindowsFeature]DSCServiceFeature"
        }

The ModulePath is set above.  I am certain I copied all the Module files into that directory, but I will double check.  Nope, I am not crazy.

dsc20

And just to check I open up the xNetworking.psd1 file and the very first line states that

# Version number of this module.
ModuleVersion = ‘2.0’

So that looks fine as well.  At this point I am kind of stumped.  I am not sure what the problem is.  All the modules also exist in the C:\Program Files\WindowsPowerShell\Modules directory.  While doing some playing around and looking at the Configurations for my Pull Server and DSCTest I am wondering where the name of the Download Manager comes in.  I just used the Configuration in Don Jones DSC-Ebook, and it seems to have worked fine for him.  But I am wondering if it needs to be something besides WebDownloadManager.  The TechNet Article for Local Configuration Manager states that DownloadManagerName “Indicates the name of the Configuration and module download manager.”  Well.  That doesn’t really help me.  I do some Google searching and see that same name, WebDownloadManager used a bunch, so it must the Default and be OK to use.

I did a bunch more searching and came across this article that talks about configuring Pull mode over SMB.  In the update at the end it talks about how he needed to set folder permissions to access his share, so I think maybe that the can be the problem.  I share out the C:\Program Files\WindowsPowerShell\DSCService\Modules folder to Everyone, giving them Full Control, and wait and see what happens.

If it checks in to Pull before I leave again today, I will update this post, otherwise I will continue tomorrow.

Update 4:24 PM.  Still failing.  Looking like I may have to try the DSCFileDownloadManager configuration tomorrow and see if I have any more luck.

Update 6:14 PM  I figured out what was wrong.  Reading further in the DSC E-Book, it talks about deploying custom resources.  Apparently even the Microsoft released Resources, such as xNetworking, which do not come with the default DSC Configuration need their own checksum file.  I created a .zip file named xNetworking_2.0.zip in the C:\Program Files\WindowsPowerShell\DSCService\Modules directory (from the extracted xNetworking folder in my modules directory).  I then ran the New-DSCChecksum command against that file to create the checksum file.  I then manually run the scheduled task on the DSCTTest server, and boom, configured!

PowerShell Desired State Configuration (DSC) Journey – Day 8

When we left off yesterday I was stuck getting my DSC Pull Server working properly.  The fix turned out to be easy.  Don’t configure a server to be a DSC Pull Server unless it’s Server 2012 R2.  Server 2012 doesn’t have the feature to make it work properly.  Once I upgraded my server to 2012 R2 and ran through the steps again everything worked great.

Now that my DSC Pull Server is working, can I pull an actual configuration from it?  I have a brand new Server 2012 R2 Server Core VM that isn’t configured for anything right now.  Here is the Configuration I would like to push to it.

Configuration ServerCore
{
    param
    (
        [Parameter(Mandatory = $True)]
        [ValidateNotNullorEmpty()]
        [String[]]$ComputerName='localhost',

        [Parameter(Mandatory = $True)]
        [ValidateNotNullorEmpty()]
        [String]$IPAddress,

        [Parameter(Mandatory = $True)]
        [ValidateNotNullorEmpty()]
        [String]$DefaultGateway,

        [Parameter(Mandatory = $True)]
        [ValidateNotNullorEmpty()]
        [String]$SubnetMask,

        [Parameter(Mandatory = $True)]
        [ValidateNotNullorEmpty()]
        [String[]]$DNSServerAddress
    )

    Import-DSCResource -Module xNetworking

    node $ComputerName
    {
        xIPAddress SetIPAddress
        {
            InterfaceAlias = "Ethernet"
            IPAddress = $IPAddress
            AddressFamily = "IPv4"
            DefaultGateway = $DefaultGateway
            SubnetMask = $SubnetMask
            DependsOn = "[xDNSServerAddress]SetDNSAddress"
        }

        xDNSServerAddress SetDNSAddress
        {
            Address = $DNSServerAddress
            InterfaceAlias = "Ethernet"
            AddressFamily = "IPv4"
        }

    }

}

I skipped a bunch of testing this on my part, but don’t set an IP address without first setting the DNS Address.  It doesn’t work out very well.  I Invoke the Configuration by running a command like this (all these values are made up)

ServerCore -ComputerName TargetServer -IPAddress 192.168.168.100 -DefaultGateway 192.168.168.1 -SubnetMask 24 -DNSServerAddress 192.168.168.2,192.168.168.3,192.168.168.4

The network adapter on the VM is currently configured for DHCP.  Let’s get this Configuration sent to the Pull Server and have my Server Core VM pull it.  Again, we are following the steps in the DSC E-Book.

I run Get-DSCLocalConfiguration manager on my Server Core VM and can see that the RefreshMode is set to Push:

Get-DSCLocalConfigurationManager
AllowModuleOverwrite : False
CertificateID :
ConfigurationID : 0c6dfa3e-0b9c-4c91-8145-2363d7aa32af
ConfigurationMode : ApplyOnly
ConfigurationModeFrequencyMins : 30
Credential :
DownloadManagerCustomData : {MSFT_KeyValuePair (key = “ServerUrl”), MSFT_KeyValuePair (key = “AllowUnsecureConnection”)}
DownloadManagerName : WebDownloadManager
RebootNodeIfNeeded : False
RefreshFrequencyMins : 15
RefreshMode : PUSH
PSComputerName :

First step.  Create a new GUID.

$guid = [guid]::NewGuid()

Second step.  Copy the file.

$source = "ServerCore\TargetServer.domain.com.mof"
$dest = "\\PullServer\c`$\program files\windowspowershell\dscservice\configuration\$guid.mof"
copy $source $dest

Third step.  Create a new CheckSum.

New-DSCChecksum $dest

Fourth step.  Tell a computer to Pull a Configuration.

Configuration SetPullMode 
{
	param([string]$guid)
	Node servercore.domain.com
	{
		LocalConfigurationManager
		{

			ConfigurationMode = 'ApplyOnly'
			ConfigurationID = $guid
			RefreshMode = 'Pull'
			DownloadManagerName = 'WebDownloadManager'
			DownloadManagerCustomData = @{
			ServerUrl = 'http://pullserver.domain.com:8080/PSDSCPullServer.svc';
			AllowUnsecureConnection = 'true' }
		}
	}
}

SetPullMode –guid $guid
Set-DSCLocalConfigurationManager -Computer servercore.domain.com -Path ./SetPullMode –Verbose

We run that script and magic happens (after about 10 minutes).  The server is configured with the static IP, Gateway, SubnetMask and DNS Server Addresses that I specified.  We can also see now that the server is Configured for Pull mode.

dsc18

Now, something I discovered while writing this article.  I tested this before I wrote this.  I set my VM back to using DHCP and then watched as the VM was checking in, but not doing anything.  While waiting to see if anything was happening, I got around to reading this article by Steven Murawski.  And wouldn’t you know it.  I needed to change a setting on the Local DSC Configuration Server on my Server Core VM.  The updated TechNet documentation can be found here.

Here is my updated SetPullModeConfiguration.

Configuration SetPullMode 
{
	param([string]$guid)
	Node oma-dsctest-01
	{
		LocalConfigurationManager
		{

			ConfigurationMode = 'ApplyAndAutocorrect'
			ConfigurationID = $guid
			RefreshMode = 'Pull'
			DownloadManagerName = 'WebDownloadManager'
			DownloadManagerCustomData = @{
			ServerUrl = 'http://PULLSERVER.DOMAIN.COM:8080/PSDSCPullServer.svc';
			AllowUnsecureConnection = 'true' }
            ConfigurationModeFrequencyMins = 15
            RefreshFrequencyMins = 15
            RebootNodeIfNeeded = $True
		}
	}
}

SetPullMode –guid $guid
Set-DSCLocalConfigurationManager -Computer oma-dsctest-01 -Path ./SetPullMode –Verbose

And the output from DSC:

VERBOSE: Performing the operation "Start-DscConfiguration: SendMetaConfigurationApply" on target "MSFT_DSCLocalConfigurati
onManager".
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendMetaConfigurationApply,'class
Name' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer MyComputer with user sid S-1-5-21-738551990-92959840-526660263-26310.
VERBOSE: [OMA-DSCTEST-01]: LCM:  [ Start  Set      ]
VERBOSE: [OMA-DSCTEST-01]: LCM:  [ Start  Resource ]  [MSFT_DSCMetaConfiguration]
VERBOSE: [OMA-DSCTEST-01]: LCM:  [ Start  Set      ]  [MSFT_DSCMetaConfiguration]
VERBOSE: [OMA-DSCTEST-01]: LCM:  [ End    Set      ]  [MSFT_DSCMetaConfiguration]  in 0.0630 seconds.
VERBOSE: [OMA-DSCTEST-01]: LCM:  [ End    Resource ]  [MSFT_DSCMetaConfiguration]
VERBOSE: [OMA-DSCTEST-01]: LCM:  [ End    Set      ]
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Set-DscLocalConfigurationManager finished in 0.409 seconds.

And the screenshot for more proof:

dsc19

The FrequencyMins don’t match what I set, I am guessing there are limits to how low those can go.  Once I did that it pulled the correct Configuration down and applied it, returning the Server Core VM to the correct IP settings.