45 Commits

Author SHA1 Message Date
Wes Carroll 579ba7a063 Merge pull request #59 from ZertoPublic/PrepRelease
Prep release
2019-12-01 17:15:24 -05:00
Wes Carroll 2cb35165a9 Update README 2019-12-01 17:09:57 -05:00
Wes Carroll 82cf4cb732 Bump Version for Release 2019-12-01 17:05:53 -05:00
Wes Carroll 9d21eb6409 Format Release Notes 2019-12-01 17:05:40 -05:00
Wes Carroll abadc86ae8 Merge pull request #58 from ZertoPublic/FoT-Fix
Fixes Failover Test function
2019-12-01 17:01:53 -05:00
Wes Carroll f094263882 Update RELEASENOTES.md 2019-11-28 10:55:59 -05:00
Wes Carroll c47614727a Fix Verbose Typo 2019-11-28 10:41:26 -05:00
Wes Carroll 7cad7eaf75 Merge pull request #56 from ZertoPublic/CopyVpgBugFix
Fix Bug when Adding Additional VMs
2019-11-08 08:32:13 -05:00
Wes Carroll d6862f75d1 Fix Bug when Adding Additional VMs 2019-11-07 22:35:40 -05:00
Wes Carroll 5b8a89e1a3 Merge pull request #55 from ZertoPublic/CloneVPG
Implement Clone VPG Function
2019-11-07 21:45:27 -05:00
Wes Carroll d6562de9bf Update for Copy-ZertoVpg 2019-11-07 21:37:03 -05:00
Wes Carroll cdae203993 Fix Documentation Formatting 2019-11-07 17:44:06 -05:00
Wes Carroll 213b6029e4 Create Documentation 2019-11-07 17:43:40 -05:00
Wes Carroll 11ab03be0a Create Tests 2019-11-07 17:43:29 -05:00
Wes Carroll 5f978d7b1a Fix AddVM Logic 2019-11-07 17:43:18 -05:00
Wes Carroll 5c76c4c58c Merge pull request #53 from ZertoPublic/wcarroll-patch-1
Update Connect-ZertoServer.md
2019-11-04 16:20:49 -05:00
Wes Carroll 8b3a3b3b0b Update Connect-ZertoServer.md 2019-11-04 16:20:31 -05:00
Wes Carroll 63d56cf862 Merge branch 'CloneVPG' of https://github.com/wcarroll/ZertoApiWrapper into CloneVPG 2019-10-25 14:10:09 -04:00
Wes Carroll 10785df8a9 Create Copy-ZertoVpg Function 2019-10-25 14:09:00 -04:00
Wes Carroll 8a1593ceba Merge pull request #52 from ZertoPublic/EvacuateHost
Implement Evacuate VRA Function
2019-10-25 14:03:26 -04:00
Wes Carroll 1ca3d6704b Update Release Notes for Evacuate Function 2019-10-25 13:49:59 -04:00
Wes Carroll b4a7df970c Correct VraIdentifier Property 2019-10-24 13:51:26 -04:00
Wes Carroll 3d8acf03f6 Update Tests to include set counts 2019-10-24 13:50:52 -04:00
Wes Carroll 07de073bf1 Create Invoke-ZertoEvacuateVra.Tests.ps1 2019-10-24 07:25:38 -04:00
Wes Carroll 7641d28307 Add parameter validation 2019-10-23 10:00:42 -04:00
Wes Carroll 30422d0421 Create Invoke-ZertoEvacuateVra.md 2019-10-23 09:52:09 -04:00
Wes Carroll 4a0885f731 Fix Help Message Typo 2019-10-22 13:35:49 -04:00
Wes Carroll 28d66806a5 Add ExternalHelp Def 2019-10-22 13:31:10 -04:00
Wes Carroll 42b923cef5 Create EvacuateVra Function 2019-10-22 13:26:10 -04:00
Wes Carroll 5984bc93c9 Create Copy-ZertoVpg Function 2019-10-12 22:26:13 -04:00
Wes Carroll 528bc66bcd Merge pull request #49 from ZertoPublic/New-Token
Add Function to Obtain a Pairing Token
2019-10-08 12:45:15 -04:00
Wes Carroll e706470395 Add New-ZertoPairingToken to Release notes. 2019-10-08 12:37:11 -04:00
Wes Carroll 29a79bbb92 Correct extension case. 2019-10-08 12:31:34 -04:00
Wes Carroll f907acd14a Create New-ZertoPairingToken.md 2019-10-07 11:23:24 -04:00
Wes Carroll 90a17045af Create PairingToken.Json 2019-10-07 11:23:19 -04:00
Wes Carroll e1ba8412ff Create New-ZertoPairingToken.Tests.ps1 2019-10-07 11:23:13 -04:00
Wes Carroll 0a90d51735 Create New-ZertoPairingToken.ps1 2019-10-07 11:23:10 -04:00
Wes Carroll 9d34086e40 Merge pull request #48 from ZertoPublic/75Update
Update to add token parameter to Add-ZertoPeerSite
2019-10-04 17:01:37 -04:00
Wes Carroll 842c7ceeec Added release notes for this update. 2019-10-03 16:54:56 -04:00
Wes Carroll d78fc28b1c Add ShouldProcess support to help file. 2019-10-03 14:33:17 -04:00
Wes Carroll 28fb42d56a Update documentation for token parameter and example. 2019-10-03 14:33:01 -04:00
Wes Carroll 0657607f3a Update Tests to New format and add token parameter tests 2019-10-03 14:32:36 -04:00
Wes Carroll 32f6a6eebc Update function to use new token parameter 2019-10-03 14:32:05 -04:00
Wes Carroll 6cc2e8d61d Correct Example Number Typo 2019-09-04 15:45:17 -04:00
Wes Carroll b9598e7e0b Add Aug Release in recent updates. 2019-08-01 14:11:59 -04:00
21 changed files with 807 additions and 50 deletions
+2 -1
View File
@@ -32,6 +32,8 @@ PS> Install-Module -name ZertoApiWrapper
## Recent Updates
* December 1st, 2019: November Release. See [Release Notes](https://github.com/ZertoPublic/ZertoApiWrapper/releases/tag/1.3.0.20191201).
* August 1st, 2019: August Release. See [Release Notes](https://github.com/ZertoPublic/ZertoApiWrapper/releases/tag/1.2.0.20190801).
* June 16th, 2019: Added functionality for Zerto Analytics.
* May 31st, 2019: Implement logic to allow use of this module in both Windows PowerShell 5.1 and PowerShell Core.
* March 15th, 2019: Implement Export and Import Functionality. Please See [Export-ZertoVpg Help](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Export-ZertoVpg.md) and [Import-ZertoVpg Help](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Import-ZertoVpg.md) for assistance. No current pre-seed support.
@@ -39,7 +41,6 @@ PS> Install-Module -name ZertoApiWrapper
## TODO
* Complete Help Markdown Files
* JFLR Functionality
* Create VPG (Per-VM modification and Backup Settings)
* Edit VPG
+6 -14
View File
@@ -2,17 +2,9 @@
### Zerto Virtual Manager
* Added two functions to aid in bulk updating of NIC information for protected VMs. ([Issue 38](https://github.com/ZertoPublic/ZertoApiWrapper/issues/38))
* [Export-ZertoVmNicSetting](https://github.com/ZertoPublic/ZertoApiWrapper/blob/Master/docs/Export-ZertoVmNicSettings.md)
* [Import-ZertoVmNicSetting](https://github.com/ZertoPublic/ZertoApiWrapper/blob/Master/docs/Import-ZertoVmNicSettings.md)
* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/43) where a VPG being created with a single VM member would not be parsed by the API correctly using PowerShell 5.1
### Zerto Analytics
* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/36) where the Zerto Analytics Rest Request function was not checking for the token before attempting a connection.
* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/40) where the `Get-ZAVpg` method would return a 404 error when a `-vpgIdentifier` parameter was specified.
### General Updates
* Updated the way that tests are invoked and parsed to ensure that both source and built module files are tested. This will ensure that what is being shipped passes all tests along with testing of the source files.
* Added additional parameter validation tests to several of the functions. On-going effort to complete stand alone unit testing of each function.
* [Zerto version 7.5 has been released.](https://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Release%20Notes.pdf) As part of this release Zerto has added API functionality that requires the following updates.
* A token is now required to pair two sites together. The need is discussed in [Issue 46](https://github.com/ZertoPublic/ZertoApiWrapper/issues/46). To implement this change a `-token` parameter has been added to the `Add-ZertoPeerSite` function.
* A new function has been added; `New-ZertoPairingToken`. This function will allow users to generate a pairing authentication token from the target ZVM to be used in the pairing process. [Issue 47](https://github.com/ZertoPublic/ZertoApiWrapper/issues/47) covers additional details.
* A new function has been added; `Invoke-ZertoEvacuateVra`. This function will allow users to evacuate a target VRA by specifying a Host Name, VRA Name, or VRA Identifier. All VMs currently replicating to the specified location will be migrated to different targets. [Issue 51](https://github.com/ZertoPublic/ZertoApiWrapper/issues/51)
* A function has been added; `Copy-ZertoVpg`. This function will allow users to copy the settings of a single VPG and add new VMs to it. There is currently no customization beyond specifying the VMs to be placed in the newly created VPG. Should additional edits \ updates be required, they should be done post creation. [Issue 54](https://github.com/ZertoPublic/ZertoApiWrapper/issues/54)
* Fixed [issue 57](https://github.com/ZertoPublic/ZertoApiWrapper/issues/57) where a `Start-ZertoFailoverTest` would throw an error complaining about validating the body parameter. This has been fixed and tested against Zerto Virtual Manager 7.5 Update 1 with Windows PowerShell 5.1 and PowerShell Core 6.2.
+50 -22
View File
@@ -9,34 +9,55 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
Context "$global:function::Parameter Unit Tests" {
It "Has a mandatory string parameter for the target host" {
Get-Command $global:function | Should -HaveParameter TargetHost -Mandatory -Type String
It "$global:function should have exactly 16 parameters defined" {
(Get-Command $global:function).Parameters.Count | Should -Be 16
}
It "Will not take a non-ip address as a 'TargetHost'" {
{ Add-ZertoPeerSite -targetHost 'MyZVMHost' -targetPort '9081' } | Should -Throw
{ Add-ZertoPeerSite -targetHost '192.168.1.266' -targetPort '9081' } | Should -Throw
{ Add-ZertoPeerSite -targetHost '192.168.1' -targetPort '9081' } | Should -Throw
{ Add-ZertoPeerSite -targetHost $null -targetPort '9081' } | Should -Throw
$ParameterTestCases = @(
@{ParameterName = 'targetHost'; Type = 'String'; Mandatory = $true; Validation = 'Script' }
@{ParameterName = 'targetPort'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' }
@{ParameterName = 'token'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
)
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
param($ParameterName, $Type, $Mandatory, $Validation)
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
}
It "Has a non-mandatory string parameter for the target port with default value of 9081" {
Get-Command Add-ZertoPeerSite | Should -HaveParameter TargetPort -Not -Mandatory
Get-Command Add-ZertoPeerSite | Should -HaveParameter TargetPort -Type Int32
Get-Command Add-ZertoPeerSite | Should -HaveParameter TargetPort -DefaultValue 9081
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
param($ParameterName, $Validation)
Switch ($Validation) {
'Script' {
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
$attrs.Where{ $_ -is [ValidateScript] }.Count | Should -Be 1
}
'Range' {
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
}
'NotNullOrEmpty' {
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
}
default {
$true | Should be $false -Because "No Validation Selected. Review test cases"
}
}
}
It "Will not take a non-int as a port" {
{ Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 'string' } | Should -Throw
{ Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort $true } | Should -Throw
{ Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort $null } | Should -Throw
It "targetPort Parameter should have a default value of 9081" {
Get-Command $global:function | Should -HaveParameter targetPort -DefaultValue 9081
}
It "Will fail if the specified port is outside of the range 1024 - 65535" {
{ Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 1023 } | Should -Throw
{ Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 65536 } | Should -Throw
{ Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 0 } | Should -Throw
{ Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort -1 } | Should -Throw
It "targetPort Parameter should have a Min value of 1024" {
(Get-Command $global:function).Parameters['targetPort'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should Be 1024
}
It "targetPort Parameter should have a Max value of 65535" {
(Get-Command $global:function).Parameters['targetPort'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should Be 65535
}
It "Supports 'SupportsShouldProcess'" {
@@ -52,19 +73,26 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
return (Get-Content "$global:here\Mocks\TaskId.txt")
}
It "Returns a string value" {
It "Returns a string value when no Token Passed" {
$results = Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort '9081'
$results | Should -Not -BeNullOrEmpty
$results | Should -BeOfType "String"
$results | Should -BeExactly "7e79035e-fb8c-47fe-815c-12ddd41708e6.3e4cdd0d-1064-4022-921f-6265ad6d335a"
}
It "Returns a string value when a Token is passed" {
$results = Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort '9081' -token "NotARealTokenString"
$results | Should -Not -BeNullOrEmpty
$results | Should -BeOfType "String"
$results | Should -BeExactly "7e79035e-fb8c-47fe-815c-12ddd41708e6.3e4cdd0d-1064-4022-921f-6265ad6d335a"
}
It "Does not return a taskId if '-whatif' is used" {
$results = Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort '9081' -WhatIf
$results | Should -BeNullOrEmpty
}
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -Exactly 1
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -Exactly 2
}
}
Remove-Variable -Name here -Scope Global
+56
View File
@@ -0,0 +1,56 @@
#Requires -Modules Pester
$global:here = (Split-Path -Parent $MyInvocation.MyCommand.Path)
$global:function = ((Split-Path -leaf $MyInvocation.MyCommand.Path).Split('.'))[0]
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
BeforeAll {
$script:ScriptBlock = (Get-Command $global:function).ScriptBlock
}
Context "$($global:function)::Parameter Unit Tests" {
It "$global:function should have exactly 16 parameters defined" {
(Get-Command $global:function).Parameters.Count | Should -Be 16
}
$ParameterTestCases = @(
@{ParameterName = 'SourceVpgName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
@{ParameterName = 'NewVpgName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
@{ParameterName = 'VMs'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
)
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
param($ParameterName, $Type, $Mandatory)
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
}
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
param($ParameterName, $Validation)
Switch ($Validation) {
'NotNullOrEmpty' {
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
}
$null {
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
$attrs.TypeId.Count | Should -Be 2
}
}
}
It "Supports 'SupportsShouldProcess'" {
Get-Command $global:function | Should -HaveParameter WhatIf
Get-Command $global:function | Should -HaveParameter Confirm
$script:ScriptBlock | Should -match 'SupportsShouldProcess'
$script:ScriptBlock | Should -match '\$PSCmdlet\.ShouldProcess\(.+\)'
}
}
Context "$($global:function)::Function Unit Tests" {
}
}
Remove-Variable -Name function -Scope Global
Remove-Variable -Name here -Scope Global
@@ -0,0 +1,54 @@
#Requires -Modules Pester
$global:here = (Split-Path -Parent $MyInvocation.MyCommand.Path)
$global:function = ((Split-Path -leaf $MyInvocation.MyCommand.Path).Split('.'))[0]
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
Context "$global:function::Parameter Unit Tests" {
It "$global:function should have exactly 16 parameters defined" {
(Get-Command $global:function).Parameters.Count | Should -Be 16
}
$ParameterTestCases = @(
@{ParameterName = 'hostName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty'; ParameterSet = @('hostName') }
@{ParameterName = 'vraName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' ; ParameterSet = @('vraName') }
@{ParameterName = 'vraIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' ; ParameterSet = @('vraIdentifier') }
)
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
param($ParameterName, $Type, $Mandatory, $Validation)
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
}
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
param($ParameterName, $Validation)
Switch ($Validation) {
'NotNullOrEmpty' {
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
}
$null {
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
$attrs.TypeId.Count | Should -Be 2
}
}
}
It "<ParameterName> parameter is part of the correct ParameterSet(s)" -TestCases $ParameterTestCases {
param($ParameterName, $ParameterSet)
$commandParameterSets = (Get-Command $global:function).Parameters[$ParameterName].ParameterSets
foreach ($Set in $ParameterSet) {
$commandParameterSets.ContainsKey($Set) | Should -BeTrue
}
$commandParameterSets.Count | Should -Be $ParameterSet.Count
}
}
Context "$global:function::Parameter Functional Tests" {
}
}
Remove-Variable -Name here -Scope Global
Remove-Variable -Name function -Scope Global
+4
View File
@@ -0,0 +1,4 @@
{
"Token": "TH15ISN0T4R3AL70KEN",
"UtcExpirationDate": "10/09/2019 12:55 PM"
}
@@ -0,0 +1,51 @@
#Requires -Modules Pester
$global:here = (Split-Path -Parent $MyInvocation.MyCommand.Path)
$global:function = ((Split-Path -leaf $MyInvocation.MyCommand.Path).Split('.'))[0]
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
BeforeAll {
$script:ScriptBlock = (Get-Command $global:function).ScriptBlock
}
Context "$global:function::Parameter Unit Tests" {
It "$global:function should have exactly 13 parameters defined" {
(Get-Command $global:function).Parameters.Count | Should -Be 13
}
It "Supports 'SupportsShouldProcess'" {
Get-Command $global:function | Should -HaveParameter WhatIf
Get-Command $global:function | Should -HaveParameter Confirm
$script:ScriptBlock | Should -match 'SupportsShouldProcess'
$script:ScriptBlock | Should -match '\$PSCmdlet\.ShouldProcess\(.+\)'
}
}
Context "$global:function::Parameter Functional Tests" {
Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest {
return (Get-Content -Raw "$global:here\Mocks\PairingToken.json" | ConvertFrom-Json)
}
It "Returns a Token" {
$Token = New-ZertoPairingToken
$Token | Should -Not -Be $Null
$Token.Token | Should -Be "TH15ISN0T4R3AL70KEN"
}
It "Returns a ExpirationDate" {
$Token = New-ZertoPairingToken
$Token | Should -Not -Be $Null
$Token.UtcExpirationDate | Should -Be "10/09/2019 12:55 PM"
}
It "Does not return a taskId if '-whatif' is used" {
$results = New-ZertoPairingToken -WhatIf
$results | Should -BeNullOrEmpty
}
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -Exactly 2
}
}
Remove-Variable -Name here -Scope Global
Remove-Variable -Name function -Scope Global
+13 -4
View File
@@ -6,21 +6,30 @@ function Add-ZertoPeerSite {
Mandatory = $true,
HelpMessage = "Target Hostname or IP address to pair the localsite to."
)]
[ValidateScript( {$_ -match [IPAddress]$_ } )]
[ValidateScript( { $_ -match [IPAddress]$_ } )]
[string]$targetHost,
[Parameter(
HelpMessage = "Target communication port. Default is 9081"
)]
[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 {
$baseUri = "peersites"
$body = @{"HostName" = $targetHost; "Port" = $targetPort}
}
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")) {
Invoke-ZertoRestRequest -uri $baseUri -body $($body | ConvertTo-Json) -method "POST"
}
+67
View File
@@ -0,0 +1,67 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Copy-ZertoVpg {
[CmdletBinding(SupportsShouldProcess)]
param (
# VPG Name to Clone
[Parameter(Mandatory,
HelpMessage = "Name of the VPG to clone")]
[ValidateNotNullOrEmpty()]
[String]$SourceVpgName,
# New VPG Name
[Parameter(Mandatory,
HelpMessage = "Name to assign the newly created VPG")]
[ValidateNotNullOrEmpty()]
[String]$NewVpgName, # Name of VMs to add to the VPG
[Parameter(Mandatory,
HelpMessage = "Name(s) of the Virtual Machine(s) to add to the VPG")]
[ValidateNotNullOrEmpty()]
[String[]]$VMs
)
begin {
}
process {
$VpgIdToCopy = @{ VpgIdentifier = (Get-ZertoVpg -vpgName $SourceVpgName).vpgIdentifier }
if ( $null -eq $VpgIdToCopy.VpgIdentifier ) {
Write-Error -Message "Unable to find a VPG with the name: $SourceVpgName. Please check the name and try again."
Break
} elseif ($VpgIdToCopy.VpgIdentifier.Count -gt 1) {
Write-Error -Message "More than one VPG was returned when searching for the VPG name: $SourceVpgName. Please try again."
Break
}
$BaseUri = "vpgSettings/copyVpgSettings"
$UnprotectedVms = Get-ZertoUnprotectedVm
$ProtectedVms = Get-ZertoProtectedVm
$VMsToAdd = foreach ($VM in $VMs) {
if ($UnprotectedVms.VmName -contains $VM) {
$VmId = $UnprotectedVms | Where-Object { $_.VmName -like $VM } | Select-Object -ExpandProperty VmIdentifier
} elseif ($ProtectedVms.VmName -contains $VM) {
$VmId = $ProtectedVms | Where-Object { $_.VmName -like $VM } | Select-Object -ExpandProperty VmIdentifier
} else {
Write-Warning -Message "Unable to find VM with Name $VM. Skipping."
}
$returnObject = New-Object PSObject
$returnObject | Add-Member -MemberType NoteProperty -Name "VmIdentifier" -Value $VmId
$returnObject
}
if ($PSCmdlet.ShouldProcess("$VMsToAdd", "Copying $SourceVpgName to $NewVpgName with Settings")) {
$NewVpgId = Invoke-ZertoRestRequest -Uri $BaseUri -Body ($VpgIdToCopy | ConvertTo-Json) -Method "POST"
$Uri = "{0}/{1}/vms" -f "vpgSettings", $NewVpgId
foreach ($VM in $VMsToAdd) {
$null = Invoke-ZertoRestRequest -Uri $Uri -Body ($VM | ConvertTo-Json) -Method "POST"
}
$Uri = "vpgSettings/{0}" -f $NewVpgId
$CurrentSettings = Invoke-ZertoRestRequest -Uri $Uri
$CurrentSettings.Basic.Name = $NewVpgName
$Null = Invoke-ZertoRestRequest -Uri $Uri -Method "Put" -Body $($CurrentSettings | ConvertTo-Json -Depth 20)
Save-ZertoVpgSetting -vpgSettingsIdentifier $NewVpgId
}
}
end {
}
}
@@ -0,0 +1,62 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Invoke-ZertoEvacuateVra {
[CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = "VraIdentifier")]
param (
# HostName Option
[Parameter(
Mandatory,
HelpMessage = "Name of the Host to Evacuate",
ParameterSetName = "HostName"
)]
[ValidateNotNullOrEmpty()]
[String]$HostName,
# VRA Option
[Parameter(
Mandatory,
HelpMessage = "Name of the VRA to Evacuate",
ParameterSetName = "VraName"
)]
[ValidateNotNullOrEmpty()]
[String]$VraName,
# VRAIdentifier Option
[Parameter(
Mandatory,
HelpMessage = "Identifier of the VRA to be evacuated",
ParameterSetName = "VraIdentifier",
ValueFromPipelineByPropertyName,
ValueFromPipeline
)]
[Alias("VraId", "Identifier")]
[ValidateNotNullOrEmpty()]
[String]$VraIdentifier
)
begin {
}
process {
switch ($PSCmdlet.ParameterSetName) {
"HostName" {
$VraName = "Z-VRA-" + $HostName
Invoke-ZertoEvacuateVra -VraName $VraName
}
"VraName" {
$VraIdentifier = (Get-ZertoVra -vraName $VraName).VraIdentifier
Invoke-ZertoEvacuateVra -VraIdentifier $VraIdentifier
}
"VraIdentifier" {
$Uri = "vras/{0}/changerecoveryvra/execute" -f $VraIdentifier
if ($PSCmdlet.ShouldProcess($VraIdentifier, "Evacuating VRA with Identifier:")) {
Invoke-ZertoRestRequest -Uri $Uri -Method "POST"
}
}
}
}
end {
}
}
+1 -1
View File
@@ -89,7 +89,7 @@ function Invoke-ZertoMove {
Write-Error "VPG: $name not found. Please check the name and try again. Skipping"
} else {
$uri = "{0}/{1}/move" -f $baseUri, $vpgId
if ($PSCmdlet.ShouldProcess("Moving VPG: $name wiht settings: $($body | convertto-json)")) {
if ($PSCmdlet.ShouldProcess("Moving VPG: $name with settings: $($body | convertto-json)")) {
Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json)
}
}
@@ -0,0 +1,23 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function New-ZertoPairingToken {
[CmdletBinding(SupportsShouldProcess = $true)]
param (
)
begin {
}
process {
$uri = "peersites/generatetoken"
$body = @{ }
if ($PSCmdlet.ShouldProcess("Obtaining Pairing token from $script:zvmServer")) {
Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json)
}
}
end {
}
}
@@ -27,11 +27,12 @@ function Start-ZertoFailoverTest {
if ( -not $vpgIdentifier) {
Write-Error "VPG: $vpgName Not Found. Please check the name and try again!" -ErrorAction Stop
}
$body = @{ }
if ( $PSBoundParameters.ContainsKey('vmName') ) {
$vpgVmInformation = Get-ZertoProtectedVm -vpgName $vpgName
[System.Collections.ArrayList]$vmIdentifiers = @()
$vmIdentifiers = [System.Collections.Generic.List[string]]::new()
foreach ( $name in $vmName ) {
$selectedVm = $vpgVmInformation | Where-Object {$_.VmName.toLower() -eq $name.toLower()}
$selectedVm = $vpgVmInformation | Where-Object { $_.VmName.toLower() -eq $name.toLower() }
if ($null -eq $selectedVm) {
Write-Error "VM: $name NOT found in VPG $vpgName. Check the name and try again." -ErrorAction Stop
} elseif ($vmIdentifiers.Contains($selectedVm.vmIdentifier.toString())) {
+26 -3
View File
@@ -13,7 +13,8 @@ Pairs the current Zerto Virtual Manager to the target Zerto Virtual Manager
## SYNTAX
```
Add-ZertoPeerSite [-targetHost] <String> [[-targetPort] <Int32>] [-WhatIf] [-Confirm] [<CommonParameters>]
Add-ZertoPeerSite [-targetHost] <String> [[-targetPort] <Int32>] [-token <String>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```
## DESCRIPTION
@@ -23,10 +24,17 @@ Pairs the current Zerto Virtual Manager to the target Zerto Virtual Manager by l
### Example 1
```powershell
PS C:\> Add-ZertoPeerSite -targetHost "192.168.2.100" -targetPort "9081"
PS C:\> Add-ZertoPeerSite -targetHost "192.168.2.100"
```
Pairs the current Zerto Virtual Manager to the Zerto Virtual Manager at IP address 192.168.2.100.
Pairs the current Zerto Virtual Manager to the Zerto Virtual Manager at IP address 192.168.2.100. Use this method when pairing Zerto Virtual Managers that are prior to version 7.5
### Example 2
```powershell
PS C:\> Add-ZertoPeerSite -targetHost "192.168.2.100" -token "GeneratedFromTargetZVM"
```
Pairs the current Zerto Virtual Manager to the Zerto Virtual Manager at IP address 192.168.2.100. Use this method when pairing Zerto Virtual Managers that are version 7.5 or later.
## PARAMETERS
@@ -61,6 +69,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -token
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.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
+2
View File
@@ -106,5 +106,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## RELATED LINKS
[Zerto REST API Session End Point Documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/index.html#page/RestfulAPIs%2FStatusAPIs.5.068.html%23)
[PSCredential Documentation](https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.pscredential?view=pscore-6.0.0)
[Get-Credential Documentation](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/get-credential?view=powershell-6)
+127
View File
@@ -0,0 +1,127 @@
---
external help file: ZertoApiWrapper-help.xml
Module Name: ZertoApiWrapper
online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Copy-ZertoVpg.md
schema: 2.0.0
---
# Copy-ZertoVpg
## SYNOPSIS
Copy an existing VPG settings object to create a new VPG with the same settings. New VMs must be added to the copied VPG.
## SYNTAX
```
Copy-ZertoVpg -SourceVpgName <String> -NewVpgName <String> [-VMs] <String[]> [-WhatIf] [-Confirm]
[<CommonParameters>]
```
## DESCRIPTION
Copy an existing VPG settings object to create a new VPG with the same settings. New VMs must be added to the copied VPG.
## EXAMPLES
### Example 1
```powershell
PS C:\> Copy-ZertoVpg -SourceVpgName 'MyVpg' -NewVpgName 'MyNewVpg' -VMs 'VmToAdd01'
```
Copies the settings of 'MyVpg' into a new VPG 'MyNewVpg' adding one VM, 'VmToAdd01'
### Example 2
```powershell
PS C:\> Copy-ZertoVpg -SourceVpgName 'MyVpg' -NewVpgName 'MyNewVpg' -VMs 'VmToAdd01', 'VmToAdd02'
```
Copies the settings of 'MyVpg' into a new VPG 'MyNewVpg' adding two VMs, 'VmToAdd01' and 'VmToAdd02'
## PARAMETERS
### -NewVpgName
Name to assign the newly created VPG
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -SourceVpgName
Name of the VPG to clone
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -VMs
Name of VMs to add to the VPG
```yaml
Type: String[]
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
## RELATED LINKS
[Zerto Clone VPG API Endpoint Documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/index.html#page/RestfulAPIs%2FStatusAPIs.5.119.html%23)
+1 -1
View File
@@ -49,7 +49,7 @@ PS C:\>Edit-ZertoVra -vraIdentifier $vraIdentifier -vraIpAddress "192.168.1.101"
Updates the VRA IP address to 192.168.1.101, subnet mask to 255.255.252.0, and default gateway to 192.168.1.1
### Example 3
### Example 4
```powershell
PS C:\>Edit-ZertoVra -vraIdentifier $vraIdentifier -defaultGateway "192.168.1.1"
```
+32 -1
View File
@@ -13,7 +13,7 @@ Using a CSV file, will import updated Live and Test network settings for protect
## SYNTAX
```
Import-ZertoVmNicSetting [-InputFile] <String> [<CommonParameters>]
Import-ZertoVmNicSetting [-InputFile] <String> [-WhatIf] [-Confirm] [<CommonParameters>]
```
## DESCRIPTION
@@ -47,6 +47,36 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
@@ -57,4 +87,5 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## NOTES
## RELATED LINKS
[Zerto Virtual Manager REST API VpgSettings end point documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/index.html#page/RestfulAPIs%2FStatusAPIs.5.110.html%23)
+148
View File
@@ -0,0 +1,148 @@
---
external help file: ZertoApiWrapper-help.xml
Module Name: ZertoApiWrapper
online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Invoke-ZertoEvacuateVra.md
schema: 2.0.0
---
# Invoke-ZertoEvacuateVra
## SYNOPSIS
This operation will move all VMs currently replicating to the selected host or VRA to different hosts based on internal Zerto algorithms.
## SYNTAX
### VraIdentifier (Default)
```
Invoke-ZertoEvacuateVra -VraIdentifier <String> [-WhatIf] [-Confirm] [<CommonParameters>]
```
### HostName
```
Invoke-ZertoEvacuateVra -HostName <String> [-WhatIf] [-Confirm] [<CommonParameters>]
```
### VraName
```
Invoke-ZertoEvacuateVra -VraName <String> [-WhatIf] [-Confirm] [<CommonParameters>]
```
## DESCRIPTION
This operation will move all VMs currently replicating to the selected host or VRA to different hosts based on internal Zerto algorithms.
This will return a Zerto Task Identifier so the task progress can be tracked.
## EXAMPLES
### Example 1
```powershell
PS C:\> Invoke-ZertoEvacuateVra -HostName 'host01'
```
Will move all VMs currently replicating to the selected host to different hosts.
### Example 2
```powershell
PS C:\> Invoke-ZertoEvacuateVra -VraName 'Z-VRA-host01'
```
Will move all VMs currently replicating to the selected VRA to different VRAs.
### Example 3
```powershell
PS C:\> Invoke-ZertoEvacuateVra -VraIdentifier '1234-1234-4312-9856'
```
Will move all VMs currently replicating to the selected VRA to different VRAs.
## PARAMETERS
### -HostName
HostName Option
```yaml
Type: String
Parameter Sets: HostName
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -VraIdentifier
VRAIdentifier Option
```yaml
Type: String
Parameter Sets: VraIdentifier
Aliases: VraId, Identifier
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
```
### -VraName
VRA Option
```yaml
Type: String
Parameter Sets: VraName
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
## RELATED LINKS
[Zerto REST API Evacuate VRA End Point Documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/index.html#page/RestfulAPIs%2FStatusAPIs.5.129.html%23)
+78
View File
@@ -0,0 +1,78 @@
---
external help file: ZertoApiWrapper-help.xml
Module Name: ZertoApiWrapper
online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/New-ZertoPairingToken.md
schema: 2.0.0
---
# New-ZertoPairingToken
## SYNOPSIS
Generates a new pairing token to be used during pairing ZVM to ZVM operations.
## SYNTAX
```
New-ZertoPairingToken [-WhatIf] [-Confirm] [<CommonParameters>]
```
## DESCRIPTION
Generates a new pairing token to be used during pairing ZVM to ZVM operations. This token is valid until used or 48 hours have passed, whichever comes first. This feature is only required when pairing two Zerto sites that are both operating Zerto version 7.5 or greater. To use this feature you will need to generate a pairing token from the destination site. Once that token is generated you will use that token to pair the source site to the destination site either via the GUI or via the `Add-ZertoPeerSite` function.
## EXAMPLES
### Example 1
```powershell
PS C:\> New-ZertoPairingToken
```
Generates an object that will contain the pairing token and expiration date and time.
## PARAMETERS
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
### None
## OUTPUTS
### System.Object
## NOTES
## RELATED LINKS
[Zerto REST API Peer Sites End Point Documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/index.html#page/RestfulAPIs%2FStatusAPIs.5.046.html%23)
+1 -1
View File
@@ -1 +1 @@
1.2.0
1.3.0