Wednesday 22 April 2020

Check Active Directory Computer Object Contains DNS Alias

# DNS Alias Info

$DNSAlias = Get-Content C:\temp\dns.txt

# AD Server Information

$ADObjects = Get-Content C:\temp\nas.txt| Get-ADComputer -Property
Name,ServicePrincipalName | Select-Object name,@{Name="SPN";e={$_.ServicePrincipalName -join ","}}

# Check Server SPN entry contains DNS Alias
foreach ($DNS in $DNSAlias){
foreach ($ADObj in $ADObjects){
    If ($ADObj -like "*$DNS*"){
        $log = "$DNS Object found in $ADObj" | Out-File -Append C:\temp\Result.txt
    }else{
        $Log = "$Dns" | Out-File -Append C:\temp\Result-Not.txt
    }
    }
    }

No comments:

Post a Comment