[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 562
  • Last Modified:

Modify local Group Policy through powershell

Hi Everyone,

How can I add and lockdown "logon Script" in Local Group Policy through Powershell or batch script.
0
silcom
Asked:
silcom
  • 2
  • 2
1 Solution
 
Benjamin VoglarCommented:
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
 
silcomAuthor Commented:
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
 
CoralonCommented:
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
 
Benjamin VoglarCommented:
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
 
silcomAuthor Commented:
Thanks for the workaround on how to set logon script.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now