This commit is contained in:
2023-11-29 17:01:08 +01:00
parent ad3ec73749
commit a4fa9cb5ab
73 changed files with 774 additions and 0 deletions

31
Link-GpoToOU.ps1 Normal file
View File

@@ -0,0 +1,31 @@
<#
.EXAMPLE
$GpoLinks = @(
$(New-Object PSObject -Property @{ Name = "POLICYNAME" ; OU = "OUPATH"; Order = 1; LinkEnabled = 'YES'}),
)
.\Link-GpoToOU.ps1 -GpoLinks $GpoLinks -Verbose
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $True)][PSObject] $GpoLinks
)
Import-Module ActiveDirectory
$DC = (Get-ADDomain).DistinguishedName
$GpoLinks | foreach-Object {
$name = $_.Name
$OU = $_.ou
$order = $_.Order
$LinkEnabled = $_.LinkEnabled
if ($OU -eq "") {
$ouPath = $DC
}
else {
$ouPath = "$OU,$DC"
}
Write-Verbose "Linking GPO '$name' into OU '$ouPath'"
New-GPLink -Name $name -Target $ouPath -LinkEnabled $LinkEnabled -Order $order
}