将三个值导出到csv时出现问题。
这是我的代码:
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
没有Export-CSV它正确显示,一个名称一个MAC和一个IP,但在txt中它表示“Server01”,“MAC1”,“System.String []”。 有办法获取IP地址吗?
提前致谢。
答案 0 :(得分: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