This script follows these steps : scan the Active Directory domain retrieve all Server names (OS name like “Windows*Server*”) ping the server name to check if it is alive if the ping is successfull, a WMI request get the following
Query a DNS zone
Query and retrieve all A records of a specific DNS zone Script : $dns_entries = Get-WmiObject -namespace “root\MicrosoftDNS” -class MicrosoftDNS_Atype -ComputerName dnsServerName -Filter “DomainName = ‘domain.local.net'” foreach ($dnsrecord in $dns_entries) { $dnsrecord.IPAddress + “`t” + $dnsrecord.OwnerName.split(“.”)[0] + “`t” + $dnsrecord.OwnerName
Ping computers in a host file
Just fill the host file with host names you want to ping. Script : $PingMachines = Gc “C:\folder\hosts.txt” ForEach($MachineName In $PingMachines){ $PingStatus = Gwmi Win32_PingStatus -Filter “Address = ‘$MachineName'” | Select-Object StatusCode If ($PingStatus.StatusCode -eq 0){ Write-Host $MachineName ” :