Skip to content

Instantly share code, notes, and snippets.

@spy86
Created October 24, 2018 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spy86/2bc764a321990b20f9f3d5cb748c81f3 to your computer and use it in GitHub Desktop.
Save spy86/2bc764a321990b20f9f3d5cb748c81f3 to your computer and use it in GitHub Desktop.
Resolve IP Addresses from List of Host Names
function Get-HostToIP($hostname) {
$result = [system.Net.Dns]::GetHostByName($hostname)
$result.AddressList | ForEach-Object {$_.IPAddressToString }
}
Get-Content "C:\Temp\Servers.txt" | ForEach-Object {(Get-HostToIP($_)) >> C:\Temp\Addresses.txt}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment