Here is an introduction to the main new feature of PowerShell 4.0, Desired State Configuration. See how to create 'Nodes' and 'Resources', which will manage your operating system.
PowerShell 4.0 New Feature DSC
- PowerShell Desired State Configuration (DSC)
- Example Script for DSC
- PowerShell DSC in Action
- PowerShell Version 4.0
DSC is Microsoft's new system for building identical servers using PowerShell. It works well if you want a group of servers with the same role, for example file servers. As with many PowerShell tasks, the benefit is that automation will save time and produce consistency.
Another obvious way in which DSC repays your efforts is if you wish to return a server to its default state following a configuration failure of some sort.
Note 1: DSC depends on Windows PowerShell remoting.
Before you deploy a configuration naturally you will need to create a script. If you have experience of creating a PowerShell function then the format will seem familiar; The term 'Configuration' replaces 'Function', there are parameters at the top, followed by a process, or in this case a 'Node'.
As the name suggests, the keyword in DSC is Configuration. Within each script is at least one Node block, for example, HyperV. The modular nature of DSC expects a resource block for items such as WindowsFeatureIIS.
# A Configuration expects at least one Node
# Set DCM Settings for each Node
RebootNodeIfNeeded = $True
ConfigurationMode = "ApplyAndAutoCorrect"
ConfigurationModeFrequencyMins = 15
#Install the Hyper-V Role
Ensure = "Present"
Name = "Hyper-V"
} # … Add more roles
} #End of Node
} # End of Configuration
Note 2: To maintain the 'Desired State' sometimes you need to uninstall the role. To remove a role change Ensure = "Present" to = "Absent"
Note 3: Once again, knowledge of functions is useful when it comes to invoking the Configuration block.
# DSC Example:
MyWebConfig -MachineName "TestMachine" –WebsiteFilePath"\\filesrv\WebFiles" -Output Path "C:\DSC"
Note 4: The result is a MOF file known as the configuration instance document, created at the path specified in the script.
Note 5: DSC runs every 15 minutes if you are employing a push technology. It works rather like a Group Policy Object, where you push out settings which the operating systems enforces.
# Run your script with:
Start-DscConfiguration -Path "C:\DSC" -Wait -Force -Verbose
# Check with Get-DscConfiguration and Test-DscConfiguration.
Note 6: When Start-DscConfiguration runs it calls the Local Configuration Manager (LCM) on the server, which then process the MOF files. It is the LCM that makes any changes to enforce the assigned configuration.
SolarWinds’ Network Performance Monitor will help you discover what’s happening on your network. This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.
What I like best is the way NPM suggests solutions to network problems. Its also has the ability to monitor the health of individual VMware virtual machines. If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.
Microsoft provides the Desired State Configuration (DSC) as part of .NET Framework. This is the situation: you get PowerShell version 4.0 automatically with Server 2012 R2.
However, if you have Windows Server 2012 or 2008 R2, then you can install Windows Management Framework 4.0
Summary of PowerShell's Desired State Configuration
Microsoft's DSC is the latest management system that enables the deployment and management of configuration data for software services and the environment on the machines which these services operate.
The configuration is much like a PowerShell function, it has parameters, and the Process section is replaced by Nodes and Resources.
If you like this page then please share it with your friends
See more Microsoft PowerShell Examples of Real Life Tasks
Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.