Solved

Modify local Group Policy through powershell

Posted on 2016-07-25
5
166 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 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

Threat Trends for MSPs to Watch

See the findings.
Despite its humble beginnings, phishing has come a long way since those first crudely constructed emails. Today, phishing sites can appear and disappear in the length of a coffee break, and it takes more than a little know-how to keep your clients secure.

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
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…

739 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