-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-vmNetworkInfo.ps1
22 lines (22 loc) · 992 Bytes
/
get-vmNetworkInfo.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
. $PSScriptRoot\Initialize-PowerCLI.ps1
$AllVMs = Get-VM
$VMNetInfo = @()
Foreach ($VM in $AllVMs) {
[array]$AllAdapters = $VM | Get-NetworkAdapter
foreach ($adapter in $AllAdapters) {
$entry = [PSCustomObject]@{
Name = $VM.Name
OS = $VM.ExtensionData.Guest.GuestFullName
Adapter = $adapter.Name
Network = $adapter.NetworkName
Type = $adapter.Type
MAC = $adapter.MacAddress
IPv4 = (($VM.ExtensionData.Guest.Net | Where-Object {$_.MacAddress -eq $adapter.MacAddress}).IPAddress | Where-Object {$_ -notlike '*:*'}) -join ';'
IPv6 = (($VM.ExtensionData.Guest.Net | Where-Object {$_.MacAddress -eq $adapter.MacAddress}).IPAddress | Where-Object {$_ -notlike '*.*'}) -join ';'
}
$VMNetInfo+= $entry
}
}
$VMNetInfo | Format-Table -Property *
$VMNetInfo | Export-Csv $PSScriptRoot\vmnetinfo.csv -NoTypeInformation
"$PSScriptRoot\vmnetinfo.csv"