#Alan Kaplan #10-16-17 #ver 1.1 fixed pick by nameadds default sort of displayname #requires -module GroupPolicy #requires -version 3 Add-Type -assemblyname Microsoft.visualBasic function Edit-GPO([guid]$guid, [string]$domain){ #Based on #http://blog.backslasher.net/opening-group-policy-management-editor-from-the-command-line.html $odomain = Get-ADDomain $domain # Operate on PDC to help consistency $server=$odomain.PDCEmulator $PoliciesPath=("CN=Policies,"+$odomain.SystemsContainer) $GPPath= "LDAP://{0}/CN={{{1}}},{2}" -f $server,$guid,$PoliciesPath gpme.msc "/GPOBJECT:`"$GPPath`"" } Function Get-GPOList{ Write-Progress "Reading the list of group policy objects in $domain. Please wait ...." $list = Get-GPO -All -server $domain -Domain $domain | sort displayName | Select-Object -Property DisplayName,Owner, GPOStatus,ID #-OutVariable list Write-Progress "Done" -Completed $selected = $List |Out-GridView -OutputMode Single -Title "Select GPO to edit, then click OK" if ($selected) { ($selected).id.Guid.ToString() } Else { '' } } $domain = [Microsoft.VisualBasic.Interaction]::InputBox("Edit a GPO in what domain?", "Domain", "$env:userdnsdomain") if ($domain.Length -eq 0) {Exit} #message for Welcome menu $msg = "This script lets you directly launch the Group Policy Editor.`n Enter a GPO GUID, DisplayName, or enter `"List`" pick the GPO from a list." $strInput = [Microsoft.VisualBasic.Interaction]::InputBox($msg, "Choose Action") if ($strInput.Length -eq 0) {Exit} $strInput = $strInput.Trim() if ($strInput -match 'list') { $guid = Get-GPOList } ELSE { #Logic to check whether the input is a GUID or string $ok = [guid]::Empty $bIsGuid = [guid]::TryParse($strInput,[ref]$ok) if ($bIsGuid) { $guid = ([guid]::Parse($strInput)).guid }ELSE{ Try{ $guid = (Get-GPO -Name $strInput -Domain $domain -ErrorAction stop).id } Catch { Write-warning "Could not find `"$strInput`" in $domain, getting GPO list instead." $Guid = Get-GPOList } } } if ($guid.Length -ne 0){ Edit-GPO $guid $domain }