-
Notifications
You must be signed in to change notification settings - Fork 20
/
Get-VMwareTrafficShapingSettings.ps1
executable file
·78 lines (71 loc) · 3.27 KB
/
Get-VMwareTrafficShapingSettings.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# PowerCLI Script for Getting Traffic Shapping Settings for All VirtualPortGroup on VirtualSwitch
# @davidstamen
# http://davidstamen.com
# Powershel Functions provided by @LucD http://www.lucd.info/2011/06/11/dvswitch-scripting-part-9-traffic-shaping/
function Get-dvPgTrafficShaping{
<#
.SYNOPSIS
Returns the traffic shaping settings for a dvSwitch portgroup
.DESCRIPTION
The function will return all traffic shaping settings for a dvSwitch portgroup
.NOTES
Author: Luc Dekens
.PARAMETER dvPg
An object that represents a dvPortgroup as returned by the
Get-dVsWPg function
.EXAMPLE
PS> Get-dvSwPg $dvSw $dvPgName | Get-dvPgTrafficShaping
#>
[CmdletBinding()]
param(
[parameter(Mandatory = $true, ValueFromPipeline = $true)]
[PSObject]$dvPg)
$ts = New-Object PSObject
$ingress = $dvPg.Config.DefaultPortConfig.InshapingPolicy
Add-Member -InputObject $ts -Name IngressState -Value $ingress.Enabled.Value -MemberType NoteProperty
if($ingress.Enabled.Value){
Add-Member -InputObject $ts -Name "InAverage (Kbps)" -Value ($ingress.AverageBandwidth.Value/1000) -MemberType NoteProperty
Add-Member -InputObject $ts -Name "InBurst (KB)" -Value ($ingress.BurstSize.Value/1KB) -MemberType NoteProperty
Add-Member -InputObject $ts -Name "InPeak (Kbps)" -Value ($ingress.PeakBandwidth.Value/1000) -MemberType NoteProperty
}
else{
Add-Member -InputObject $ts -Name "InAverage (Kbps)" -Value "na" -MemberType NoteProperty
Add-Member -InputObject $ts -Name "InBurst (KB)" -Value "na" -MemberType NoteProperty
Add-Member -InputObject $ts -Name "InPeak (Kbps)" -Value "na" -MemberType NoteProperty
}
$egress = $dvPg.Config.DefaultPortConfig.OutshapingPolicy
Add-Member -InputObject $ts -Name EgressState -Value $egress.Enabled.Value -MemberType NoteProperty
if($egress.Enabled.Value){
Add-Member -InputObject $ts -Name "OutAverage (Kbps)" -Value ($egress.AverageBandwidth.Value/1000) -MemberType NoteProperty
Add-Member -InputObject $ts -Name "OutBurst (KB)" -Value ($egress.BurstSize.Value/1KB) -MemberType NoteProperty
Add-Member -InputObject $ts -Name "OutPeak (Kbps)" -Value ($egress.PeakBandwidth.Value/1000) -MemberType NoteProperty
}
else{
Add-Member -InputObject $ts -Name "OutAverage (Kbps)" -Value "na" -MemberType NoteProperty
Add-Member -InputObject $ts -Name "OutBurst (KB)" -Value "na" -MemberType NoteProperty
Add-Member -InputObject $ts -Name "OutPeak (Kbps)" -Value "na" -MemberType NoteProperty
}
$ts
}
function Get-dvSwPg{
param($dvSw,
[string]$PGName,
[int]$VLANnr)
# Search for Portgroup Name
if($PGName){
$dvSw.Portgroup | %{Get-View -Id $_} | `
where{$_.Name -eq $PGName}
}
# Search for VLAN number
elseif($VLANnr){
$dvSw.Portgroup | %{Get-View -Id $_} | `
where{$_.Config.DefaultPortConfig.Vlan.VlanId -eq $VLANnr}
}
}
Foreach ($VirtualSwitch in Get-VirtualSwitch -Distributed) {
Foreach ($VirtualPortGroup in Get-VirtualPortGroup -VirtualSwitch $VirtualSwitch|Where {$_.Name -notlike "*DVUplinks*"}) {
Write "$VirtualPortGroup on $VirtualSwitch"
$dvPg = Get-dvSwPg -dvSw $VirtualSwitch.ExtensionData -PGName $VirtualPortGroup
Get-dvPgTrafficShaping -dvPg $dvPg|ft
}
}