?
Solved

Modify local Group Policy through powershell

Posted on 2016-07-25
5
Medium Priority
?
382 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

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.
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month12 days, 22 hours left to enroll

777 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