I am looking to run a DNS lookup for a local server, select both the hostname and IP address and output to a text file.
[System.Net.Dns]::GetHostEntry('server1') |
Select-Object 'HostName', 'IPAddressToString' |
Out-File -Path 'c:\temp\DnsIpAddress.txt'
I can access HostName
but cannot select IPAddressToString
. I can
access IPAddressToString
if I save the results to a variable this way:
$result.AddressList.IpAddressToString
Can I use Select-Object
to select hostname
and IPAddressToString
? Or should I do this another way?