Powershell script to collect hostname from ipaddress
####################################################
$ipaddress=Get-Content -Path C:\ry\ansible\ip.txt
$results = @()
ForEach ($i in $ipaddress)
{
$o=new-object psobject
$o | Add-Member -MemberType NoteProperty -Name hostname -Value ([System.Net.Dns]::GetHostByAddress($i).HostName)
$results +=$o
}
$results | Select-Object -Property hostname | Export-Csv C:\ry\ansible\machinenames.csv
#####################################################
No comments:
Post a Comment