Skip to content

Instantly share code, notes, and snippets.

@leeramsay
Last active September 15, 2023 06:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leeramsay/66e07cbe1f6173d010bd1c98661a3425 to your computer and use it in GitHub Desktop.
Save leeramsay/66e07cbe1f6173d010bd1c98661a3425 to your computer and use it in GitHub Desktop.
Simple Powershell to add computers, for my own poor memory, to add a computer, or multiples, to a group policy object under the "security filtering" section.

Simple Powershell to add computers, for my own poor memory, to add a computer, or multiples, to a group policy object under the "security filtering" section.

#To add:
# - Powershell Min version
# - Ad tools detection?
# - Instructions how to undo/remove computer/computers
# - Ability to run interactively, instead of copy/pasta
#Variables
$Domain = "example.domain"
$GPO_Name = "example GPO object"
$Computers_To_Add = "Example_PC1","Example_PC2","Example_PC3"
$Computer_To_Add = "Example_PC4"
#Business
$gpo = get-gpo -Domain $Domain -Name $GPO_Name
#Add single PC to GPO Security Filter
$gpo | Set-GPPermissions -domain $Domain -PermissionLevel gpoapply -TargetType computer -TargetName $Computer_To_Add
#Add multiple computers to GPO Security Filter
foreach ($Computer in $Computers_To_Add) { $gpo | Set-GPPermissions -domain $Domain -PermissionLevel gpoapply -TargetType computer -TargetName $Computer }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment