Aman Dhally's Blog

  • Home
  • 100Days Of Self Improvement
  • PowerShell Blog
  • Poetry
  • About Me
  • General

How to Use Windows PowerShell Desired State Configuration Group Resource.

16 May, 2014 by Leave a Comment

 

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

9. Using Registry Resource

10. Using Archive 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 :

 

14-05-2014 15-51-17

 

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“.

14-05-2014 15-41-15

In user container, you can see a username , whose name is “root“.

14-05-2014 15-41-53

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.

14-05-2014 15-43-20

<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>

Run the script, and it will generate the MOF file.

14-05-2014 15-43-46

Once, the MOF file is generated, we need to deploy it using, Start-DscConfiguration cmdlet.

Start the deployment of the MOF file using “Start-DscConfiguration“

Start-DscConfiguration -Path .\createNewGroup -Wait -Verbose

 

14-05-2014 15-44-31

Deployment of the MOF file is finished.

14-05-2014 15-44-57

it’s time to verify Smile 

Open Server Manger on the Server , Click  Local User and Group Option on the “Posh-Demo”  server, Click on Groups and and you can  see that group is created. ,

14-05-2014 15-45-39

If you check the properties of the group, you can see that , Description is set as we define it in our DSC script.and it also added the ROOT user to the group.

14-05-2014 15-46-09

Cool ! Isn’t

That’s all for today, see you in my next blog post.

Thanks

thank-you (3)

Regards

Aman Dhally

If you like, you can follow me on Twitter and Facebook. You can also check my “You Tube” channel for PowerShell video tutorials. You can download all of my scripts from “Microsoft TechNet Gallery”.

  • Click to print (Opens in new window)
  • Click to share on Google+ (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to email this to a friend (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Reddit (Opens in new window)
Posted in: PowerShell Tagged: Desired State Configuration, Desired State Configuration and PowerShell, DSC, DSC and PowerShell, DSC Resource Kit Wave 1, DSC Resource Kit Wave 2, DSC Resource Kit Wave3, DSC Resource Kit Waves, Group Resource, Powershell, PowerShell 4.0, WMF 4.0

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Disclaimer!

Please note all of these views and opinions are my own

RSS Click here to Subscribe to the Podcast

  • Use Powershell to find the difference between two dates. 18 April, 2017
  • PowerShell Basics : Find commands by using Get-Command cmdlet. 8 April, 2017
  • Tips and Tricks : Now you can loop your videos in YouTube 6 January, 2017
  • Tips : Now,You can edit PDF files in Microsoft Office 2016. [The Killing Feature] 3 January, 2017
  • Book Review : “She Walks, She Leads: Women Who Inspire India” by “Gunjan Jain” 18 October, 2016

Subscribe Podcast

Click Here to subscribe to the PodCast

Copyright © 2019 Aman Dhally's Blog.

Delicious WordPress Theme by themehall.com

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.