📅  最后修改于: 2022-03-11 15:00:23.305000             🧑  作者: Mango
$domain = [System.Directoryservices.Activedirectory.Domain]::GetCurrentDomain()
$domain | ForEach-Object {$_.DomainControllers} |
ForEach-Object {
$hostEntry= [System.Net.Dns]::GetHostByName($_.Name)
New-Object -TypeName PSObject -Property @{
Name = $_.Name
IPAddress = $hostEntry.AddressList[0].IPAddressToString
}
} | Select Name, IPAddress