Home > Back-end >  How to enable group policy toggle button using powershell or cmd
How to enable group policy toggle button using powershell or cmd

Time:05-06

I am trying to automate sever setup of a windows 2019 server using userdata. I need to update the local group policy settings.

The specific group policy i want to enable is "Set time limit for disconnected sessions"

enter image description here

How can i enable this 'local' group policy for a vm using powershell or bash or even Regedit.

I have tried but i cant seem to get it be in an "enabled" state.

CodePudding user response:

Look at this Registry Edit.

You can access this registry key in Powershell or Bash.

More information here.

reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v MaxDisconnectionTime /t REG_DWORD /d 5000 /f

CodePudding user response:

Try this, its the same registry key but using Powershell to set.

Set-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" -Name MaxDisconnectionTime -Type REG_DWORD -Value 900000

The value is in ms, this would set it to 15 minutes.

https://admx.help/?Category=Windows_10_2016&Policy=Microsoft.Policies.TerminalServer::TS_SESSIONS_Disconnected_Timeout_2

After you run that, restart the device and the settings should be updated.

CodePudding user response:

There is no way to directly configure the local group policy using PowerShell.

When configured, the GPO sets a registry key and value. It's not bi-directional where you can set the registry key and then the GPO is configured.

You can use Microsoft's tool LGPO.exe to export the policy settings from a computer you've configured, and then use PowerShell to import those settings to your new computer.

  • Related