Added ability to updated Host Password
This commit is contained in:
@@ -18,20 +18,26 @@ function Edit-ZertoVra {
|
|||||||
ParameterSetName = "StaticIp",
|
ParameterSetName = "StaticIp",
|
||||||
HelpMessage = "Static IP address to assign to the VRA."
|
HelpMessage = "Static IP address to assign to the VRA."
|
||||||
)]
|
)]
|
||||||
[ValidateScript( {$_ -match [IPAddress]$_ })]
|
[ValidateScript( { $_ -match [IPAddress]$_ })]
|
||||||
[string]$vraIpAddress,
|
[string]$vraIpAddress,
|
||||||
[Parameter(
|
[Parameter(
|
||||||
ParameterSetName = "StaticIp",
|
ParameterSetName = "StaticIp",
|
||||||
HelpMessage = "Default gateway to assign to the VRA"
|
HelpMessage = "Default gateway to assign to the VRA"
|
||||||
)]
|
)]
|
||||||
[ValidateScript( {$_ -match [IPAddress]$_ })]
|
[ValidateScript( { $_ -match [IPAddress]$_ })]
|
||||||
[string]$defaultGateway,
|
[string]$defaultGateway,
|
||||||
[Parameter(
|
[Parameter(
|
||||||
ParameterSetName = "StaticIp",
|
ParameterSetName = "StaticIp",
|
||||||
HelpMessage = "Subnetmask to be assigned to the VRA"
|
HelpMessage = "Subnetmask to be assigned to the VRA"
|
||||||
)]
|
)]
|
||||||
[ValidateScript( {$_ -match [IPAddress]$_ })]
|
[ValidateScript( { $_ -match [IPAddress]$_ })]
|
||||||
[string]$subnetMask
|
[string]$subnetMask,
|
||||||
|
[Parameter(
|
||||||
|
HelpMessage = "Updated ESXi host root password."
|
||||||
|
)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[securestring]$HostRootPassword
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
@@ -45,8 +51,8 @@ function Edit-ZertoVra {
|
|||||||
|
|
||||||
process {
|
process {
|
||||||
# Create ordered hashtables to be converted later to JSON.
|
# Create ordered hashtables to be converted later to JSON.
|
||||||
$vraUpdate = [ordered]@{}
|
$vraUpdate = [ordered]@{ }
|
||||||
$vraNetwork = [ordered]@{}
|
$vraNetwork = [ordered]@{ }
|
||||||
# If a new group name is specified, update.
|
# If a new group name is specified, update.
|
||||||
if ( $PSBoundParameters.ContainsKey('GroupName')) {
|
if ( $PSBoundParameters.ContainsKey('GroupName')) {
|
||||||
$vraUpdate['GroupName'] = $groupName
|
$vraUpdate['GroupName'] = $groupName
|
||||||
@@ -77,8 +83,14 @@ function Edit-ZertoVra {
|
|||||||
$vraNetwork['VraIPConfigurationTypeApi'] = "Dhcp"
|
$vraNetwork['VraIPConfigurationTypeApi'] = "Dhcp"
|
||||||
$vraUpdate['VraNetworkDataApi'] = $vraNetwork
|
$vraUpdate['VraNetworkDataApi'] = $vraNetwork
|
||||||
}
|
}
|
||||||
|
if ($PSBoundParameters.ContainsKey('HostRootPassword')) {
|
||||||
|
$HostRootCredential = [pscredential]::New('root', $HostRootPassword)
|
||||||
|
$vraUpdate['UsePublicKeyInsteadOfCredentials'] = $false
|
||||||
|
$vraUpdate['HostRootPassword'] = $HostRootCredential.GetNetworkCredential().Password
|
||||||
|
}
|
||||||
|
|
||||||
# -WhatIf processing and submit!
|
# -WhatIf processing and submit!
|
||||||
if ($PSCmdlet.ShouldProcess( "Updating " + $vra.vraName + " with these settings: $($vraUpdate | convertTo-Json)")) {
|
if ($PSCmdlet.ShouldProcess( $vra.vraName )) {
|
||||||
Invoke-ZertoRestRequest -uri $baseUri -body $($vraUpdate | ConvertTo-Json) -method "PUT"
|
Invoke-ZertoRestRequest -uri $baseUri -body $($vraUpdate | ConvertTo-Json) -method "PUT"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user