# Modify GPO settings via Powershell?

**URL:** <https://forums.powershell.org/t/modify-gpo-settings-via-powershell/9633>\
**Category:** PowerShell Help\
**Created:** [November 1, 2017, 9:54pm UTC](https://forums.powershell.org/t/modify-gpo-settings-via-powershell/9633 "2017-11-01T21:54:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivill](https://avatars.discourse-cdn.com/v4/letter/i/7993a0/32.png) [@ivill](https://forums.powershell.org/u/ivill)\
**Post date:** [November 1, 2017, 9:54pm UTC](https://forums.powershell.org/t/modify-gpo-settings-via-powershell/9633/1 "2017-11-01T21:54:44Z")

</div>

Hello All,  
I want to automate a task in Windows 10 Pro where i need to Toggle the “Remove Lock Computer” and “Remove Task Manager” enable/disable. is it possible to make it work via powershell?

**Gpedit.msc \> User Configuration \> Administrative Teamplates \> System \> Ctrl+Alt+Del Options \> Remove Lock Computer \> Enable(or Disable)**

**Gpedit.msc \> User Configuration \> Administrative Teamplates \> System \> Ctrl+Alt+Del Options \> Remove Task Manager \> Enable(or Disable)**

---

<div class="post-metadata">

**Author:** ![alex-aymonier](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@alex-aymonier](https://forums.powershell.org/u/alex-aymonier)\
**Post date:** [November 1, 2017, 10:55pm UTC](https://forums.powershell.org/t/modify-gpo-settings-via-powershell/9633/2 "2017-11-01T22:55:04Z")

</div>

I take it these are not on a domain? If they are then GPO is your best bet. The only way i can think of is you’ll need to find the reg keys that correspond to these settings and set those reg keys via PowerShell.

---

<div class="post-metadata">

**Author:** ![seth](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/seth/32/412_2.png) [@seth](https://forums.powershell.org/u/seth)\
**Post date:** [November 2, 2017, 4:55am UTC](https://forums.powershell.org/t/modify-gpo-settings-via-powershell/9633/3 "2017-11-02T04:55:21Z")

</div>

Hello.  
Maybe this:

```
function CtrlAltDel
{
    Param(
        [switch]$DisableLockWorkstation,
        [switch]$EnableLockWorkstation,
        [switch]$DisableTaskMgr,
        [switch]$EnableTaskMgr
    )

    $Path = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\System'

    if ($DisableLockWorkstation -and $EnableLockWorkstation)
    {
        Write-Output 'Specify DisableLockWorkstation OR EnableLockWorkstation'
        return
    }

    if ($DisableTaskMgr -and $EnableTaskMgr)
    {
        Write-Output 'Specify DisableTaskMgr OR EnableTaskMgr'
        return
    }
    
    if ($DisableLockWorkstation)
    {
        if (-not (Test-Path -Path $Path))
        {
            New-Item -Path $Path | Out-Null
        }
        New-ItemProperty -Path $Path -Name DisableLockWorkstation -Value 1 -Force -ErrorAction SilentlyContinue | Out-Null
    }

    if ($EnableLockWorkstation)
    {
        Remove-ItemProperty -Path $Path -Name DisableLockWorkstation -ErrorAction SilentlyContinue
    }

    if ($DisableTaskMgr)
    {
        if (-not (Test-Path -Path $Path))
        {
            New-Item -Path $Path | Out-Null
        }
        New-ItemProperty -Path $Path -Name DisableTaskMgr -Value 1 -Force -ErrorAction SilentlyContinue | Out-Null
    }

    if ($EnableTaskMgr)
    {
        Remove-ItemProperty -Path $Path -Name DisableTaskMgr -ErrorAction SilentlyContinue
    }
}
```

---

<div class="post-metadata">

**Author:** ![js2010](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@js2010](https://forums.powershell.org/u/js2010)\
**Post date:** [November 2, 2017, 7:12am UTC](https://forums.powershell.org/t/modify-gpo-settings-via-powershell/9633/4 "2017-11-02T07:12:55Z")

</div>

I like the PolicyFileEditor module: [http://brandonpadgett.com/powershell/Local-gpo-powershell/](http://brandonpadgett.com/powershell/Local-gpo-powershell/)

---

<div class="post-metadata">

**Author:** ![ivill](https://avatars.discourse-cdn.com/v4/letter/i/7993a0/32.png) [@ivill](https://forums.powershell.org/u/ivill)\
**Post date:** [November 2, 2017, 7:41pm UTC](https://forums.powershell.org/t/modify-gpo-settings-via-powershell/9633/5 "2017-11-02T19:41:08Z")

</div>

Hi, Thanks for your reply, it seems not working, after a splash powershell window, i checked the registry, nothing was changed

---

<div class="post-metadata">

**Author:** ![ivill](https://avatars.discourse-cdn.com/v4/letter/i/7993a0/32.png) [@ivill](https://forums.powershell.org/u/ivill)\
**Post date:** [November 2, 2017, 7:44pm UTC](https://forums.powershell.org/t/modify-gpo-settings-via-powershell/9633/6 "2017-11-02T19:44:13Z")

</div>

Hi, thanks for your reply, i installed the PolicyFileEditor, somehow i’m trying to figure it out how to make it working… could you make an example for me? like how to turn off taskmgr

---

<div class="post-metadata">

**Author:** ![seth](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/seth/32/412_2.png) [@seth](https://forums.powershell.org/u/seth)\
**Post date:** [November 3, 2017, 4:26am UTC](https://forums.powershell.org/t/modify-gpo-settings-via-powershell/9633/7 "2017-11-03T04:26:54Z")

</div>

It’s a function definition.  
After you define it in the session, you can use following commands:

```
CtrlAltDel -DisableLockWorkstation -DisableTaskMgr
CtrlAltDel -EnableLockWorkstation -EnableTaskMgr
```

Also you can add any of there lines after function definition and use it like s script.

---

<div class="post-metadata">

**Author:** ![js2010](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@js2010](https://forums.powershell.org/u/js2010)\
**Post date:** [November 3, 2017, 9:28am UTC](https://forums.powershell.org/t/modify-gpo-settings-via-powershell/9633/8 "2017-11-03T09:28:02Z")

</div>

That blog teaches you. Do it in gpedit.msc, then you can export it to an xml with that module, or display it on the screen and see what the registry setting is.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:37pm UTC](https://forums.powershell.org/t/modify-gpo-settings-via-powershell/9633/9 "2024-05-16T20:37:16Z")

</div>


