Powershell: Getting the IP Address, FQDN and MAC Address of Each Domain Controller

I was asked to get a base­line for gen­er­at­ing reports with­in AD.  The two impor­tant pieces of infor­ma­tion which were required to gen­er­ate these reports were the ip address and FQDN of each domain con­troller.  The script would then con­nect to each indi­vid­ual sys­tem to gath­er data.  While I was at it, I added the MAC Address just to see what oth­er pieces of data would be use­ful out of the Win32_NetworkAdapterConfiguration class.

#Enter the fqdn of your forest/domain
$fqdn = "fully.qualified.domain.name"
#Create Empty HashTable
$ht = New-Object psobject | Select FQDN, MACAddress, IPAddress

#Enumerate Domain Controllers
$context = new-object System.DirectoryServices.ActiveDirectory.DirectoryContext("Domain",$fqdn)
$dclist = [System.DirectoryServices.ActiveDirectory.DomainController]::findall($context)
ForEach ($strComputer in $dclist) {
	#Get IP Info of each DC
	$colItems = GWMI -cl "Win32_NetworkAdapterConfiguration" -name "rootCimV2" -comp `
                $strComputer.name -filter "IpEnabled = TRUE"
	ForEach ($objItem in $colItems){
        $ht.FQDN = $strComputer
        $ht.MACAddress = $objItem.MacAddress
        $ht.IPAddress = $objItem.IpAddress

Powershell: Using PoSH to Search Across Multiple Domains in Forest

I was recent­ly asked to get a quick report of all Win­dows 7 com­put­ers with­in a mul­ti-domain AD for­est.  After bang­ing my head into the key­board for a while, I final­ly fig­ured it out.  The script below should do the trick.

Also, if you use the Oper­at­ingSys­temVer­sion attribute, you will find that Serv­er 2008 R2 shares ver­sion “6.1 (7600)”.  So, the best way to find Win­dows 7 only, is to search for “Win­dows 7*” with the wild­card char­ac­ter against the Oper­at­ingSys­tem attribute.  That will ensure all Win­dows 7 ver­sions are returned and will exclude Serv­er 2008 R2 from your results.

#Get Domain List
$objForest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
$DomainList = @($objForest.Domains | Select-Object Name)
$Domains = $DomainList | foreach {$_.Name}

#Act on each domain
foreach($Domain in ($Domains))
	Write-Host "Checking $Domain" -fore red
	$ADsPath = [ADSI]"LDAP://$Domain"
	$objSearcher = New-Object System.DirectoryServices.DirectorySearcher($ADsPath)
	$objSearcher.Filter = "(&(objectCategory=Computer)(operatingSystem=Windows 7*))"
	$objSearcher.SearchScope = "Subtree"

	$colResults = $objSearcher.FindAll()
	foreach ($objResult in $colResults)
		$Computer = $objResult.GetDirectoryEntry()