Update function to use new token parameter

This commit is contained in:
Wes Carroll
2019-10-03 14:32:05 -04:00
parent 6cc2e8d61d
commit 32f6a6eebc
+13 -4
View File
@@ -6,21 +6,30 @@ function Add-ZertoPeerSite {
Mandatory = $true, Mandatory = $true,
HelpMessage = "Target Hostname or IP address to pair the localsite to." HelpMessage = "Target Hostname or IP address to pair the localsite to."
)] )]
[ValidateScript( {$_ -match [IPAddress]$_ } )] [ValidateScript( { $_ -match [IPAddress]$_ } )]
[string]$targetHost, [string]$targetHost,
[Parameter( [Parameter(
HelpMessage = "Target communication port. Default is 9081" HelpMessage = "Target communication port. Default is 9081"
)] )]
[ValidateRange(1024, 65535)] [ValidateRange(1024, 65535)]
[int]$targetPort = 9081 [int]$targetPort = 9081,
[Parameter(
HelpMessage = "The generated token from the destination site. Note: This is only supported when both sites support pairing authentication. This was implemented to support ZVR 7.5 and later."
)]
[ValidateNotNullOrEmpty()]
[string]$token
) )
begin { begin {
$baseUri = "peersites"
$body = @{"HostName" = $targetHost; "Port" = $targetPort}
} }
process { process {
$baseUri = "peersites"
if ($PSBoundParameters.Keys.Contains("token")) {
$body = @{ "HostName" = $targetHost; "Port" = $targetPort; "Token" = $token }
} else {
$body = @{ "HostName" = $targetHost; "Port" = $targetPort }
}
if ($PSCmdlet.ShouldProcess("Pairing with Site $targetHost")) { if ($PSCmdlet.ShouldProcess("Pairing with Site $targetHost")) {
Invoke-ZertoRestRequest -uri $baseUri -body $($body | ConvertTo-Json) -method "POST" Invoke-ZertoRestRequest -uri $baseUri -body $($body | ConvertTo-Json) -method "POST"
} }