Add errorhandling;Fix OU
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
9dfb51db18
commit
ed69de5d27
@ -1,7 +1,7 @@
|
|||||||
Name: 'COMP: Restrict Internet Communication'
|
Name: 'COMP: Restrict Internet Communication'
|
||||||
Type: Object
|
Type: Object
|
||||||
LinkedOUs:
|
LinkedOUs:
|
||||||
- OU=Servers
|
- OU=Servers,OU=Computer accounts
|
||||||
WMIFilters: []
|
WMIFilters: []
|
||||||
RegistryEntries:
|
RegistryEntries:
|
||||||
- Key: HKLM\Software\Policies\Microsoft\InternetManagement
|
- Key: HKLM\Software\Policies\Microsoft\InternetManagement
|
||||||
|
@ -175,16 +175,22 @@ If (@('primary','standalone') -contains $Parameter['deployment.type']) {
|
|||||||
|
|
||||||
ForEach ($OU in $GroupPolicy.LinkedOUs) {
|
ForEach ($OU in $GroupPolicy.LinkedOUs) {
|
||||||
If (Test-Path "AD:\$($OU + (',{0}' -f (Get-ADRootDSE).rootDomainNamingContext))") {
|
If (Test-Path "AD:\$($OU + (',{0}' -f (Get-ADRootDSE).rootDomainNamingContext))") {
|
||||||
|
Try {
|
||||||
Write-Host "Linking policy '$($NewGPO.DisplayName)' to OU '$($OU)' ..."
|
Write-Host "Linking policy '$($NewGPO.DisplayName)' to OU '$($OU)' ..."
|
||||||
$NewGPLinkSplat = @{
|
$NewGPLinkSplat = @{
|
||||||
Name = $NewGPO.DisplayName
|
Name = $NewGPO.DisplayName
|
||||||
Target = $OU + (',{0}' -f (Get-ADRootDSE).rootDomainNamingContext)
|
Target = $OU + (',{0}' -f (Get-ADRootDSE).rootDomainNamingContext)
|
||||||
# ErrorAction = 'SilentlyContinue'
|
|
||||||
}
|
}
|
||||||
New-GPLink @NewGPLinkSplat | Out-Null
|
New-GPLink @NewGPLinkSplat | Out-Null
|
||||||
}
|
}
|
||||||
|
Catch {
|
||||||
|
$ParseErrors += "Could not link GPO '$($NewGPO.DisplayName)' to OU '$($OU)'"
|
||||||
|
Continue
|
||||||
|
}
|
||||||
|
}
|
||||||
Else {
|
Else {
|
||||||
Throw "Path not accessible: 'AD:\$($OU + (',{0}' -f (Get-ADRootDSE).rootDomainNamingContext))"
|
$ParseErrors += "Path not accessible (referred to by '$($NewGPO.DisplayName)'): 'AD:\$($OU + (',{0}' -f (Get-ADRootDSE).rootDomainNamingContext))'"
|
||||||
|
Continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user