From 2d6d3205e11b3d2d1b15a072c1ca5ba8b271eab8 Mon Sep 17 00:00:00 2001 From: William Lam Date: Tue, 31 Jan 2017 15:13:56 -0800 Subject: [PATCH] Adding Get-VAMINetwork function Fixing comments --- Modules/VAMI.psm1 | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/Modules/VAMI.psm1 b/Modules/VAMI.psm1 index 515b274..8a1dc05 100755 --- a/Modules/VAMI.psm1 +++ b/Modules/VAMI.psm1 @@ -159,4 +159,54 @@ Function Get-VAMITime { } $timeResult +} + +Function Get-VAMINetwork { +<# + .NOTES + =========================================================================== + Created by: William Lam + Date: Jan 31, 2016 + Organization: VMware + Blog: www.virtuallyghetto.com + Twitter: @lamw + =========================================================================== + .SYNOPSIS + This function retrieves network information from VAMI interface (5480) + for a VCSA node which can be an Embedded VCSA, External PSC or External VCSA. + .DESCRIPTION + Function to return networking information including details for each interface + .EXAMPLE + Connect-CisServer -Server 192.168.1.51 -User administrator@vsphere.local -Password VMware1! + Get-VAMINetwork +#> + $netResults = @() + + $Hostname = (Get-CisService -Name 'com.vmware.appliance.networking.dns.hostname').get() + $dns = (Get-CisService -Name 'com.vmware.appliance.networking.dns.servers').get() + + Write-Host "Hostname: " $hostname + Write-Host "DNS Servers: " $dns.servers + + $interfaces = (Get-CisService -Name 'com.vmware.appliance.networking.interfaces').list() + foreach ($interface in $interfaces) { + $interfaceResult = "" | Select Inteface, MAC, Status, Mode, IP, Prefix, Gateway, Updateable + + $interfaceResult.Inteface = $interface.name + $interfaceResult.MAC = $interface.mac + $interfaceResult.Status = $interface.status + + $ipv4API = (Get-CisService -Name 'com.vmware.appliance.techpreview.networking.ipv4') + $spec = $ipv4API.Help.get.interfaces.CreateExample() + $spec+= $interface.name + $ipv4result = $ipv4API.get($spec) + + $interfaceResult.Mode = $ipv4result.mode + $interfaceResult.IP = $ipv4result.address + $interfaceResult.Prefix = $ipv4result.prefix + $interfaceResult.Gateway = $ipv4result.default_gateway + $interfaceResult.Updateable = $ipv4result.updateable + $netResults += $interfaceResult + } + $netResults } \ No newline at end of file