-
-
Save irwins/498f44e6eac1795f5523 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Author: I.C.A. Strachan | |
Version: | |
Version History: | |
Purpose: Pester script to validate Group Polcies status and Link on Domain,Sites and OUs | |
#> | |
[CmdletBinding()] | |
Param() | |
Describe 'Group Policies Scope of Management validation' { | |
BeforeAll { | |
#region Get GPOs Producution Validation set | |
$gpoValidationSet = @' | |
DisplayName,DistinguishedName,GPOStatus,BlockInheritance,LinkEnabled,Enforced,LinkOrderNr | |
Default Domain Policy,"DC=pshirwin,DC=local",AllSettingsEnabled,FALSE,TRUE,FALSE,1 | |
Default Domain Controllers Policy,"OU=Domain Controllers,DC=pshirwin,DC=local",AllSettingsEnabled,FALSE,TRUE,FALSE,1 | |
WinRM Listeners,"OU=Servers,DC=pshirwin,DC=local",AllSettingsEnabled,FALSE,TRUE,FALSE,1 | |
RemoteDesktop,"OU=Servers,DC=pshirwin,DC=local",AllSettingsEnabled,FALSE,TRUE,FALSE,2 | |
Firewall,"OU=Servers,DC=pshirwin,DC=local",UserSettingsDisabled,FALSE,TRUE,TRUE,3 | |
'@ | ConvertFrom-Csv -Delimiter ',' | |
#endregion | |
#Dot source Function Get-GPOsSOM.ps1 | |
. $PSScriptRoot\Get-GPOsSOM.ps1 | |
#Create hashtable for lookup | |
$lookupGPOInReport = Get-GPOsSOM | Group-Object -AsHashTable -Property 'DisplayName' | |
} | |
It 'GPOs Scope of Managment has been retrieved' { | |
$lookupGPOInReport | should not BeNullOrEmpty | |
} | |
It 'GPO validation set has been retrieved' { | |
$gpoValidationSet | Should not BeNullOrEmpty | |
} | |
foreach($set in $gpoValidationSet){ | |
Context "GPO: $($set.DisplayName)" { | |
it "GPO $($set.DisplayName) exists" { | |
$lookupGPOInReport.$($set.DisplayName) | Should Not BeNullOrEmpty | |
} | |
it "GPO is linked to $($set.DistinguishedName)"{ | |
$lookupGPOInReport.$($set.DisplayName).DistinguishedName | Should be $set.DistinguishedName | |
} | |
it "BlockInheritance: $($set.BlockInheritance)" { | |
$lookupGPOInReport.$($set.DisplayName).BlockInheritance | Should be $set.BlockInheritance | |
} | |
it "LinkEnabled: $($set.LinkEnabled)" { | |
$lookupGPOInReport.$($set.DisplayName).LinkEnabled | Should be $set.LinkEnabled | |
} | |
it "Group policy Enforced: $($set.Enforced)" { | |
$lookupGPOInReport.$($set.DisplayName).Enforced | Should be $set.Enforced | |
} | |
it "Group policy LinkOrder nr: $($set.LinkOrderNr)" { | |
$lookupGPOInReport.$($set.DisplayName).LinkOrderNr | Should be $set.LinkOrderNr | |
} | |
it "Group policy status: $($set.GPOStatus)" { | |
$lookupGPOInReport.$($set.DisplayName).GPOStatus | Should be $set.GPOStatus | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment