5

PowerShell DSC: tips to get started right now

 3 years ago
source link: https://www.pluralsight.com/blog/software-development/powershell-dsc-tips
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
PowerShell DSC: tips to get started right now

PowerShell is a fantastic tool for automating tasks, managing computers, and even making your evening meal. Just kidding, of course, or am I? PowerShell, as you know, is a tool that runs on Windows natively and provides commands for management. With the most recent updates to PowerShell, you can run it on any platform, including macOS and Linux. 

However, one problem with using straight PowerShell is that everything needs scripting, including configuration values and customizations. Wouldn't it be great to create a template of what is required, then use it again on any system, or even clone an existing configuration and re-use it?

Luckily, we have that, and it is called PowerShell Desired State Configuration or DSC for short. DSC allows you to configure the Windows Operating System and Applications using a configuration file with PowerShell commands. It is similar to other configuration management systems such as Puppet or Ansible. You can describe the required configuration, otherwise known as the state in a configuration file, then use PowerShell to apply it to single or multiple computers and servers. DSC's goal is to help you simplify the deployment and configuration for servers and workstations. The secret is that it has been available since its launch in 2014 and was available in PowerShell version 4. PowerShell is available today for Windows, and there is a PowerShell Core Cross-platform version. DSC joined the ride and is available today within both versions.

How do I get PowerShell DSC?

Firstly, you need to select the platform you want to use DSC with. Current support is Windows Client and Server, Windows Nano Server, Linux, and Azure Automation. Luckily DSC is included within the Windows Instrumentation Framework, making it simple to use with no additional installation or updates. You can follow the current guidelines provided within the documentation to get up and running for other platforms.

How to get started using PowerShell DSC?

So, you have everything configured and ready to use, what comes next? That’s exactly why I’ve thrown together a few tips to help you get started.

Identify a specific need, requirement, or problem to solve

To get the most out of DSC, you need to have a specific task or reason for using it. It is not like other PowerShell commands, which execute tasks as directed by you and are typically limited to a particular feature or service. DSC takes that single process and superchargers it, allowing for a more powerful templated and reusable approach. Review those current tasks you have and any technical requirements and match that to a DSC process and build that.

Practice within a test environment

Creating a lab environment will allow you to isolate what you do and enable full creativity. I often see individuals trying to learn something new on their current work computer but restrict themselves on what they could know. Go spin up a cloud environment and go crazy; try it all, with no limitations, with no worry of ruining your nice work computer.

Watch Windows PowerShell Desired State Configuration Fundamentals Pluralsight Course

PowerShell MVP Jeff Hicks brought you another great video training resource to get started with DSC. Being a Pluralsight course, this method is most similar to a classroom training exercise with lots of demos. It's a great refresher on core DSC topics while also hitting some different points and suggestions that you may not know.

Visit and Read the PowerShell DSC Documentation on GitHub

If you learn better from reading and executing example code, then this is a great one to check out. It provides all the documentation you need, along with real-world examples and samples that will get you started quickly, written by Microsoft and other Community Members. 

https://github.com/PowerShell/DscResources

https://github.com/dsccommunity

Are you looking for more?

Download it. Play around with it and see if you can accomplish the same tasks with DSC you would do manually or with native PowerShell. Take a few minutes to read as many DSC articles online; however, don't get overwhelmed and try to roll out an entire infrastructure overnight. Instead, take small bites and practice. Once you've learned the basics, then start and finish bigger and bigger DSC projects. Before you know it, you'll create an entire server infrastructure using your own automated and repeatable DSC process.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK