1

I have a problem with exporting three values to a csv.

This is my code:

Get-WmiObject win32_networkadapterconfiguration -ComputerName $sn.Name | 
Where-Object { 
    $_.Description -like "BASP Virtual Adapter" -or
    $_.Description -like "HP Network Team #1" } | 
Select-Object PSComputername, MACAddress, IPAddress | 
Export-Csv C:\Server_MAC_IP.txt -Force

without the Export-CSV it is displayed correctly, one name one MAC and one IP, but in the txt it says i.e. "Server01","MAC1","System.String[]". Is there a way to get the IP address?

Thanks in advance.

1 Answer 1

1

TRY

Get-WmiObject win32_networkadapterconfiguration -ComputerName $sn.Name | 
Where-Object { $_.Description -like "BASP Virtual Adapter" -or $_.Description -like "HP Network Team #1" } | 
Select-Object PSComputername, MACAddress, @{N="IPAddress";E={ $_.IPADDRESS -JOIN ';'}} |
Export-Csv C:\Server_MAC_IP.txt -Force
Sign up to request clarification or add additional context in comments.

1 Comment

@IronGibbet Glad to help! The -join is needed in case some NIC have more than one IP configrated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.