AzStackHciExternalActiveDirectory/AzStackHci.ExternalActiveDirectory.Tests.psm1

Import-LocalizedData -BindingVariable lcAdTxt -FileName AzStackHci.ExternalActiveDirectory.Strings.psd1

class HealthModel
{
    # Attributes for Azure Monitor schema
    [string]$Name #Name of the individual test/rule/alert that was executed. Unique, not exposed to the customer.
    [string]$Title #User-facing name; one or more sentences indicating the direct issue.
    [string]$Severity #Severity of the result (Critical, Warning, Informational, Hidden) – this answers how important the result is. Critical is the only update-blocking severity.
    [string]$Description #Detailed overview of the issue and what impact the issue has on the stamp.
    [psobject]$Tags #Key-value pairs that allow grouping/filtering individual tests. For example, "Group": "ReadinessChecks", "UpdateType": "ClusterAware"
    [string]$Status #The status of the check running (i.e. Failed, Succeeded, In Progress) – this answers whether the check ran, and passed or failed.
    [string]$Remediation #Set of steps that can be taken to resolve the issue found.
    [string]$TargetResourceID #The unique identifier for the affected resource (such as a node or drive).
    [string]$TargetResourceName #The name of the affected resource.
    [string]$TargetResourceType #The type of resource being referred to (well-known set of nouns in infrastructure, aligning with Monitoring).
    [datetime]$Timestamp #The Time in which the HealthCheck was called.
    [psobject[]]$AdditionalData #Property bag of key value pairs for additional information.
    [string]$HealthCheckSource #The name of the services called for the HealthCheck (I.E. Test-AzureStack, Test-Cluster).
}

class OrganizationalUnitTestResult : HealthModel {}

class ExternalADTest
{
    [string]$TestName
    [scriptblock]$ExecutionBlock
}

$ExternalAdTestInitializors = @(
)

$ExternalAdTests = @(
    <# Can't execute this test during deployment as Get-KdsRootKey will try to access the DVM KDS and come up with an empty value
    (New-Object -Type ExternalADTest -Property @{
        TestName = "KdsRootKeyExists"
        ExecutionBlock = {
            Param ([hashtable]$testContext)
 
            $dcName = $null
            $KdsRootKey = $null
            $accessDenied = $false
            try
            {
                # Must use the server name and credentials that are passed in if they exist
                $getDomainControllerParams = @{}
                if ($testContext["AdServer"] -and $testContext["AdCredentials"])
                {
                    $getDomainControllerParams += @{Server = $testContext["AdServer"]}
                    $getDomainControllerParams += @{Credential = $testContext["AdCredentials"]}
                }
                else
                {
                    $getDomainControllerParams += @{DomainName = $testContext["DomainFQDN"]}
                    $getDomainControllerParams += @{MinimumDirectoryServiceVersion = "Windows2012"}
                    $getDomainControllerParams += @{NextClosestSite = $true}
                    $getDomainControllerParams += @{Discover = $true}
                }
                $adDomainController = Get-ADDomainController @getDomainControllerParams
                $dcName = "$($adDomainController.Name).$($adDomainController.Domain)"
 
                # This cmdlet doesn't take a server name or credentials, so it may fail when not run from a domain-joined machine
                $KdsRootKey = $null
                try
                {
                    $KdsRootKey = Get-KdsRootKey
                }
                catch
                {
                    $accessDenied = $true
                }
 
                if($KdsRootKey)
                {
                    # make sure it is effective at least 10 hours ago
                    if(((Get-Date) - $KdsRootKey.EffectiveTime).TotalHours -lt 10)
                    {
                        $KdsRootKey = $null
                    }
                }
            }
            catch {}
 
            $rootKeyStatus = if ($dcName -and $KdsRootKey) { 'Succeeded' } else { 'Failed' }
            if ($accessDenied)
            {
                $rootKeyStatus = 'Skipped'
            }
            return New-Object PSObject -Property @{
                Resource = "KdsRootKey"
                Status = $rootKeyStatus
                TimeStamp = [datetime]::UtcNow
                Source = $ENV:COMPUTERNAME
                Detail = $testContext["LcAdTxt"].KdsRootKeyMissingRemediation
            }
        }
    }),
    #>

    (New-Object -Type ExternalADTest -Property @{
        TestName = "RequiredOrgUnitsExist"
        ExecutionBlock = {
            Param ([hashtable]$testContext)

            $serverParams = @{}
            if ($testContext["AdServer"])
            {
                $serverParams += @{Server = $testContext["AdServer"]}
            }
            if ($testContext["AdCredentials"])
            {
                $serverParams += @{Credential = $testContext["AdCredentials"]}
            }

            $requiredOUs = @($testContext["ADOUPath"], $testContext["ComputersADOUPath"], $testContext["UsersADOUPath"])

            Log-Info -Message (" Checking for the existance of OUs: {0}" -f ($requiredOUs -join ", ")) -Type Info -Function "RequiredOrgUnitsExist"

            $results = $requiredOUs | ForEach-Object {
                $resultingOU = $null

                try {
                    $resultingOU = Get-ADOrganizationalUnit -Identity $_ -ErrorAction SilentlyContinue @serverParams
                }
                catch {
                }

                return New-Object PSObject -Property @{
                    Resource    = $_
                    Status      = if ($resultingOU) { 'Succeeded' } else { 'Failed' }
                    TimeStamp   = [datetime]::UtcNow
                    Source      = $ENV:COMPUTERNAME
                    Detail = ($testContext["LcAdTxt"].MissingOURemediation -f $_)
                }
            }

            return $results
        }
    }),
    (New-Object -Type ExternalADTest -Property @{
        TestName = "PhysicalMachineObjectsExist"
        ExecutionBlock = {
            Param ([hashtable]$testContext)

            $serverParams = @{}
            if ($TestContext["AdServer"])
            {
                $serverParams += @{Server = $TestContext["AdServer"]}
            }
            if ($TestContext["AdCredentials"])
            {
                $serverParams += @{Credential = $TestContext["AdCredentials"]}
            }

            $computerAdOuPath = $testContext["ComputersADOUPath"]
            $domainFQDN = $testContext["DomainFQDN"]

            $physicalHostsSetting = @($testContext["PhysicalMachineNames"] | Where-Object { -not [string]::IsNullOrEmpty($_) })

            Log-Info -Message (" Validating settings for physical hosts: {0}" -f ($physicalHostsSetting -join ", ")) -Type Info -Function "PhysicalMachineObjectsExist"

            $allComputerObjects = Get-ADComputer -Filter "*" @serverParams
            $foundPhysicalHosts = @($allComputerObjects | Where-Object {$_.Name -in $physicalHostsSetting})
            $missingPhysicalHostEntries = @($physicalHostsSetting | Where-Object {$_ -notin $allComputerObjects.Name})

            Log-Info -Message (" Found {0} entries in AD : {1}" -f $foundPhysicalHosts.Count,($foundPhysicalHosts.Name -join ", ")) -Type Info -Function "PhysicalMachineObjectsExist"

            $physicalHostsWithBadDnsName = $($foundPhysicalHosts | Where-Object { $_.DNSHostName -ne "$($_.Name).$domainFQDN" })
            $physicalHostsWithBadSAMAcct = $($foundPhysicalHosts | Where-Object { $_.SAMAccountName -ne "$($_.Name)$" })

            Log-Info -Message (" Found {0} entries with invalid DNS names: {1}" -f $physicalHostsWithBadDnsName.Count,(($physicalHostsWithBadDnsName | Select-Object -Property DNSHostName) -join ", ")) -Type Info -Function "PhysicalMachineObjectsExist"
            Log-Info -Message (" Found {0} entries with invalid SAM account names: {1}" -f $physicalHostsWithBadSAMAcct.Count,(($physicalHostsWithBadSAMAcct | Select-Object -Property SAMAccountName) -join ", ")) -Type Info -Function "PhysicalMachineObjectsExist"

            $results = @()

            $hasComputerEntries = ($foundPhysicalHosts -and $foundPhysicalHosts.Count -eq $physicalHostsSetting.Count)
            $allEntriesHaveCorrectDnsNames = (-not $physicalHostsWithBadDnsName -or $physicalHostsWithBadDnsName.Count -eq 0)
            $allEntriesHaveCorrectSamAcct = (-not $physicalHostsWithBadSAMAcct -or $physicalHostsWithBadSAMAcct.Count -eq 0)

            $results += New-Object PSObject -Property @{
                Resource    = "PhysicalHostAdComputerEntries"
                Status      = if ($hasComputerEntries) { 'Succeeded' } else { 'Failed' }
                TimeStamp   = [datetime]::UtcNow
                Source      = $ENV:COMPUTERNAME
                Detail = ($testContext["LcAdTxt"].HostsMissingRemediation -f ($missingPhysicalHostEntries -join ", "),$computerAdOuPath)
            }
            $results += New-Object PSObject -Property @{
                Resource    = "PhysicalHostAdComputerDnsNames"
                Status      = if ($allEntriesHaveCorrectDnsNames) { 'Succeeded' } else { 'Failed' }
                TimeStamp   = [datetime]::UtcNow
                Source      = $ENV:COMPUTERNAME
                Detail = ($testContext["LcAdTxt"].HostsWithIncorrectDnsNameRemediation -f ($physicalHostsWithBadDnsName.Name -join ", "))
            }
            $results += New-Object PSObject -Property @{
                Resource    = "PhysicalHostAdComputerSamAccounts"
                Status      = if ($allEntriesHaveCorrectSamAcct) { 'Succeeded' } else { 'Failed' }
                TimeStamp   = [datetime]::UtcNow
                Source      = $ENV:COMPUTERNAME
                Detail = ($testContext["LcAdTxt"].HostsWithIncorrectSamAcctRemediation -f ($physicalHostsWithBadDnsName.Name -join ", "))
            }

            return $results
        }
    }),
    (New-Object -Type ExternalADTest -Property @{
        TestName = "ClusterExistsWithRequiredAcl"
        ExecutionBlock = {
            Param ([hashtable]$testContext)

            $serverParams = @{}
            if ($TestContext["AdServer"])
            {
                $serverParams += @{Server = $TestContext["AdServer"]}
            }
            if ($TestContext["AdCredentials"])
            {
                $serverParams += @{Credential = $TestContext["AdCredentials"]}
            }

            $createChildAce = $null
            $readPropertyAce = $null
            $computersAdOuPath = $testContext["ComputersADOUPath"]
            $clusterName = $testContext["ClusterName"]

            Log-Info -Message (" Searching for '{0}' entry in OU '{1}'" -f $clusterName,$computersAdOuPath) -Type Info -Function "ClusterExistsWithRequiredAcl"

            try {
                $clusterComputerEntry = Get-ADComputer -SearchBase $computersAdOuPath -Filter "Name -eq '$clusterName'" @serverParams
            }
            catch {
                Log-Info -Message (" Failed to find '{0}' entry in OU '{1}'. Inner exception: {2}" -f $clusterName,$computersAdOuPath,$_) -Type Error -Function "ClusterExistsWithRequiredAcl"
            }

            if ($clusterComputerEntry)
            {
                $clusterSID = $clusterComputerEntry.SID
                Log-Info -Message (" Found entry, SID: {0}" -f $clusterSID) -Type Info -Function "ClusterExistsWithRequiredAcl"

                # The AD module SHOULD install a drive that we can use to get ACLs. However, sometimes it isn't properly registered
                # especially if we just installed it. So verify that it's usable
                $adDriveName = "AD"
                $tempDriveName = "hciad"
                $adDriveObject = $null

                $adProvider = Get-PSProvider -PSProvider ActiveDirectory
                if ($adProvider.Drives.Count -gt 0)
                {
                    $adDriveObject = $adProvider.Drives | Where-Object {$_.Name -eq $adDriveName -or $_.Name -eq $tempDriveName}
                }

                if (-not $adDriveObject)
                {
                    # Add a new drive
                    $adDriveObject = New-PSDrive -Name $tempDriveName -PSProvider ActiveDirectory -Root '' @serverParams
                }

                $adDriveName = $adDriveObject.Name

                try
                {
                    $ouPath = ("{0}:\{1}" -f $adDriveName,$computersAdOuPath)
                    $ouAcl = Get-Acl $ouPath
                }
                catch
                {
                    throw ("Can't get acls from {0}. Inner exception: {1}" -f $ouPath,$_)
                }
                finally {
                    # best effort cleanup if we had added the temp drive
                    try
                    {
                        if ($adDriveName -eq $tempDriveName)
                        {
                            $adDriveObject | Remove-PSDrive
                        }
                    }
                    catch {}
                }

                # must specify the type to retrieve -- need to get something comparable to the clusterSID
                $accessRules = $ouAcl.GetAccessRules($true, $true, $clusterSID.GetType())

                # Check that the CreateChild ACE has been added
                $createChildAce = $accessRules | Where-Object { `
                    $_.IdentityReference -eq $clusterSID -and `
                    $_.ActiveDirectoryRights -bor [System.DirectoryServices.ActiveDirectoryRights]::CreateChild -and `
                    $_.AccessControlType -eq [System.Security.AccessControl.AccessControlType]::Allow -and `
                    $_.ObjectType -eq ([System.Guid]::New('bf967a86-0de6-11d0-a285-00aa003049e2')) -and
                    $_.InheritanceType -eq [System.DirectoryServices.ActiveDirectorySecurityInheritance]::All
                }
                $readPropertyAce = $accessRules | Where-Object { `
                    $_.IdentityReference -eq $clusterSID -and `
                    $_.ActiveDirectoryRights -bor [System.DirectoryServices.ActiveDirectoryRights]::ReadProperty -and `
                    $_.AccessControlType -eq [System.Security.AccessControl.AccessControlType]::Allow -and `
                    $_.ObjectType -eq [System.Guid]::Empty -and
                    $_.InheritanceType -eq [System.DirectoryServices.ActiveDirectorySecurityInheritance]::All
                }

                Log-Info -Message (" Found CreateChild ACE: {0}" -f ([bool]$createChildAce)) -Type Info -Function "ClusterExistsWithRequiredAcl"
                Log-Info -Message (" Found ReadProperty ACE: {0}" -f ([bool]$readPropertyAce)) -Type Info -Function "ClusterExistsWithRequiredAcl"
            }

            return New-Object PSObject -Property @{
                Resource    = "ClusterAcls"
                Status      = if ($createChildAce -and $readPropertyAce) { 'Succeeded' } else { 'Failed' }
                TimeStamp   = [datetime]::UtcNow
                Source      = $ENV:COMPUTERNAME
                Detail = ($testContext["LcAdTxt"].ClusterAclsMissingRemediation -f $computersAdOuPath)
            }
        }
    }),
    (New-Object -Type ExternalADTest -Property @{
        TestName = "SecurityGroupsExist"
        ExecutionBlock = {
            Param ([hashtable]$testContext)

            $serverParams = @{}
            if ($TestContext["AdServer"])
            {
                $serverParams += @{Server = $TestContext["AdServer"]}
            }
            if ($TestContext["AdCredentials"])
            {
                $serverParams += @{Credential = $TestContext["AdCredentials"]}
            }

            $securityGroups = @(
                "$($testContext["NamingPrefix"])-Sto-SG",
                "$($testContext["NamingPrefix"])-FsAcl-InfraSG",
                "$($testContext["NamingPrefix"])-FsAcl-AcsSG",
                "$($testContext["NamingPrefix"])-FsAcl-SqlSG",
                "$($testContext["NamingPrefix"])-Fab-SrvSG",
                "$($testContext["NamingPrefix"])-HA-SrvSG",
                "$($testContext["NamingPrefix"])-EceSG",
                "$($testContext["NamingPrefix"])-BM-ECESG",
                "$($testContext["NamingPrefix"])-HA-R-SrvSG",
                "$($testContext["NamingPrefix"])-SB-Jea-LC-VmSG",
                "$($testContext["NamingPrefix"])-Hc-Rs-SrvSG",
                "$($testContext["NamingPrefix"])-Agw-SrvSG",
                "$($testContext["NamingPrefix"])-Hrp-HssSG",
                "$($testContext["NamingPrefix"])-IH-HsSG",
                "$($testContext["NamingPrefix"])-OpsAdmin",
                "$($testContext["NamingPrefix"])-SB-Jea-MG-VmSG",
                "$($testContext["NamingPrefix"])-FsAcl-PublicSG",
                "$($testContext["NamingPrefix"])-IH-MsSG"
            )

            $usersOuPath = $testContext["UsersADOUPath"]

            $missingSecurityGroups = @()

            try
            {
                # Look up all the required security groups and identify any that are missing
                foreach ($securityGroup in $securityGroups)
                {
                    $adGroup = Get-AdGroup -SearchBase $usersOuPath -Filter { Name -eq $securityGroup } @serverParams

                    if (-not $adGroup)
                    {
                        $missingSecurityGroups += $securityGroup
                    }
                }
            }
            catch {}

            $physicalHosts = $()

            # get the list of physical hosts
            foreach ($host in $testContext["PhysicalMachineNames"])
            {
                $physicalHosts += ${Name=$host; Object=(Get-ADComputer -Identity $_ @serverParams); MissingSGs=@()}
            }

            # Now check that the physical machines have been added to the required SGs
            $physicalMachineSecurityGroups = @("$($testContext["NamingPrefix"])-Sto-SG")

            foreach ($physicalHost in $physicalHosts)
            {
                foreach ($physicalMachineSecurityGroup in $physicalMachineSecurityGroups)
                {
                    $isMember = $false
                    try
                    {
                        $groupObject = Get-ADGroup -SearchBase $usersOuPath -Filter {Name -eq $physicalMachineSecurityGroup} @serverParams

                        if ($groupObject)
                        {
                            $isMember = Get-ADGroupMember -Identity $groupObject @serverParams | Where-Object {$_.SID -eq $($physicalHost.Object.SID)}
                        }
                    }
                    catch {}

                    if (-not $isMember)
                    {
                        $physicalHost.MissingSGs += $physicalMachineSecurityGroup
                    }
                }
            }

            $results = @()

            $results += New-Object PSObject -Property @{
                Resource    = "SecurityGroups"
                Status      = if ($missingSecurityGroups.Count -eq 0) { 'Succeeded' } else { 'Failed' }
                TimeStamp   = [datetime]::UtcNow
                Source      = $ENV:COMPUTERNAME
                Detail = ($testContext["LcAdTxt"].SecurityGroupsMissingRemediation -f ($missingSecurityGroups -join ', '))
            }

            foreach ($physicalHost in $physicalHosts)
            {
                $missingSecurityGroupMemberships = $physicalHost.MissingSGs

                $results += New-Object PSObject -Property @{
                    Resource    = "SecurityGroupMembership_$($physicalHost.Name)"
                    Status      = if ($missingSecurityGroupMemberships.Count -eq 0) { 'Succeeded' } else { 'Failed' }
                    TimeStamp   = [datetime]::UtcNow
                    Source      = $ENV:COMPUTERNAME
                    Detail = ($testContext["LcAdTxt"].HostSecurityGroupsMissingRemediation -f $physcialHost.Name,($missingSecurityGroupMemberships -join ', '))
                }
            }

            return $results
        }
    }),
    (New-Object -Type ExternalADTest -Property @{
        TestName = "gMSAsExist"
        ExecutionBlock = {
            Param ([hashtable]$testContext)

            $usersOuPath = $testContext["UsersADOUPath"]

            $serverParams = @{}
            if ($TestContext["AdServer"])
            {
                $serverParams += @{Server = $TestContext["AdServer"]}
            }
            if ($TestContext["AdCredentials"])
            {
                $serverParams += @{Credential = $TestContext["AdCredentials"]}
            }

            $gmsaAccounts = @(
                [pscustomobject]@{ GmsaName="$($testContext["NamingPrefix"])-BM-ECE";
                                     PrincipalsAllowedToRetrieveManagedPassword= @("$($testContext["NamingPrefix"])-Sto-SG");
                                     ServicePrincipalName=@("$($testContext["NamingPrefix"])/ae3299a9-3e87-4186-bd99-c43c9ae6a571");
                                     MemberOf=@("$($testContext["NamingPrefix"])-FsAcl-SqlSG", "$($testContext["NamingPrefix"])-Fab-SrvSG", "$($testContext["NamingPrefix"])-HA-SrvSG", "$($testContext["NamingPrefix"])-EceSG", "$($testContext["NamingPrefix"])-BM-ECESG", "$($testContext["NamingPrefix"])-FsAcl-InfraSG")},

                [pscustomobject]@{ GmsaName="$($testContext["NamingPrefix"])-BM-ALM";
                                     PrincipalsAllowedToRetrieveManagedPassword= @("$($testContext["NamingPrefix"])-Sto-SG");
                                     ServicePrincipalName=@();
                                     MemberOf=@("$($testContext["NamingPrefix"])-FsAcl-InfraSG")},

                [pscustomobject]@{ GmsaName="$($testContext["NamingPrefix"])-BM-FCA";
                                     PrincipalsAllowedToRetrieveManagedPassword= @("$($testContext["NamingPrefix"])-Sto-SG");
                                     ServicePrincipalName=@();
                                     MemberOf=@("$($testContext["NamingPrefix"])-FsAcl-InfraSG")},

                [pscustomobject]@{ GmsaName="$($testContext["NamingPrefix"])-BM-FRA";
                                     PrincipalsAllowedToRetrieveManagedPassword= @("$($testContext["NamingPrefix"])-Sto-SG");
                                     ServicePrincipalName=@();
                                     MemberOf=@("$($testContext["NamingPrefix"])-FsAcl-InfraSG")},

                [pscustomobject]@{ GmsaName="$($testContext["NamingPrefix"])-BM-TCA";
                                     PrincipalsAllowedToRetrieveManagedPassword= @("$($testContext["NamingPrefix"])-Sto-SG");
                                     ServicePrincipalName=@();
                                     MemberOf=@("$($testContext["NamingPrefix"])-FsAcl-InfraSG")},

                [pscustomobject]@{ GmsaName="$($testContext["NamingPrefix"])-BM-HA";
                                     PrincipalsAllowedToRetrieveManagedPassword= @("$($testContext["NamingPrefix"])-Sto-SG");
                                     ServicePrincipalName=@("$($testContext["NamingPrefix"])/PhysicalNode/1b4dde6b-7ea8-407a-8c9e-f86e8b97fd1c");
                                     MemberOf=@("$($testContext["NamingPrefix"])-FsAcl-InfraSG", "$($testContext["NamingPrefix"])-HA-R-SrvSG")},

                [pscustomobject]@{ GmsaName="$($testContext["NamingPrefix"])-SB-LC";
                                     PrincipalsAllowedToRetrieveManagedPassword= @("$($testContext["NamingPrefix"])-Sto-SG", "$($testContext["NamingPrefix"])-SB-Jea-LC-VmSG");
                                     ServicePrincipalName=@("$($testContext["NamingPrefix"])/754dbc04-8f91-4cb6-a10f-899dac573fa0");
                                     MemberOf=@("$($testContext["NamingPrefix"])-FsAcl-InfraSG", "$($testContext["NamingPrefix"])-SB-Jea-LC-VmSG", "$($testContext["NamingPrefix"])-Sto-SG" ) },

                [pscustomobject]@{ GmsaName="$($testContext["NamingPrefix"])-SB-Jea";
                                     PrincipalsAllowedToRetrieveManagedPassword= @("$($testContext["NamingPrefix"])-Sto-SG");
                                     ServicePrincipalName=@();
                                     MemberOf=@("$($testContext["NamingPrefix"])-FsAcl-InfraSG", "$($testContext["NamingPrefix"])-Sto-SG" ) },

                [pscustomobject]@{ GmsaName="$($testContext["NamingPrefix"])-SB-MG";
                                     PrincipalsAllowedToRetrieveManagedPassword= @("$($testContext["NamingPrefix"])-Sto-SG", "$($testContext["NamingPrefix"])-SB-Jea-MG-VmSG");
                                     ServicePrincipalName=@("$($testContext["NamingPrefix"])/ea126685-c89e-4294-959f-bba6bf75b4aa");
                                     MemberOf=@("$($testContext["NamingPrefix"])-FsAcl-InfraSG", "$($testContext["NamingPrefix"])-SB-Jea-MG-VmSG", "$($testContext["NamingPrefix"])-Sto-SG" ) },

                [pscustomobject]@{ GmsaName="$($testContext["NamingPrefix"])-SBJeaM";
                                     PrincipalsAllowedToRetrieveManagedPassword= @("$($testContext["NamingPrefix"])-Sto-SG");
                                     ServicePrincipalName=@();
                                     MemberOf=@("$($testContext["NamingPrefix"])-FsAcl-InfraSG", "$($testContext["NamingPrefix"])-Sto-SG" ) },

                [pscustomobject]@{ GmsaName="$($testContext["NamingPrefix"])-EceSA";
                                     PrincipalsAllowedToRetrieveManagedPassword= @("$($testContext["NamingPrefix"])-Sto-SG");
                                     ServicePrincipalName=@("$($testContext["NamingPrefix"])/4dde37cc-6ee0-4d75-9444-7061e156507f");
                                     MemberOf=@("$($testContext["NamingPrefix"])-FsAcl-InfraSG", "$($testContext["NamingPrefix"])-FsAcl-sqlSG", "$($testContext["NamingPrefix"])-Fab-SrvSG", "$($testContext["NamingPrefix"])-HA-SrvSG", "$($testContext["NamingPrefix"])-EceSG", "$($testContext["NamingPrefix"])-BM-EceSG")},

                [pscustomobject]@{ GmsaName="$($testContext["NamingPrefix"])-Urp-SA";
                                     PrincipalsAllowedToRetrieveManagedPassword= @("$($testContext["NamingPrefix"])-Sto-SG");
                                     ServicePrincipalName=@("$($testContext["NamingPrefix"])/110bac92-1879-47ae-9611-e40f8abf4fc0");
                                     MemberOf=@("$($testContext["NamingPrefix"])-FsAcl-InfraSG", "$($testContext["NamingPrefix"])-BM-ECESG", "$($testContext["NamingPrefix"])-EceSG")},

                [pscustomobject]@{ GmsaName="$($testContext["NamingPrefix"])-DL-SA";
                                     PrincipalsAllowedToRetrieveManagedPassword= @("$($testContext["NamingPrefix"])-Sto-SG");
                                     ServicePrincipalName=@("$($testContext["NamingPrefix"])/365645b4-f9a5-4a7d-8669-c08a1c41d66b");
                                     MemberOf=@("$($testContext["NamingPrefix"])-FsAcl-InfraSG", "$($testContext["NamingPrefix"])-BM-ECESG", "$($testContext["NamingPrefix"])-EceSG")},

                [pscustomobject]@{ GmsaName="$($testContext["NamingPrefix"])-BM-MSA";
                                     PrincipalsAllowedToRetrieveManagedPassword= @("$($testContext["NamingPrefix"])-Sto-SG");
                                     ServicePrincipalName=@("$($testContext["NamingPrefix"])/PhysicalNode/d8c180f6-7290-458e-90f0-96894f45e981");
                                     MemberOf=@("$($testContext["NamingPrefix"])-FsAcl-InfraSG",  "$($testContext["NamingPrefix"])-IH-MsSG", "$($testContext["NamingPrefix"])-HA-R-SrvSG")}
            )

            $missingGmsaAccounts = @()

            foreach ($gmsaAccount in $gmsaAccounts)
            {
                $accountMissing = $true
                try
                {
                    $gmsaName = $gmsaAccount.GmsaName
                    $adGmsaAccount = Get-ADServiceAccount -SearchBase $usersOuPath -Filter {Name -eq $gmsaName} @serverParams
                    if ($adGmsaAccount)
                    {
                        # TODO, identify SPNs and make sure they match

                        # TODO, identify PrincipasAllowedToRetrieveManagedPassword and check

                        $isMember = $true
                        try
                        {
                            foreach ($memberOfGroup in $gmsaAccount.MemberOf)
                            {
                                $groupObject = Get-ADGroup -SearchBase $usersOuPath -Filter {Name -eq $memberOfGroup} @serverParams

                                if ($groupObject)
                                {
                                    $isMemberOfThisGroup = Get-ADGroupMember -Identity $groupObject @serverParams | Where-Object {$_.SID -eq $($adGmsaAccount.SID)}

                                    if (-not $isMemberOfThisGroup)
                                    {
                                        Log-Info -Message (" Missing GMSA account ({0}) membership: {1}" -f $gmsaName,$memberOfGroup) -Type Warning -Function "gMSAsExist"
                                        $isMember = $false
                                    }
                                } else {
                                    Log-Info -Message (" Missing SG '{0}' expected for to contain GMSA account '{1}'" -f $memberOfGroup,$gmsaName) -Type Warning -Function "gMSAsExist"
                                    $isMember = $false
                                }
                            }
                        }
                        catch {}

                        $accountMissing = -not $isMember
                    }
                }
                catch {}

                if ($accountMissing)
                {
                    $missingGmsaAccounts += $gmsaAccount.GmsaName
                }
            }

            return New-Object PSObject -Property @{
                Resource    = "GmsaAccounts"
                Status      = if ($missingGmsaAccounts.Count -eq 0) { 'Succeeded' } else { 'Failed' }
                TimeStamp   = [datetime]::UtcNow
                Source      = $ENV:COMPUTERNAME
                Detail = ($testContext["LcAdTxt"].GmsaAccountsMissingRemediation -f ($missingGmsaAccounts -join ', '))
            }
        }
    }),
    (New-Object -Type ExternalADTest -Property @{
        TestName = "GroupMembershipsExist"
        ExecutionBlock = {
            Param ([hashtable]$testContext)

            $usersOuPath = $testContext["UsersADOUPath"]

            $serverParams = @{}
            if ($TestContext["AdServer"])
            {
                $serverParams += @{Server = $TestContext["AdServer"]}
            }
            if ($TestContext["AdCredentials"])
            {
                $serverParams += @{Credential = $TestContext["AdCredentials"]}
            }

            $SecurityGroupMemberships = @(
                [pscustomobject]@{ Name="$($testContext["NamingPrefix"])-HA-R-SrvSG";
                                   MemberOf=@("$($testContext["NamingPrefix"])-Hc-Rs-SrvSG", "$($testContext["NamingPrefix"])-Agw-SrvSG", "$($testContext["NamingPrefix"])-Hrp-HssSG", "$($testContext["NamingPrefix"])-IH-HsSG",  "$($testContext["NamingPrefix"])-IH-MsSG", "$($testContext["NamingPrefix"])-FsAcl-InfraSG");
                                   MissingMemberships=@()}
            )

            $results = @()

            foreach ($securityGroupMembership in $SecurityGroupMemberships)
            {
                $sgName = $securityGroupMembership.Name
                $sgMemberList = $securityGroupMembership.MemberOf
                $groupObject = $null
                try
                {
                    $groupObject = Get-ADGroup -SearchBase $usersOuPath -Filter {Name -eq $sgName} @serverParams
                }
                catch {
                    Log-Info -Message (" Failed to get AD security group '{0}'. Inner exception: {1}" -f $sgName,$_) -Type Error -Function "GroupMembershipsExist"
                }

                if ($groupObject)
                {
                    foreach ($securityGroupName in $sgMemberList)
                    {
                        $isMember = $false
                        try
                        {
                            $parentGroupObject = Get-ADGroup -SearchBase $usersOuPath -Filter {Name -eq $securityGroupName} @serverParams

                            if ($groupObject)
                            {
                                $isMember = Get-ADGroupMember -Identity $parentGroupObject @serverParams | Where-Object {$_.SID -eq $($groupObject.SID)}
                            }
                        }
                        catch {
                            Log-Info -Message (" Failed to determine whether security group '{0}' includes security group '{1}'. Inner exception: {1}" -f $securityGroupName,$sgName,$_) -Type Error -Function "GroupMembershipsExist"
                        }

                        if (-not $isMember)
                        {
                            Log-Info -Message (" FAILED: Security group '{0}' DOES NOT include security group '{1}'." -f $securityGroupName,$sgName) -Type Warning -Function "GroupMembershipsExist"
                            $securityGroupMembership.MissingMemberships += $securityGroupName
                        }
                    }
                }
                else {
                    $securityGroupMembership.MissingMemberships = $sgMemberList
                }

                $results +=  New-Object PSObject -Property @{
                    Resource    = "NestedSecurityGroups_$sgName"
                    Status      = if ($securityGroupMembership.MissingMemberships.Count -eq 0) { 'Succeeded' } else { 'Failed' }
                    TimeStamp   = [datetime]::UtcNow
                    Source      = $ENV:COMPUTERNAME
                    Detail = ($testContext["LcAdTxt"].NestedSecurityGroupsMissingRemediation -f $sgName,($securityGroupMembership.MissingMemberships -join ', '))
                }
            }

            return $results
        }
    }),
    (New-Object -Type ExternalADTest -Property @{
        TestName = "GpoInheritanceIsBlocked"
        ExecutionBlock = {
            Param ([hashtable]$testContext)

            $serverParams = @{}
            if ($TestContext["AdServer"])
            {
                $serverParams += @{Server = $TestContext["AdServer"]}
            }
            $ouList = @($testContext["ADOUPath"],$testContext["ComputersADOUPath"],$testContext["UsersADOUPath"])

            $ousWithoutGpoInheritanceBlocked = @()

            $accessWasDenied = $false

            try
            {
                foreach ($ouItem in $ouList)
                {
                    try
                    {
                        $gpInheritance = Get-GPInheritance -Target $ouItem @serverParams
                    }
                    catch
                    {
                        if ($_.Exception -is [System.DirectoryServices.ActiveDirectory.ActiveDirectoryOperationException]) { throw }
                    }

                    if ((-not $gpInheritance) -or (-not $gpInheritance.GpoInheritanceBlocked))
                    {
                        $ousWithoutGpoInheritanceBlocked += $ouItem
                    }
                }
            }
            catch [System.DirectoryServices.ActiveDirectory.ActiveDirectoryOperationException]
            {
                $accessWasDenied = $true
            }

            $statusValue = 'Succeeded'
            if ($ousWithoutGpoInheritanceBlocked.Count -ne 0)
            {
                $statusValue = 'Failed'
            }
            if ($accessWasDenied)
            {
                $statusValue = 'Skipped'
            }

            return New-Object PSObject -Property @{
                Resource    = "OuGpoInheritance"
                Status      = $statusValue
                TimeStamp   = [datetime]::UtcNow
                Source      = $ENV:COMPUTERNAME
                Detail = $testContext["LcAdTxt"].OuInheritanceBlockedMissingRemediation
            }
        }
    }),
    (New-Object -Type ExternalADTest -Property @{
        TestName = "ExecutingAsDeploymentUser"
        ExecutionBlock = {

            <#
            During deployment, the environment checker itself runs as a local admin account, but we need to make sure that the AD credentials that are passed in
            meet all the same criteria as if they were created as part of the AD pre creation tool script.
            As a result, the user specified with these credentials needs to have:
            * All access to the deployment OU in AD
            * Membership to a set of SGs as mentioned in the array below
            #>


            Param ([hashtable]$testContext)

            # Values retrieved from the test context
            $adOuPath = $testContext["ADOUPath"]
            $namingPrefix = $testContext["NamingPrefix"]
            $usersOuPath = $testContext["UsersADOUPath"]
            [pscredential]$credentials = $testContext["AdCredentials"]
            $credentialName = $null

            if ($credentials)
            {
                # Get the user SID so we can find it in the ACL
                $credentialParts = $credentials.UserName.Split("\\")
                $credentialName = $credentialParts[$credentialParts.Length-1]
            }
            else
            {
                $credentialName = $env:USERNAME
            }

            $serverParams = @{}
            if ($TestContext["AdServer"])
            {
                $serverParams += @{Server = $TestContext["AdServer"]}
            }
            if ($TestContext["AdCredentials"])
            {
                $serverParams += @{Credential = $TestContext["AdCredentials"]}
            }

            # Defined set of SGs that need to have the AD user as a member. This needs to be kept in sync with
            # the list at the bottom of AsHciADArtifactsPreCreationTool.psm1 :: New-AsHciSecurityGroup
            $requiredSgMemberships = @(
                "$($namingPrefix)-OpsAdmin",
                "$($namingPrefix)-EceSG",
                "$($namingPrefix)-BM-ECESG",
                "$($namingPrefix)-FsAcl-InfraSG",
                "$($namingPrefix)-FsAcl-AcsSG",
                "Domain Users"
            )

            $userSID = $null
            try {
                $userSecurityIdentifier = Get-ADUser -Filter {Name -eq $credentialName} -SearchBase $adOuPath @serverParams
                if ($userSecurityIdentifier) {
                    $userSID = [System.Security.Principal.SecurityIdentifier] $userSecurityIdentifier.SID
                }
            }
            catch {
                Log-Info -Message (" Failed to get user '{0}' in Active Directory. Inner exception: {1}" -f $credentialName,$_) -Type Error -Function "ExecutingAsDeploymentUser"
            }

            if (-not $userSID)
            {
                return New-Object PSObject -Property @{
                    Resource    = "ExecutingAsDeploymentUser"
                    Status      = "Failed"
                    TimeStamp   = [datetime]::UtcNow
                    Source      = $ENV:COMPUTERNAME
                    Detail = ($testContext["LcAdTxt"].ADUserNotFound -f $credentials.UserName,$adOuPath)
                }
            }
            else
            {
                Log-Info -Message (" Found user '{0}' in Active Directory" -f $credentialName) -Type Info -Function "ExecutingAsDeploymentUser"

                # Test whether the AdCredentials user has all access rights to the OU
                $userHasOuPermissions = $false
                try {

                    # The AD module SHOULD install a drive that we can use to get ACLs. However, sometimes it isn't properly registered
                    # especially if we just installed it. So verify that it's usable
                    $adDriveName = "AD"
                    $tempDriveName = "hciad"
                    $adDriveObject = $null

                    $adProvider = Get-PSProvider -PSProvider ActiveDirectory
                    if ($adProvider.Drives.Count -gt 0)
                    {
                        $adDriveObject = $adProvider.Drives | Where-Object {$_.Name -eq $adDriveName -or $_.Name -eq $tempDriveName}
                    }

                    if (-not $adDriveObject)
                    {
                        # Add a new drive
                        $adDriveObject = New-PSDrive -Name $tempDriveName -PSProvider ActiveDirectory -Root '' @serverParams
                    }

                    $adDriveName = $adDriveObject.Name

                    $ouAcl = $null
                    try
                    {
                        $ouPath = ("{0}:\{1}" -f $adDriveName,$adOuPath)
                        $ouAcl = Get-Acl $ouPath
                    }
                    catch
                    {
                        throw ("Can't get acls from {0}. Inner exception: {1}" -f $ouPath,$_)
                    }
                    finally {
                        # best effort cleanup if we had added the temp drive
                        try
                        {
                            if ($adDriveName -eq $tempDriveName)
                            {
                                $adDriveObject | Remove-PSDrive
                            }
                        }
                        catch {}
                    }

                    if ($ouAcl) {
                        # must specify the type to retrieve -- need to get something comparable to the clusterSID
                        $accessRules = $ouAcl.GetAccessRules($true, $true, $userSID.GetType())

                        # Check that the GenericAll ACE has been added
                        $genericAllAce = $accessRules | Where-Object { `
                            $_.IdentityReference -eq $userSID -and `
                            $_.ActiveDirectoryRights -bor [System.DirectoryServices.ActiveDirectoryRights]::GenericAll -and `
                            $_.AccessControlType -eq [System.Security.AccessControl.AccessControlType]::Allow -and `
                            $_.InheritanceType -eq [System.DirectoryServices.ActiveDirectorySecurityInheritance]::All
                        }

                        if ($genericAllAce)
                        {
                            $userHasOuPermissions = $true
                        }
                        else
                        {
                            Log-Info -Message (" Found ACLs for AD OU ({0}), but user ({1})'s SID ({2}) not granted GenericAll access" -f $ouPath,$credentialName,$userSID) -Type Warning -Function "ExecutingAsDeploymentUser"
                        }
                    }
                }
                catch {
                    Log-Info -Message (" FAILED to look up ACL for AD OU ({0}) and search for GenericAll ACE for user ({1}). Inner exception: {2}" -f $ouPath,$credentialName,$_) -Type Error -Function "ExecutingAsDeploymentUser"
                }

                $missingSgMemberships = @()
                foreach ($requiredSgName in $requiredSgMemberships)
                {
                    try {
                        $groupObject = Get-ADGroup -SearchBase $usersOuPath -Filter {Name -eq $requiredSgName} @serverParams
                    }
                    catch {
                        Log-Info -Message (" FAILED to look up required SG ({0}). Inner exception: {1}" -f $requiredSgName,$_) -Type Error -Function "ExecutingAsDeploymentUser"
                    }

                    # If the group doesn't exist we report in a different test
                    if ($groupObject) {
                        $adGroupMemberEntry = Get-ADGroupMember -Identity $groupObject | Where-Object {$_.SID -eq $userSID}

                        if (-not $adGroupMemberEntry)
                        {
                            $missingSgMemberships += $requiredSgName
                            Log-Info -Message (" User {0} not a member of the required security group: {1}" -f $credentialName,$requiredSgName) -Type Warning -Function "ExecutingAsDeploymentUser"
                        }
                    }
                }

                # Find all the AD groups, and search for any that contain the deployment user (especially domain admin!)
                $extraGroups = @()

                $allGroups = Get-ADGroup -Filter '*' @serverParams
                foreach ($singleGroupObject in $allGroups)
                {
                    if (-not ($requiredSgMemberships -contains $singleGroupObject.Name))
                    {
                        $foundAdUser = Get-ADGroupMember -Identity $singleGroupObject | Where-Object {$_.SID -eq $userSID}

                        if ($foundAdUser)
                        {
                            $extraneousGroupName = $singleGroupObject.DistinguishedName
                            $extraGroups += $extraneousGroupName
                            Log-Info -Message (" User {0} should not be a member of additional security group: {1}" -f $credentialName,$extraneousGroupName) -Type Warning -Function "ExecutingAsDeploymentUser"
                        }
                    }
                }

                # Summarize detail based on what failed
                $failureReasons = @()

                if (-not $userHasOuPermissions) {
                    $failureReasons += ($testContext["LcAdTxt"].CurrentUserMissingOUAccess -f $adOuPath)
                }

                if ($missingSgMemberships.Count -gt 0) {
                    $missingGroupMembershipList = $missingSgMemberships -join ", "
                    $failureReasons += ($testContext["LcAdTxt"].CurrentUserMissingSGMembership -f $missingGroupMembershipList)
                }

                if ($extraGroups.Count -gt 0) {
                    $extraneousGroupMembershipList = $extraGroups -join ", "
                    $failureReasons += ($testContext["LcAdTxt"].CurrentUserHasExcessSGMemberships -f $extraneousGroupMembershipList)
                }

                if ($failureReasons.Count -gt 0) {
                    $statusValue = 'Failed'
                    $allFailureReasons = $failureReasons -join "; "
                    $detail = ($testContext["LcAdTxt"].CurrentUserFailureSummary -f $credentials.UserName,$allFailureReasons)
                }
                else
                {
                    $statusValue = 'Succeeded'
                    $detail = ""
                }

                return New-Object PSObject -Property @{
                    Resource    = "ExecutingAsDeploymentUser"
                    Status      = $statusValue
                    TimeStamp   = [datetime]::UtcNow
                    Source      = $ENV:COMPUTERNAME
                    Detail      = $detail
                }
            }
        }
    })
)

function Test-OrganizationalUnitOnSession {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true)]
        [string]
        $ADOUPath,

        [Parameter(Mandatory=$true)]
        [string]
        $DomainFQDN,

        [Parameter(Mandatory=$true)]
        [string]
        $NamingPrefix,

        [Parameter(Mandatory=$true)]
        [string]
        $ClusterName,

        [Parameter(Mandatory)]
        [array]
        $PhysicalMachineNames,

        [Parameter(Mandatory=$false)]
        [System.Management.Automation.Runspaces.PSSession]
        $Session,

        [Parameter(Mandatory=$false)]
        [string]
        $ActiveDirectoryServer,

        [Parameter(Mandatory=$false)]
        [pscredential]
        $ActiveDirectoryCredentials
    )

    $testContext = @{
        ADOUPath = $ADOUPath
        ComputersADOUPath = "OU=Computers,$ADOUPath"
        UsersADOUPath = "OU=Users,$ADOUPath"
        DomainFQDN = $DomainFQDN
        NamingPrefix = $NamingPrefix
        ClusterName = $ClusterName
        LcAdTxt = $lcAdTxt
        AdServer = $ActiveDirectoryServer
        AdCredentials = $ActiveDirectoryCredentials
        AdCredentialsUserName = if ($ActiveDirectoryCredentials) { $ActiveDirectoryCredentials.UserName } else { "" }
        PhysicalMachineNames = $PhysicalMachineNames
    }

    $computerName = if ($Session) { $Session.ComputerName } else { $ENV:COMPUTERNAME }

    Log-Info -Message "Executing test on $computerName" -Type Info

    # Reuse the parameters for Invoke-Command so that we only have to set up context and session data once
    $invokeParams = @{
        ScriptBlock = $null
        ArgumentList = $testContext
    }
    if ($Session) {
        $invokeParams += @{Session = $Session}
    }

    # If provided, verify the AD server and credentials are reachable
    if ($ActiveDirectoryServer -or $ActiveDirectoryCredentials)
    {
        $params = @{}
        if ($ActiveDirectoryServer)
        {
            $params["Server"] = $ActiveDirectoryServer
        }
        if ($ActiveDirectoryCredentials)
        {
            $params["Credential"] = $ActiveDirectoryCredentials
        }
        try {
            Get-ADDomain @params
        }
        catch {
            if (-not $ActiveDirectoryServer) {
                $ActiveDirectoryServer = "default"
            }
            $userName = "default"
            if ($ActiveDirectoryCredentials) {
                $userName = $ActiveDirectoryCredentials.UserName
            }
            throw ("Unable to contact AD server {0} using {1} credentials. Internal exception: {2}" -f $ActiveDirectoryServer,$userName,$_)
        }
    }

    # Initialize the array of detailed results
    $detailedResults = @()

    # Test preparation -- fill in more of the test context that needs to be executed remotely
    $ExternalAdTestInitializors | ForEach-Object {
        $invokeParams.ScriptBlock = $_.ExecutionBlock
        $testName = $_.TestName

        Log-Info -Message "Executing test initializer $testName" -Type Info

        try
        {
            $results = Invoke-Command @invokeParams

            if ($results)
            {
                $testContext += $results
            }
        }
        catch {
            throw ("Unable to execute test {0} on {1}. Inner exception: {2}" -f $testName,$computerName,$_)
        }
    }

    Log-Info -Message "Executing tests with parameters: " -Type Info
    foreach ($key in $testContext.Keys)
    {
        if ($key -ne "LcAdTxt")
        {
            Log-Info -Message " $key : $($testContext[$key])" -Type Info
        }
    }

    # Update InvokeParams with the full context
    $invokeParams.ArgumentList = $testContext

    # For each test, call the test execution block and append the results
    $ExternalAdTests | ForEach-Object {
        # override ScriptBlock with the particular test execution block
        $invokeParams.ScriptBlock = $_.ExecutionBlock
        $testName = $_.TestName

        Log-Info -Message "Executing test $testName" -Type Info

        try
        {
            $results = Invoke-Command @invokeParams

            Log-Info -Message ("Test $testName completed with: {0}" -f $results) -Type Info

            $detailedResults += $results
        }
        catch {
            Log-Info -Message ("Test $testName FAILED. Inner exception: {0}" -f $_) -Type Info
            throw ("Unable to execute test {0} on {1}. Inner exception: {2}" -f $testName,$computerName,$_)
        }
    }

    return $detailedResults
}

function Test-OrganizationalUnit {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true)]
        [string]
        $ADOUPath,

        [Parameter(Mandatory=$true)]
        [string]
        $DomainFQDN,

        [Parameter(Mandatory=$true)]
        [string]
        $NamingPrefix,

        [Parameter(Mandatory=$true)]
        [string]
        $ClusterName,

        [Parameter(Mandatory=$true)]
        [array]
        $PhysicalMachineNames,

        [Parameter(Mandatory=$false)]
        [System.Management.Automation.Runspaces.PSSession]
        $PsSession,

        [Parameter(Mandatory=$false)]
        [string]
        $ActiveDirectoryServer = $null,

        [Parameter(Mandatory=$false)]
        [pscredential]
        $ActiveDirectoryCredentials = $null
    )

    $ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop

    Log-Info -Message "Executing Test-OrganizationalUnit"
    $fullTestResults = Test-OrganizationalUnitOnSession -ADOUPath $ADOUPath -DomainFQDN $DomainFQDN -NamingPrefix $NamingPrefix -ClusterName $ClusterName -Session $PsSession -ActiveDirectoryServer $ActiveDirectoryServer -ActiveDirectoryCredentials $ActiveDirectoryCredentials -PhysicalMachineNames $PhysicalMachineNames

    # Build the results
    $now = [datetime]::UtcNow
    $TargetComputerName = if ($PsSession.PSComputerName) { $PsSession.PSComputerName } else { $ENV:COMPUTERNAME }
    $aggregateStatus = if ($fullTestResults.Status -notcontains 'Failed') { 'Succeeded' } else { 'Failed' }
    $remediationValues = $fullTestResults | Where-Object -Property Status -NE 'Succeeded' | Select-Object $Remediation
    $remediationValues = $remediationValues -join "`r`n"
    if (-not $remediationValues)
    {
        $remediationValues = ''
    }
    $testOuResult = New-Object -Type OrganizationalUnitTestResult -Property @{
        Name               = 'AzStackHci_ExternalActiveDirectory_Test_OrganizationalUnit'
        Title              = 'Test AD Organizational Unit'
        Severity           = 'Critical'
        Description        = 'Tests that the specified organizational unit exists and contains the proper sub-OUs'
        Tags               = $null
        Remediation        = 'https://learn.microsoft.com/en-us/azure-stack/hci/deploy/deployment-tool-active-directory'
        TargetResourceID   = "Test_AD_OU_$TargetComputerName"
        TargetResourceName = "Test_AD_OU_$TargetComputerName"
        TargetResourceType = 'ActiveDirectory'
        Timestamp          = $now
        Status             = $aggregateStatus
        AdditionalData     = $fullTestResults
        HealthCheckSource  = $ENV:EnvChkrId
    }
    return $testOuResult
}
# SIG # Begin signature block
# MIInwgYJKoZIhvcNAQcCoIInszCCJ68CAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCDomU9Px5q5tRGz
# OdPGM8NiwRm3m2jedYcwsOZNm9bdaqCCDXYwggX0MIID3KADAgECAhMzAAADTrU8
# esGEb+srAAAAAANOMA0GCSqGSIb3DQEBCwUAMH4xCzAJBgNVBAYTAlVTMRMwEQYD
# VQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNy
# b3NvZnQgQ29ycG9yYXRpb24xKDAmBgNVBAMTH01pY3Jvc29mdCBDb2RlIFNpZ25p
# bmcgUENBIDIwMTEwHhcNMjMwMzE2MTg0MzI5WhcNMjQwMzE0MTg0MzI5WjB0MQsw
# CQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9u
# ZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMR4wHAYDVQQDExVNaWNy
# b3NvZnQgQ29ycG9y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