poniedziałek, 29 maja 2017

How to configure Local Group Policy via PowerShell part 1


This is the 1st part of automatizng Local Group Policies.
In this post you will learn how to :

- Create new local users and groups
- Configure Local Group Policies


 Requirements :

- Windows PowerShell 4.0
- Microsoft .NET Framework 4






1.Creating Groups and Users

·         Download and install Carbon Powershell Module


 Remember to Unblock files

 

·         Start PowerShell ISE as administrator


Use this command for import Carbon module to Powerhsell

Set-ExecutionPolicy bypass -Force

Import-Module -Name PATH_TO_CARBON_MODULE\Import-Carbon.ps1


Examples of using the module

Create New User :
 

Install-User -UserName Dev -Password P@SS0W0RD -UserCannotChangePassword


Create New Group:

Install-Group -Name DevGroup -Description 'Dev'

Add User to Group:

Add-GroupMember -Name DevGroup -Member Dev
 

 

 

Remove Group Member :



Remove-GroupMember -Name Devgroup -Member Dev


More commands and informations here --> http://get-carbon.org/
 

2.Set Local Group Policies


·        Download PolicyFileEditor PowerShell Module by Dave Wyatt

 


 

·         Extract downloaded files on your computer and make sure that files are unblocked and name of module match name of Windows PowerShell Script Module file.

It’s important.



·         Now copy unblocked and prepared module here :
C:\Windows\System32\WindowsPowerShell\v1.0\Modules

 
·         Type this commands for Import and start using PolicyFileEditor module

Set-ExecutionPolicy bypass -Force

Import-Module -Name PolicyFileEditor



 
·       Now we have two ways to set Local Group Policy restrictions:

First way

Use Microsoft Management Console. Set whole configuration for computer and user manually. Then import all settings to .xml file which can be used multiple times for apllying this settings on another machines via PowerShell.

·         File/Add-Remove Snap-in…

Choose “Group Policy Object Editor” 

 
Local Computer :
 
 


Or/And Users




·         Now you can start setting Local Group Policy restrictions

 

 Save your settings.


Go to part 2 --->  http://blog.besharp.pl/2017/05/how-to-configure-local-group-policy-via_29.html
·