Can it be done as one liner


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) Desktop2 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
---------                                          -----------