IPs.txt
10.10.30.45
10.20.45.23
get-wmiobject -computername (gc .\Ips.txt) -class win32_computersystem |select DNSHostname
Is it possible to have output as follow just using one liner ( I can do it regular way)
10.10.30.45 Desktop2
10.20.45.23 Desktop3
Thanks in advance
Yes, just use a calculated property on the stuff you are passing in. Something likeā¦
Get-Content -Path 'FileUNC' |
ForEach {
get-wmiobject -computername $PSItem -class win32_computersystem |
select @{
Name = 'IPAddress'
Expression = {$PSItem}
}, DNSHostname
}
# Results
IPAddress DNSHostname
--------- -----------
...