Я создал быстрый пример того, что вы могли бы сделать для примера ipconfig
.
По сути, я извлекаю все конфигурации IP для моего локального компьютера, тогда, если они больше 1, он будет проходить по каждой из них и создавать объект, который будет более читабельным.
#Get IP Configurations
$ipList = Get-NetIPConfiguration
#If there is more than 1 item in the ipList
If($ipList.count -gt 1){
#Loop through each of the IPs int the list
foreach($entry in $ipList){
#Create a Custom PowerShell Object and Assign empty attributes for the Name and IP
$object = new-object psobject | select-object Name, IPAddress
#Add a value to the $object.Name property
$object.Name = $entry.InterfaceAlias
#Add a value to the $object.IPAddress property
$object.IPAddress = $entry | select -ExpandProperty IPv4Address
#Store the value of each object in an array
[array]$output += $object
}
}
#Output the contents of the Array into a file
$output | export-csv c:\temp\IP_Info.csv -NoTypeInformation
Теперь вы можете сделать еще кое-что. В настоящее время выводится System.Object
, если не найдено значение IP, также ищет только IPv4Address
Надеюсь, это поможет вам найти решение