(For more resources related to this topic, see here.)
DSC approaches declarative syntax that describes what needs to be done rather than covering imperative syntax that specifies how a task can be performed.
To use DSC, first define a desired configuration. Like functions, configurations in DSC can be defined in the Windows PowerShell language by using the Configuration keyword and stored in script (.ps1) or module (.psm1) files. Also, similar to functions, configurations need to be defined and then run.
PS C :>MyWebConf -MachineName $env:COMPUTERNAME –WebsitePath
\PSShareMyWebSites
This will create a folder with the same name as your configuration name and will contain our MOF output file.
PS C :>Start-DscConfiguration -Path . MyWebConf –Wait –Verbose
Each Configuration block must have at least one Node block. Each Node block can have one or more resource provider blocks. You can use the same role provider more than once in the same Node block.
In addition to new language keywords, DSC includes the following set of CMDLETs for managing configurations:
PS C :>$Sess = New-CimSession -ComputerName localhost PS C :>Get-DscConfiguration –CimSession $Sess
PS C :>$Sess = New-CimSession -ComputerName localhost PS C :>Restore-DscConfiguration –CimSession $Sess
There is one more CMDLET that helps to detect the configuration drift:
PS C :>$session = New-CimSession -ComputerName localhost PS C :>Test-DscConfiguration –CimSession $session
This will either return True when the current and actual configuration matches or False if there’s a mismatch
In this article, we learned about how to execute the new feature introduced with the release of Windows PowerShell v4.0—Desired State Configuration.
Further resources on this subject:
I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…
Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…
Once we learn how to deploy an Ubuntu server, how to manage users, and how…
Key-takeaways: Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…
While developing a web application, or setting dynamic pages and meta tags we need to deal with…
Software architecture is one of the most discussed topics in the software industry today, and…