I just discovered I have to enable a local group policy setting (Computer Configuration -> Administrative Templates -> System -> UserProfiles) on a server running a specific application. I have a PowerShell installation script I use to install the application and configure the server. I'd like to be able to enable this group policy in my installation script. Is there a way to do this in PowerShell? If not, any other technology? I'm comfortable using the Win32 API, if that is my only option.

  • What are you setting through group policy. Lots of policies simply make registry changes which Powershell can do directly. – Zoredache Aug 11 '16 at 20:52
  • @Zoredache Computer Configuration -> Administrative Templates -> System -> UserProfiles – splattered bits Aug 12 '16 at 0:25

Most group policy settings are just registry keys under HKLM\Software\Policies. If your PowerShell script runs as Adminstrator, you can just set the corresponding registry value and achieve the same effect without touching Group Policy.

The mappings between registry values and GPO settings is documented by Microsoft. https://www.microsoft.com/en-us/download/details.aspx?id=25250

| improve this answer | |

It's typically bad juju to mix local GPO and domain GPO with servers (it should be one or the other, otherwise you run into "one off" issues). Following the principal of functional GPO's I'd recommend creating a GPO with the specific setting, attach it to your server OU, and create a filter to attach to the GPO.

The filter could either be for the installed application (it's registry entries, install path, etc) or for the COMPUTERNAME. The filter settings use WQL for your reference.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.