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.
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
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.