1.Introduction of Windows PowerShell “Desired State Configuration”.
2.Installing Windows PowerShell 4.0 [Windows Management Framework 4.0].
3.Getting Started With Desired State Configuration: DSC Syntax.
4.Review of Desired State Configuration: The 3 easy steps.
5.Write your First Desired State Configuration Script using ROLE Resource.
6. Run your first “DSC” PowerShell Script.
7.Configuring Dependencies in “Desired State Configuration” script in PowerShell.
8.PowerShell and DSC : Using File Resource
In my previous blog post, we have seen that how can we use the “Archive Resource” of “Desired State Configuration”.
It’s time to create some new local groups and local users. In this blog post we are going to create a new LOCAL group.
We can create local groups using the “Group Resource” of the “Desired State Configuration”. Always keep in mind that “Group Resource” creates only LOCAL groups only it won’t support creating in new Domain groups.
“Group Resource” resource is very simple to configure and simple to use.
Syntax of the Group Resource is :
Let’s start.
What we are planning to achieve?
We are going to write an simple Desired State Configuration Script, which have a “Group Resource” block. In this script we, are creating a new Local Group, we also setting it’s description, and after that we are also adding one local user to this newly created group. That’s all.
For testing we are using our all time favourite server “Posh-Demo” again.
Open Server Manger on the Server , Click Local User and Group Option on the “Posh-Demo” server, Click on Groups and You can see that currently there is no group of the name of “AmanTestGroup“.
In user container, you can see a username , whose name is “root“.
Now, we have user, we need to create a new group,
The below is our “Desired State configuration script”.
The Name of our DSC script is DSC_CreatingNewGroups.ps1. And the name of our DSC configuration is “createNewGroup“.
We are using “Group Resource” of Desired State Configuration. Below is the parameters and there arguments details.
Ensure : Make sure it is present .
GroupName : Name of the desired group.
Member : Name of the local user groups, whom you want to add to this group.
Description : Description of the group.
<div id="codeSnippetWrapper"><pre id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4"><font size="3" face="Calibri">Configuration createNewGroup<br>{<br><br><br> Node <span style="color: #008000">'Posh-Demo'</span><br> {<br> Group testGroup<br> {<br> Ensure = <span style="color: #008000">'Present'</span><br> GroupName = <span style="color: #008000">'AmanTestGroup'</span><br> Members = <span style="color: #008000">'root'</span><br> Description = <span style="color: #006080">"This group is created by PowerShell DCS script"</span><br> <br><br> }<br> }<br>}<br>createNewGroup</font>