Turn off User or Computer settings of a GPO

Supply the FQDN(Fully Qualified Domain Name) and GUID of GPO as parameters.

  • To enable computer settings and disable user settings execute the below script as it is.
  • To disable computer settings and enable user settings edit the script by replacing$objGpo.SetComputerEnabled($true)$objGpo.SetUserEnabled($false)
    with
    $objGpo.SetComputerEnabled($false)
    $objGpo.SetUserEnabled($true)
    and execute.

Script

<#
.SYNOPSIS
This script can be used to enable computer settings and disable user settings of a GPO.
.DESCRIPTION
This script can be used to enable computer settings and disable user settings of a GPO.
.EXAMPLE
C:\PS> C:\Script\Turn_Off_User_Or_Computer_Settings.ps1 mslync10.com 31B2F340-016D-11D2-945F-00C04FB984F9
Enables computer settings and disables user settings of a DefaultDomainPolicy.
#>

param( [String]$Domain_FQDN , [String]$GPO_GUID )
$gpm = New-Object -ComObject GPMgmt.GPM
#Creates and returns a GPMConstants object that allows you to retrieve the value of multiple Group Policy Management Console (GPMC) constants.

$gpmConstants = $gpm.GetConstants()
$objDomain = $gpm.GetDomain(“$Domain_FQDN”, “”, $gpmConstants.UseAnyDC)
#Identify the GPO uniquely by using its GUID.

$objGpo = $objDomain.GetGPO(“{$GPO_GUID}”)
#set true to enable and false to disabe the user or computer settings.

$objGpo.SetComputerEnabled($true)
$objGpo.SetUserEnabled($false)

 

Output
Turnoffusercomputersettings

Leave a Reply