forked from jasemccarty/Vsan-Settings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VsanProxyConfig.ps1
128 lines (91 loc) · 3.77 KB
/
VsanProxyConfig.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
Function Get-VsanProxyConfig {
<#
.SYNOPSIS
Get the Proxy Configurations for vSAN Clusters attached to vCenter
.DESCRIPTION
Get the Proxy Configurations for vSAN Clusters attached to vCenter
.PARAMETER Cluster
The name of the vSAN Cluster
.EXAMPLE
PS C:\> Get-VsanProxyConfig -Cluster "ClusterName"
.NOTES
Author : Jase McCarty
Version : 0.1
Requires : PowerCLI 11.0 or Higher
#>
# Set Parameters
[CmdletBinding()]Param([Parameter(Mandatory=$true)][String]$Cluster)
# Get the Cluster Object
$VsanCluster = Get-Cluster -Name $Cluster
# Setup the vSAN View
$vchs = Get-VsanView -Id VsanVcClusterHealthSystem-vsan-cluster-health-system
Write-Host " "
# Write which cluster we are working on
Write-Host "vSAN Proxy Information for Cluster:" $Cluster
# Return the VsanTelemetry Proxy Information
$vchs.VsanHealthQueryVsanClusterHealthConfig($VsanCluster.ExtensionData.MoRef).VsanTelemetryProxy
# Return whether it is enabled or not
$VsanProxyEnabled = $vchs.VsanHealthQueryVsanClusterHealthConfig($VsanCluster.ExtensionData.MoRef).EnableVsanTelemetry
Write-Host "vSAN Proxy Enabled:"$VsanProxyEnabled
}
Function Set-VsanProxyConfig {
<#
.SYNOPSIS
Get the Proxy Configurations for vSAN Clusters attached to vCenter
.DESCRIPTION
Get the Proxy Configurations for vSAN Clusters attached to vCenter
.PARAMETER Cluster
The name of the vSAN Cluster
.PARAMETER ProxyUser
The name of the vSAN Cluster
.PARAMETER ProxyPass
The name of the vSAN Cluster
.PARAMETER ProxyHost
The name of the vSAN Cluster
.PARAMETER ProxyPort
The name of the vSAN Cluster
.PARAMETER ProxyEnabled
The name of the vSAN Cluster
.EXAMPLE
PS C:\> Get-VsanProxyConfig -Cluster "ClusterName"
.NOTES
Author : Jase McCarty
Version : 0.1
Requires : PowerCLI Desktop 6.5 or higher
#>
# Set Parameters
[CmdletBinding()]Param(
[Parameter(Mandatory=$true)][String]$Cluster,
[Parameter(Mandatory=$true)][String]$ProxyUser,
[Parameter(Mandatory=$true)][String]$ProxyPass,
[Parameter(Mandatory=$true)][String]$ProxyHost,
[Parameter(Mandatory=$true)][String]$ProxyPort,
[Parameter(Mandatory=$false)][Boolean]$ProxyEnabled
)
# Get the Cluster Object
$VsanCluster = Get-Cluster -Name $Cluster
# Setup the vSAN View
$vchs = Get-VsanView -Id VsanVcClusterHealthSystem-vsan-cluster-health-system
Write-Host " "
# Write which cluster we are working on
Write-Host "Setting the vSAN Proxy Information for Cluster:" $Cluster
# Configure the variable for the vSAN Telemetry Proxy
$VsanTelemetryProxy = New-Object -TypeName VMware.Vsan.Views.VsanClusterTelemetryProxyConfig
$VsanTelemetryProxy.Host = $ProxyHost
$VsanTelemetryProxy.Password = $ProxyPass
$VsanTelemetryProxy.User = $ProxyUser
$VsanTelemetryProxy.Port = $ProxyPort
# Configure the variable for the vSAN Health Configuration
$VsanClusterConfig = New-Object -Type VMware.Vsan.Views.VsanClusterHealthConfigs
$VsanClusterConfig.VsanTelemetryProxy = $VsanTelemetryProxy
# If the state differs from the $ProxyEnabled parameter, change it
If ($ProxyConfigEnabled -ne $ProxyEnabled) {
$VsanClusterConfig.EnableVsanTelemetry = $ProxyEnabled
}
# Update the proxy configuration
$vchs.VsanHealthSetVsanClusterTelemetryConfig($VsanCluster.ExtensionData.MoRef,$VsanClusterConfig)
}
#Example to get the vSAN Proxy
Get-VsanProxyConfig -Cluster "Cluster"
#Example to set the vSAN Proxy
Set-VsanProxyConfig -Cluster "Cluster" -ProxyUser "fred" -ProxyPass "VMware1!" -ProxyHost "proxy.vmware.com" -ProxyPort "8080" -ProxyEnabled $True