PowerShell: basic Desired State Configuration (DSC)

This shows a basic config…

, which I have adapted for my Windows 10 box. Note ref Kerberos etc objections, you will also need to look at this.

Some history from the PowerShell session lest I forget:

Get-DscResource service -Syntax
Get-Item -Path WSMan:\localhost\Client\TrustedHosts
$cred = Get-Credential
Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value ‘DEN-I7’
$sess = New-PSSession -ComputerName DEN-I7
$sess = New-PSSession -ComputerName DEN-I7 -Credential $cred
C:\temp\BasicInstall.ps1

, where last line is this:

dsc01

Configuration BasicDscConfig
{
Node “DEN-I7” {
WindowsFeature NetFramework35Core {
Name = “NET-Framework-Core”
Ensure = “Present”
}

WindowsFeature NetFramework45Core {
Name = “NET-Framework-45-Core”
Ensure = “Present”
}

WindowsFeature ASP {
Ensure = “Present”
Name = “Web-Asp-Net45”
}
}
}

BasicDscConfig -InstanceName “DEN-I7”
Start-DscConfiguration -Path .\BasicDscConfig -Wait -Verbose -Force

#http://blogs.technet.com/b/privatecloud/archive/2013/08/30/introducing-powershell-desired-state-configuration-dsc.aspx

dsc02

Following a reboot after unsetting .Net 3.5 and 4.6 (sic), I tried again, and this time go this:

dsc03

So because this is a client-type machine, it won’t accept these particular Features from DSC.

Let’s see what happens if I more modestly just try to create a folder (I’ll delete the MOF files first)

Configuration BasicDscConfig
{
Node “DEN-I7” {
<# WindowsFeature NetFramework35Core { Name = “NET-Framework-Core” Ensure = “Present” } WindowsFeature NetFramework45Core { Name = “NET-Framework-45-Core” Ensure = “Present” } WindowsFeature ASP { Ensure = “Present” Name = “Web-Asp-Net45” } #>
File MyRandomDir {
DestinationPath = “c:\temp3\andMore”
Type = “Directory”
Recurse = $false
}
}
}

BasicDscConfig -InstanceName “DEN-I7”
Start-DscConfiguration -Path .\BasicDscConfig -Wait -Verbose -Force

#http://blogs.technet.com/b/privatecloud/archive/2013/08/30/introducing-powershell-desired-state-configuration-dsc.aspx
#https://technet.microsoft.com/en-us/library/dn282129.aspx

1

dsc04

2

dsc05

3

dsc06

4