PowerShell DSC Journey – Day 29

While working on some Demo scripts for a  presentation I am doing on DSC for the Infrastructure team I belong to at work, I ran into a couple of issues and figured I would blog about them.  I haven’t been publishing a lot of blogs lately because I am working on a series of posts about a little project I got myself into with DSC. Here is my Configuration that I am using to Demo with.

Configuration DemoPushServerConfig
{
    param
    (
        [Parameter(Mandatory = $True)]
        [ValidateNotNullorEmpty()]
        [String[]]$ComputerName

    )

    node $ComputerName
    {

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


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

        }

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


        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"

        }

    }

}

DemoPushServerConfig -ComputerName ServerA,ServerB

It’s just doing some really basic stuff to show some of the things that DSC can do. I randomly selected the Windows Features I am installing, which is where I ran into some issues.

 VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: [DSCTEST-01]:                            [[WindowsFeature]PowerShell] Installation succeeded.
The request to add or remove features on the specified server failed.
Installation of one or more roles, role services, or features failed.
The source files could not be downloaded. 
Use the "source" option to specify the location of the files that are required to restore the feature. For more information on specifying a source location, see 
http://go.microsoft.com/fwlink/?LinkId=243077. Error: 0x800f0906
    + CategoryInfo          : InvalidOperation: (@{Vhd=; Credent...Name=localhost}:) [], CimException
    + FullyQualifiedErrorId : DISMAPI_Error__Cbs_Download_Failure,Microsoft.Windows.ServerManager.Commands.AddWindowsFeatureCommand
    + PSComputerName        : ServerA.domain.com
 
VERBOSE: [DSCTEST-01]: LCM:  [ End    Set      ]  [[WindowsFeature]PowerShell]  in 43.1947 seconds.
The PowerShell DSC resource MSFT_RoleResource threw one or more non-terminating errors while running the Set-TargetResource functionality. These errors are logged to the ETW channel called 
Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : NonTerminatingErrorFromProvider
    + PSComputerName        : ServerA.domain.com
 
VERBOSE: [DSCTEST-01]: LCM:  [ Start  Resource ]  [[WindowsFeature]IISManagementTools]
VERBOSE: [DSCTEST-01]: LCM:  [ Start  Test     ]  [[WindowsFeature]IISManagementTools]
VERBOSE: [DSCTEST-01]:                            [[WindowsFeature]IISManagementTools] The operation 'Get-WindowsFeature' started: Web-Mgmt-Tools
VERBOSE: [DSCTEST-01]:                            [[WindowsFeature]IISManagementTools] The operation 'Get-WindowsFeature' succeeded: Web-Mgmt-Tools
VERBOSE: [DSCTEST-01]:                            [[WindowsFeature]IISManagementTools] The operation 'Get-WindowsFeature' started: Web-Mgmt-Console
VERBOSE: [DSCTEST-01]:                            [[WindowsFeature]IISManagementTools] The operation 'Get-WindowsFeature' succeeded: Web-Mgmt-Console
VERBOSE: [DSCTEST-01]: LCM:  [ End    Test     ]  [[WindowsFeature]IISManagementTools]  in 6.7754 seconds.
VERBOSE: [DSCTEST-01]: LCM:  [ Start  Set      ]  [[WindowsFeature]IISManagementTools]
VERBOSE: [DSCTEST-01]:                            [[WindowsFeature]IISManagementTools] Uninstallation started...
VERBOSE: [DSCTEST-01]:                            [[WindowsFeature]IISManagementTools] Uninstallation succeeded.
VERBOSE: [DSCTEST-01]:                            [[WindowsFeature]IISManagementTools] successfully unInstalled the feature Web-Mgmt-Tools.
VERBOSE: [DSCTEST-01]: LCM:  [ End    Set      ]  [[WindowsFeature]IISManagementTools]  in 0.3828 seconds.
VERBOSE: [DSCTEST-01]: LCM:  [ End    Resource ]  [[WindowsFeature]IISManagementTools]
The SendConfigurationApply function did not succeed.
    + CategoryInfo          : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 1
    + PSComputerName        : ServerA.domain.com

Using the Trace-XDSCOperation cmdlet I then find this in the logs.

Call to GetAlterationRequestState provider method failed with error(s): The request to add or remove feat
ures on the specified server failed.
Installation of one or more roles, role services, or features failed.
The source files could not be downloaded. 
Use the "source" option to specify the location of the files that are required to restore the feature. For more information on specifying a source location, see http://go.microsoft.com/fwlink
/?LinkId=243077. Error: 0x800f0906

[ServerA]:                            [[WindowsFeature]PowerShell] Installation succeeded.
This event indicates that a non-terminating error was thrown when DSCEngine was executing Set-TargetResource on MSFT_RoleResource DSC resource. FullyQualifiedErrorId is DISMAPI_Error__Cbs_Dow
nload_Failure,Microsoft.Windows.ServerManager.Commands.AddWindowsFeatureCommand. ErrorMessage is The request to add or remove features on the specified server failed.
Installation of one or more roles, role services, or features failed.
The source files could not be downloaded. 
Use the "source" option to specify the location of the files that are required to restore the feature. For more information on specifying a source location, see http://go.microsoft.com/fwlink
/?LinkId=243077. Error: 0x800f0906
.
Displaying debug messages from Powershell DSC resource:
	 ResourceID : [WindowsFeature]PowerShell 
	 Message : [ServerA]:                            [[WindowsFeature]PowerShell] End executing Set functionality on the PowerShellRoot feature.
Method Exec_PSProvider ended successfully
[ServerA]: LCM:  [ End    Set      ]  [[WindowsFeature]PowerShell]  in 43.1947 seconds.

Also, since I included a log file for this Windows Feature in my Configuration, here is what a section of that log file contains.

3056: 2014-05-19 13:14:47.244 [ServerManagerPS]           Complete initializing log file.
3056: 2014-05-19 13:14:47.682 [ServerManagerPS]           492fb36a-8a2a-413d-85a0-4ab3028acb5e Enumerate server component ended with Success.
3056: 2014-05-19 13:15:06.617 [ServerManagerPS]           492fb36a-8a2a-413d-85a0-4ab3028acb5e Alter server component started. Component names: PowerShell-V2,NET-Framework-Core,NET-Framework-Features,DSC-Service,ManagementOdata,Web-Static-Content,Web-Common-Http,Web-WebServer,Web-Server,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-Stat-Compression,Web-Performance,Web-Http-Logging,Web-Health,Web-Request-Monitor,Web-Http-Tracing,Web-Filtering,Web-Security,NET-WCF-HTTP-Activation45,NET-Framework-45-ASPNET,Web-Asp-Net45,Web-App-Dev,Web-ISAPI-Filter,Web-ISAPI-Ext,Web-Net-Ext45,WAS-Process-Model,WAS,WAS-Config-APIs,WindowsPowerShellWebAccess,Web-Http-Redirect
3056: 2014-05-19 13:15:06.648 [ServerManagerPS]           492fb36a-8a2a-413d-85a0-4ab3028acb5e Alter server component ended with InProgress. The progress is 20

There are a about 30 lines of that, with the progress getting up to 68 a couple of times before it fails and rolls back. Well, this issue appears pretty obvious. I believe it is looking for the Sources\SxS directory on the Server 2012 install media. And it’s telling me that I need to add that source to the Configuration. Can do! In my example I am using an attached DVD as the source, but ideally I think you would want to extract those files to a file server, and copy them over to the server so they are there for any future Windows Feature Configuration changes. Here is what my WindowsFeature PowerShell Resource now looks like.

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


        }

And Voila!

VERBOSE: Operation 'Invoke CimMethod' complete.
WARNING: [ServerA]:                            [[WindowsFeature]PowerShell] For more information about how to finish installing and configuring Windows PowerShell Web Access, see http:/
/go.microsoft.com/fwlink/?LinkID=221050.
VERBOSE: [ServerA]:                            [[WindowsFeature]PowerShell] Installation succeeded.
VERBOSE: [ServerA]:                            [[WindowsFeature]PowerShell] successfully installed the feature PowerShellRoot
VERBOSE: [ServerA]: LCM:  [ End    Set      ]  [[WindowsFeature]PowerShell]  in 195.3454 seconds.
VERBOSE: [ServerA]: LCM:  [ End    Resource ]  [[WindowsFeature]PowerShell]