For the purposes of this script, native Group Policy is added via the native PowerShell command: Set-GPRegistryValue
https://technet.microsoft.com/itpro/powershell/windows/group-policy/set-gpregistryvalue
The code is as follows:
Function Set_GP {
param ($GP, $Key, $Type, $ValueName, $Value)
Set-GPRegistryValue -Name $GP -Key $Key -Type $Type -ValueName $ValueName -Value $Value -Server $SelectedDC >$Null
WriteLog "$Key`t`t$ValueName`t`t$Value" "GP"
} #End Function Set_GP
EXAMPLE
In this example the $BASE Enterprise Computer Policy is updated to enable: Run logon scripts synchronously
The script would contain the following code:
Set_GP $GPEntComputer “HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System” “DWORD” “RunLogonScriptSync” 1
Parameters:
GP - There are a number of Group Policy Objects create by the script depending on the options selected. They are:
$GPEntComputer = "$Base Enterprise Computer Policy" $GPEntUser = "$Base Enterprise User Policy" $GPEntOffice = "$Base Enterprise Office $OfficeProduct Policy" $GPRemoteUser = "$Base Remote User Policy" $GPRemoteComputer = "$Base Remote Computer Policy" $GPRemoteLoopback = "$Base Remote Loopback Policy" $GPWSUSTestPolicy = "$Base WSUS Test Workstations" $GPWSUSPolicy = "$Base WSUS Workstations"
Identify the Group Policy object that will get the new Group Policy setting, in this case $Base Enterprise Computer Policy, or $GPEntComputer.
The next few parameters are identified by using the Excel reference spreadsheet in conjunction with the appropriate ADMX file. To identify the rest of the parameters, open up the Excel spreadsheet, Windows10andWindowsServer2016PolicySettings.xlsx and search for the name of the policy.
Key - In this this case search for: Run logon scripts synchronously
This will bring the document to the following location:

Column E of the spreadsheet will identify the Key. Some policies are available for both Users and Computers, ensure the correct key path is copied based on the desired location.
The Key for this example is: HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System
After some practice it will be easy to identify some of the following values without going to the .admx file, but that is the easiest place ensure the correct values are identified.
Type - Open up the ADMX that was identified as containing the setting, in this case: scripts.admx. Once opened, search for the value that was just identified: RunLogonScriptSync. This jumps to the following location in the file:
<policy name="Run_Logon_Script_Sync_2" class="Machine" displayName="$(string.Run_Logon_Script_Sync)" explainText="$(string.Run_Logon_Script_Sync_Help)" key="Software\Microsoft\Windows\CurrentVersion\Policies\System" valueName="RunLogonScriptSync">
<parentCategory ref="Scripts" />
<supportedOn ref="windows:SUPPORTED_Win2k" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
Decimal means the Type for this example should be set to DWORD. The others that are used frequently in Group Policy are String and ExpandString.
ValueName - The ValueName is identified in column E (column F in the Office reference), following the ! of the Excel spreadsheet. In this case it is identified as RunLogonScriptSync
Value - The appropriate Value in this example is 1, since that is identified as the enabledValue in the scripts.admx. If the Group policy needed to be disabled, the value would be 0.
Finally, here is a completed command that can be run in the script that sets this specific Group Policy in this specific Group Policy Object.
Set_GP $GPEntComputer "HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System" "DWORD" "RunLogonScriptSync" 1
Additional Examples:
Set the AutoSave Path for Microsoft Word
Set_GP $GPOfficeOptionUser "HKCU\Software\Policies\Microsoft\office\$OfficeVersion\word\options" "ExpandString" "autosave-path" "%USERPROFILE%\Documents\AutoRecover"
Add a site to IE Compatibility Mode
Set_GP $GPEntUser "HKCU\Software\Policies\Microsoft\Internet Explorer\BrowserEmulation\PolicyList" "String" "site.com" "site.com"
While it is a bit of a pain to identify and get the correct settings, once they are identified and added to the script these settings can be rolled out from environment to environment with the click of a button. A number of example GP's are included in the script.
