windowspowershellregistrygroup-policy

How to manage policies in gpedit.msc in a workgroup server (Windows 2019) using powershell?


I am trying to create a powershell script to manage policies (Administrative Templates (Computer) / System) in gpedit.msc.

I want to manage these policies in windows 2019 server which is not part of any domain.

I know the registry keys for the policies but when I add or update this registries I dont see the corresponding changes in the gpedit.msc (gui).

Is there any way to manage "Administrative Templates (Computer) / System" policies in gpedit.msc which is in a Windows 2019 (workgroup) server using powershell ?


Solution

  • See: https://4sysops.com/archives/administering-group-policy-with-powershell/

    And: https://serverfault.com/questions/848388/how-to-edit-local-group-policy-with-a-script

    From the post above, use PolicyFileEditor PowerShell module: https://www.powershellgallery.com/packages/PolicyFileEditor/3.0.0

    Here is an example:

    $RegPath = 'Software\Policies\Microsoft\Windows\Control Panel\Desktop'
    $RegName = 'ScreenSaverIsSecure'
    $RegData = '1'
    $RegType = 'String'
    
    
    Set-PolicyFileEntry -Path $UserDir -Key $RegPath -ValueName $RegName -Data $RegData -Type $RegType