Solved

Modify local Group Policy through powershell

Posted on 2016-07-25
5
113 Views
Last Modified: 2016-09-05
Hi Everyone,

How can I add and lockdown "logon Script" in Local Group Policy through Powershell or batch script.
0
Comment
Question by:silcom
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:Benjamin Voglar
ID: 41734268
And what does the script do?

Is this what you are looking for?

https://4sysops.com/archives/configuring-logon-powershell-scripts-with-group-policy/
0
 

Author Comment

by:silcom
ID: 41735453
Hi Benjamin,

Script is setting wallpaper and network drive.

My computers are in workgroup and I want to set Local Group policy through Powershell or Command prompt and not GPEDIT.MSC GUI.
0
 
LVL 25

Accepted Solution

by:
Coralon earned 500 total points
ID: 41745624
All you have to do is look up the correct registry values and then use your script to place them..

For the logon script, you will copy your script down to whatever location, and then put a reference to it under HKLM\Software\Microsoft\Windows\CurrentVersion\Run
LogonScript = c:\scripts\logonscript.ps1 (REG_SZ)

You can use your login script to set the wallpaper, or you can lookup the registry value for the policy to put in that value.  (There are several places for policy values to go unfortunately.. )

Coralon
0
 
LVL 12

Expert Comment

by:Benjamin Voglar
ID: 41764816
Hi.

Make a bat file and copy this into:

@echo off
reg add "HKCU\control panel\desktop" /v wallpaper /t REG_SZ /d "" /f 
reg add "HKCU\control panel\desktop" /v wallpaper /t REG_SZ /d "C:\[LOCATION OF WALLPAPER HERE]" /f 
reg delete "HKCU\Software\Microsoft\Internet Explorer\Desktop\General" /v WallpaperStyle /f
reg add "HKCU\control panel\desktop" /v WallpaperStyle /t REG_SZ /d 2 /f
RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters 

net use s: /Delete
net use s: \\your\share

Exit

Open in new window


How to run a batch file each time the computer boots:

http://www.computerhope.com/issues/ch000322.htm
0
 

Author Closing Comment

by:silcom
ID: 41785605
Thanks for the workaround on how to set logon script.
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help you understand what HashTables are and how to use them in PowerShell.
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question