Compare commits
154 Commits
1.4.1
...
zvma-updates
| Author | SHA1 | Date | |
|---|---|---|---|
| b3e27c8ef7 | |||
| 5b9c692f5b | |||
| 31638c5f48 | |||
| a7642eee67 | |||
| 42ac97ca4c | |||
| 47866b360b | |||
| 1a0972bd3e | |||
| 97e3c20792 | |||
| 26be123b76 | |||
| a16088fb66 | |||
| 81dc568407 | |||
| 457b7e6a74 | |||
| 5f6693fac4 | |||
| 7f5237e53e | |||
| 181761310c | |||
| 61b09638ab | |||
| 7462b55451 | |||
| badf2dd6a5 | |||
| e7694831b3 | |||
| cce96a9783 | |||
| 05253026e4 | |||
| ad8b61e19f | |||
| 14d36ab32b | |||
| 7e61fbec7e | |||
| 315cdf6db9 | |||
| ccc4118d22 | |||
| 764738b015 | |||
| 4b1506f962 | |||
| 55b6614a69 | |||
| f9291ed933 | |||
| a2d724a54c | |||
| f06157c75e | |||
| d413374c09 | |||
| 1513cd4f4b | |||
| 1daac508b2 | |||
| a22d9e3416 | |||
| 06e81b46d6 | |||
| af33715f02 | |||
| 912bca0f9c | |||
| 4ac951607b | |||
| d3d01f892f | |||
| 84b7922156 | |||
| 0eaf89608b | |||
| 50e03b36f5 | |||
| 4531d2d53b | |||
| e6e6be9ede | |||
| 5c2dd620d8 | |||
| a5a91febcf | |||
| bb5dbaa0d4 | |||
| e6b5777e64 | |||
| ddee165575 | |||
| f0279633dd | |||
| 139e52f3e2 | |||
| eea6e95988 | |||
| 0630cbb20e | |||
| 682750fc6d | |||
| 9dc9aa92d0 | |||
| 23e0b8a665 | |||
| ae53dcd4d2 | |||
| ced5671ab2 | |||
| cb528df3d4 | |||
| c91d53ecad | |||
| 8d8cb58558 | |||
| 2dad347544 | |||
| 6f798fd96a | |||
| 649e7413a7 | |||
| af6e81267b | |||
| b6d8083b69 | |||
| 9d4b4d3533 | |||
| 510f0b9ed7 | |||
| 9561936be7 | |||
| 961eafb945 | |||
| aa73534d7f | |||
| 56bbe59ea7 | |||
| 5f786775dc | |||
| 14ef5048e4 | |||
| d7e46bd263 | |||
| c64c82f8bc | |||
| a59feb2d5f | |||
| d9e1063654 | |||
| d9e6c74f27 | |||
| df82bc26ca | |||
| dbde9aa4c2 | |||
| 7dcb6539a5 | |||
| 3621ddef8d | |||
| 5b4a25b66d | |||
| 5a2c01341c | |||
| c477d40364 | |||
| 494c45b02c | |||
| 8318229cf4 | |||
| 7427ffe707 | |||
| 713c94461c | |||
| 0872f1a655 | |||
| a072905253 | |||
| 41fddf5f13 | |||
| 136d1b2c76 | |||
| a25bf3adfe | |||
| 93c55bdd07 | |||
| 5627992a04 | |||
| 7fc7edff86 | |||
| 6f1e582ceb | |||
| 0f1b4302bb | |||
| ea8d6f096d | |||
| ddae22fb9f | |||
| 6903ccc99b | |||
| 7ce6369ad7 | |||
| 2d453ef608 | |||
| 363b6e727c | |||
| f4c1cf630a | |||
| 348fcbd28c | |||
| 3000a2b013 | |||
| 52609bf64a | |||
| e021a7bab0 | |||
| c3ad8dd415 | |||
| f81a22ca80 | |||
| de1a85cecd | |||
| d3acba3967 | |||
| 512d5bbd74 | |||
| 9ad9cb7f1e | |||
| a55b0cd467 | |||
| aab22cf266 | |||
| 906d35186f | |||
| c7c3428dd5 | |||
| e90d2a23cc | |||
| 925ecaf224 | |||
| 32403ec3e3 | |||
| 73540faeb9 | |||
| 932262e33a | |||
| 1e84f5aea0 | |||
| 7befc7d21e | |||
| cdad0c5e79 | |||
| 291aae9dcd | |||
| f8f0d980d0 | |||
| b72099559c | |||
| 6046103da0 | |||
| cccd45b7fd | |||
| 77b7e1c376 | |||
| 8f735bee62 | |||
| de505debf9 | |||
| bc570e9005 | |||
| 804a60be77 | |||
| 1e678214b1 | |||
| ba0b12e83c | |||
| b33b07b524 | |||
| d4b4d1b4d7 | |||
| fbe3f4d031 | |||
| 26cfb832a4 | |||
| 865ca1dd39 | |||
| 2887f6d450 | |||
| 7e58672bc2 | |||
| 34f2f937aa | |||
| f59d0bece4 | |||
| 13ee62de6c | |||
| 8fd820ff38 |
@@ -6,3 +6,4 @@ SourceTestResults.xml
|
|||||||
publish/*
|
publish/*
|
||||||
CodeCoverage.xml
|
CodeCoverage.xml
|
||||||
scratch
|
scratch
|
||||||
|
.DS_Store
|
||||||
|
|||||||
Vendored
+2
-1
@@ -4,5 +4,6 @@
|
|||||||
"editor.insertSpaces": true,
|
"editor.insertSpaces": true,
|
||||||
"editor.tabSize": 4,
|
"editor.tabSize": 4,
|
||||||
"powershell.codeFormatting.preset": "OTBS",
|
"powershell.codeFormatting.preset": "OTBS",
|
||||||
"terminal.integrated.shell.windows": "c:/Program Files/PowerShell/7/pwsh.exe"
|
"terminal.integrated.shell.windows": "c:/Program Files/PowerShell/7/pwsh.exe",
|
||||||
|
"powershell.codeFormatting.addWhitespaceAroundPipe": true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,103 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project is transitioning to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project is transitioning to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [2.1.0]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
* Added Support for Zerto 10.7u1 Virtual Appliance - You can now authenticate to Zerto Virtual Appliances and run the other functions of this module.
|
||||||
|
|
||||||
|
### Updated
|
||||||
|
|
||||||
|
* Updated `Invoke-ZertoRestRequest` function [help documentation](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Install-ZertoVra.md)
|
||||||
|
|
||||||
|
## [2.0.0]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
* Added Support for Zerto 10 Virtual Appliance - You can now authenticate to Zerto Virtual Appliances and run the other functions of this module.
|
||||||
|
|
||||||
|
### Updated
|
||||||
|
|
||||||
|
* Updated `Connect-ZertoServer` function [help documentation](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Install-ZertoVra.md)
|
||||||
|
* Updated `Invoke-ZertoRestRequest` function [help documentation](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Install-ZertoVra.md)
|
||||||
|
|
||||||
|
## [1.5.4]
|
||||||
|
|
||||||
|
### Zerto Virtual Manager
|
||||||
|
|
||||||
|
#### Updated
|
||||||
|
|
||||||
|
* Updated `Install-ZertoVra` function [help documentation](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Install-ZertoVra.md) to allow for configuring the number of vCPUs during deployment. Special thanks to @mitchellen for the fix.
|
||||||
|
|
||||||
|
## [1.5.3]
|
||||||
|
|
||||||
|
### Zerto Virtual Manager
|
||||||
|
|
||||||
|
#### Fixed
|
||||||
|
|
||||||
|
* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/112) where `New-ZertoVpg` would fail when specifying the local site as the target site.
|
||||||
|
* Updated the method where a Site Identifer is obtained during the `New-ZertoVpg` execution that would occasionally fail on some versions of PowerShell.
|
||||||
|
|
||||||
|
#### Updated
|
||||||
|
|
||||||
|
* Updated `New-ZertoVpg` function [help documentation](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/New-ZertoVpg.md) to more clearly specify the return value and the requirement to pass it into the `Save-ZertoVpgSetting` function to commit the VPG.
|
||||||
|
|
||||||
|
## [1.5.2]
|
||||||
|
|
||||||
|
### Zerto Virtual Manager
|
||||||
|
|
||||||
|
#### Fixed
|
||||||
|
|
||||||
|
* Fixed an issue when attempting to export more than 100 VPGs with the `Export-ZertoVpg` function that would cause an error.
|
||||||
|
|
||||||
|
## [1.5.1]
|
||||||
|
|
||||||
|
### Zerto Virtual Manager
|
||||||
|
|
||||||
|
#### Fixed
|
||||||
|
|
||||||
|
* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/108) with `New-ZertoVpg` where when specifying a single host as a recovery target, the host identifier was not properly assigned. - Thanks @jonsouzerto!
|
||||||
|
* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/86) with `Invoke-ZertoMoveVpg` where parameters should have been mandatory in certain workflows. - Thanks @gdbarron!
|
||||||
|
|
||||||
|
## [1.5.0]
|
||||||
|
|
||||||
|
### Zerto Virtual Manager
|
||||||
|
|
||||||
|
#### New
|
||||||
|
|
||||||
|
* Added `Add-ZertoVpgVm` function to the module. Read the [help file](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Add-ZertoVpgVm.md) for more information.
|
||||||
|
* Added `Remove-ZertoVpgVm` function to the module. Read the [help file](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Remove-ZertoVpgVm.md) for more information.
|
||||||
|
|
||||||
|
#### Fixed
|
||||||
|
|
||||||
|
* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/103) with `Add-ZertoPeerSite` where there was an incorrect settings validator on the `-targetHost` parameter where it would not accept a hostname.
|
||||||
|
|
||||||
|
## [1.4.3]
|
||||||
|
|
||||||
|
### Zerto Virtual Manager
|
||||||
|
|
||||||
|
#### Updated
|
||||||
|
|
||||||
|
* Updated `Connect-ZertoServer` with a `-AutoReconnect` switch to allow the auto reconnection of a session that has timed-out.
|
||||||
|
* Updated `New-ZertoVpg` to have a Default Parameter Set of `recoveryHostDatastore` should no parameters be passed when calling the function.
|
||||||
|
* Updated `New-ZertoVpg -recoverySite` parameter to be case-insensitive
|
||||||
|
|
||||||
|
#### Fixed
|
||||||
|
|
||||||
|
* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/96) with `Set-ZertoLicense` so that ShouldProcess functions properly.
|
||||||
|
* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/95) when attempting to connect to an unlicensed site.
|
||||||
|
|
||||||
|
## [1.4.2]
|
||||||
|
|
||||||
|
### Zerto Virtual Manager
|
||||||
|
|
||||||
|
#### Fixed
|
||||||
|
|
||||||
|
* Updated `Get-ZertoEvent` to translate a vpg name parameter to a vpgIdentifier per the API documentation
|
||||||
|
* Updated `Invoke-ZertoMoveCommit` to ensure that when one of the parameter switches is defined, all required parameters are sent to avoid conflicts with parameters passed with the `Invoke-ZertoMove` command.
|
||||||
|
* Updated `Start-ZertoCloneVpg` to fix an issue where an error would be thrown if an operation specified a subset of VMs to be cloned.
|
||||||
|
|
||||||
## [1.4.1]
|
## [1.4.1]
|
||||||
|
|
||||||
### General
|
### General
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ PS> Install-Module -name ZertoApiWrapper
|
|||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
* [Getting Started with Zerto Virtual Manager and the ZertoApiWrapper](https://github.com/ZertoPublic/ZertoApiWrapper/wiki/Getting-Stated-with-Zerto-Virtual-Manager)
|
* [Getting Started with Zerto Virtual Manager and the ZertoApiWrapper](https://github.com/ZertoPublic/ZertoApiWrapper/wiki/Getting-Started-with-Zerto-Virtual-Manager)
|
||||||
* [Getting Started with Zerto Analytics and the ZertoApiWrapper](https://github.com/ZertoPublic/ZertoApiWrapper/wiki/Getting-Started-with-Zerto-Analytics)
|
* [Getting Started with Zerto Analytics and the ZertoApiWrapper](https://github.com/ZertoPublic/ZertoApiWrapper/wiki/Getting-Started-with-Zerto-Analytics)
|
||||||
|
|
||||||
## Recent Updates
|
## Recent Updates
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#Requires -Modules Pester
|
#Requires -Modules Pester
|
||||||
$global:here = (Split-Path -Parent $PSCommandPath)
|
$global:here = (Split-Path -Parent $PSCommandPath)
|
||||||
$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0]
|
$global:function = ((Split-Path -Leaf $PSCommandPath).Split('.'))[0]
|
||||||
|
|
||||||
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
@@ -14,7 +14,7 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$ParameterTestCases = @(
|
$ParameterTestCases = @(
|
||||||
@{ParameterName = 'targetHost'; Type = 'String'; Mandatory = $true; Validation = 'Script' }
|
@{ParameterName = 'targetHost'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||||
@{ParameterName = 'targetPort'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' }
|
@{ParameterName = 'targetPort'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' }
|
||||||
@{ParameterName = 'token'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
@{ParameterName = 'token'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||||
)
|
)
|
||||||
@@ -27,11 +27,6 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
|||||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||||
param($ParameterName, $Validation)
|
param($ParameterName, $Validation)
|
||||||
Switch ($Validation) {
|
Switch ($Validation) {
|
||||||
'Script' {
|
|
||||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
|
||||||
$attrs.Where{ $_ -is [ValidateScript] }.Count | Should -Be 1
|
|
||||||
}
|
|
||||||
|
|
||||||
'Range' {
|
'Range' {
|
||||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||||
@@ -63,8 +58,8 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
|||||||
It "Supports 'SupportsShouldProcess'" {
|
It "Supports 'SupportsShouldProcess'" {
|
||||||
Get-Command $global:function | Should -HaveParameter WhatIf
|
Get-Command $global:function | Should -HaveParameter WhatIf
|
||||||
Get-Command $global:function | Should -HaveParameter Confirm
|
Get-Command $global:function | Should -HaveParameter Confirm
|
||||||
$script:ScriptBlock | Should -match 'SupportsShouldProcess'
|
$script:ScriptBlock | Should -Match 'SupportsShouldProcess'
|
||||||
$script:ScriptBlock | Should -match '\$PSCmdlet\.ShouldProcess\(.+\)'
|
$script:ScriptBlock | Should -Match '\$PSCmdlet\.ShouldProcess\(.+\)'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
#Requires -Modules Pester
|
||||||
|
$global:here = (Split-Path -Parent $PSCommandPath)
|
||||||
|
$global:function = ((Split-Path -Leaf $PSCommandPath).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 = 'vpgSettingsIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||||
|
@{ParameterName = 'Vm'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||||
|
@{ParameterName = 'VpgName'; Type = 'String'; Mandatory = $true; 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 "<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
|
||||||
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
|
$true | Should -Be $false -Because "No Validation Selected. Review test cases"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 "Add-ZertoPeerSite::Functional Unit Tests" {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Remove-Variable -Name here -Scope Global
|
||||||
|
Remove-Variable -Name function -Scope Global
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#Requires -Modules Pester
|
#Requires -Modules Pester
|
||||||
$global:here = (Split-Path -Parent $PSCommandPath)
|
$global:here = (Split-Path -Parent $PSCommandPath)
|
||||||
$global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0]
|
$global:function = ((Split-Path -Leaf $PSCommandPath).Split('.'))[0]
|
||||||
|
|
||||||
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
@@ -21,7 +21,7 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
|||||||
It "port variable has a non-mandatory String parameter" {
|
It "port variable has a non-mandatory String parameter" {
|
||||||
Get-Command $global:function | Should -HaveParameter zertoPort -Not -Mandatory
|
Get-Command $global:function | Should -HaveParameter zertoPort -Not -Mandatory
|
||||||
Get-Command $global:function | Should -HaveParameter zertoPort -Type String
|
Get-Command $global:function | Should -HaveParameter zertoPort -Type String
|
||||||
Get-Command $global:function | Should -HaveParameter zertoPort -DefaultValue "9669"
|
Get-Command $global:function | Should -HaveParameter zertoPort -DefaultValue "443"
|
||||||
}
|
}
|
||||||
|
|
||||||
It "port variable does not accecpt an empty or null input" {
|
It "port variable does not accecpt an empty or null input" {
|
||||||
@@ -45,6 +45,16 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
|||||||
{ Connect-ZertoServer -zertoServer -credential 1234 } | Should -Throw
|
{ Connect-ZertoServer -zertoServer -credential 1234 } | Should -Throw
|
||||||
{ Connect-ZertoServer -zertoServer -credential $(@{Username = "zerto\build"; Password = 'SecureString' }) } | Should -Throw
|
{ Connect-ZertoServer -zertoServer -credential $(@{Username = "zerto\build"; Password = 'SecureString' }) } | Should -Throw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#It "has a switch parameter to return the headers" {
|
||||||
|
# #Get-Command $global:function | Should -HaveParameter returnHeaders
|
||||||
|
# Get-Command $global:function | Should -HaveParameter returnHeaders -Type Switch
|
||||||
|
#}
|
||||||
|
|
||||||
|
It "has a switch parameter to auto reauthorize the session" {
|
||||||
|
Get-Command $global:function | Should -HaveParameter autoReconnect
|
||||||
|
Get-Command $global:function | Should -HaveParameter autoReconnect -Type Switch
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InModuleScope -ModuleName ZertoApiWrapper {
|
InModuleScope -ModuleName ZertoApiWrapper {
|
||||||
@@ -57,17 +67,13 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
|||||||
return $results
|
return $results
|
||||||
}
|
}
|
||||||
|
|
||||||
Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoLocalSite {
|
|
||||||
return (Get-Content -Path "$global:here\Mocks\LocalSiteInfo.json" -Raw | ConvertFrom-Json)
|
|
||||||
}
|
|
||||||
|
|
||||||
Context "$($global:function)::InModuleScope Function Unit Tests" {
|
Context "$($global:function)::InModuleScope Function Unit Tests" {
|
||||||
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
$server = '192.168.1.100'
|
$server = '192.168.1.100'
|
||||||
$password = ConvertTo-SecureString -String "NotARealPassword" -AsPlainText -Force
|
$password = ConvertTo-SecureString -String "NotARealPassword" -AsPlainText -Force
|
||||||
$credential = New-Object pscredential('NotARealUser', $password)
|
$credential = New-Object pscredential('NotARealUser', $password)
|
||||||
$now = $(Get-Date).ticks
|
#$now = $(Get-Date).ticks
|
||||||
Connect-ZertoServer -zertoServer $server -credential $credential
|
Connect-ZertoServer -zertoServer $server -credential $credential
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +84,7 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
|||||||
|
|
||||||
It "Module Scope zvmPort variable tests" {
|
It "Module Scope zvmPort variable tests" {
|
||||||
$script:zvmPort | Should -Not -BeNullOrEmpty
|
$script:zvmPort | Should -Not -BeNullOrEmpty
|
||||||
$script:zvmPort | Should -Be '9669'
|
$script:zvmPort | Should -Be '443'
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Module Scope zvmLastAction variable tests" {
|
It "Module Scope zvmLastAction variable tests" {
|
||||||
@@ -86,44 +92,38 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
|||||||
$script:zvmLastAction | Should -BeGreaterOrEqual $now
|
$script:zvmLastAction | Should -BeGreaterOrEqual $now
|
||||||
}
|
}
|
||||||
|
|
||||||
It "Module Scope zvmHeaders variable tests" {
|
#It "Module Scope zvmHeaders variable tests" {
|
||||||
$script:zvmHeaders | Should -Not -BeNullOrEmpty
|
# $script:zvmHeaders | Should -Not -BeNullOrEmpty
|
||||||
$script:zvmHeaders | Should -BeOfType PSCustomObject
|
# $script:zvmHeaders | Should -BeOfType PSCustomObject
|
||||||
$script:zvmHeaders.keys.count | Should -BeExactly 3
|
# $script:zvmHeaders.keys.count | Should -BeExactly 3
|
||||||
$script:zvmHeaders.ContainsKey('x-zerto-session') | Should -BeTrue
|
#$script:zvmHeaders.ContainsKey('x-zerto-session') | Should -BeTrue
|
||||||
$script:zvmHeaders.ContainsKey('Accept') | Should -BeTrue
|
# $script:zvmHeaders.ContainsKey('Accept') | Should -BeTrue
|
||||||
$script:zvmHeaders['x-zerto-session'] | Should -BeOfType String
|
#$script:zvmHeaders['x-zerto-session'] | Should -BeOfType String
|
||||||
$script:zvmHeaders['Accept'] | Should -BeOfType String
|
# $script:zvmHeaders['Accept'] | Should -BeOfType String
|
||||||
}
|
#}
|
||||||
|
|
||||||
It "Module Scope zvmLocalInfo variable tests" {
|
#$headers = Connect-ZertoServer -zertoServer $Server -credential $credential -returnHeaders
|
||||||
$script:zvmLocalInfo | Should -Not -BeNullOrEmpty
|
#It "returns a Hashtable with 2 keys" {
|
||||||
$script:zvmLocalInfo | Should -BeOfType PSCustomObject
|
# $headers | Should -BeOfType Hashtable
|
||||||
$script:zvmLocalInfo.SiteIdentifier | Should -BeOfType String
|
# $headers.keys.count | Should -Be 3
|
||||||
}
|
#}
|
||||||
|
|
||||||
$headers = Connect-ZertoServer -zertoServer $Server -credential $credential -returnHeaders
|
#It "return value has a key called 'x-zerto-session'" {
|
||||||
It "returns a Hashtable with 2 keys" {
|
# $headers.ContainsKey('x-zerto-session') | Should -Be $true
|
||||||
$headers | Should -BeOfType Hashtable
|
#}
|
||||||
$headers.keys.count | Should -Be 3
|
|
||||||
}
|
|
||||||
|
|
||||||
It "return value has a key called 'x-zerto-session'" {
|
#It "return key 'x-zerto-session' value should be a string" {
|
||||||
$headers.ContainsKey('x-zerto-session') | Should -Be $true
|
# $headers['x-zerto-session'] | Should -BeOfType "String"
|
||||||
}
|
# $headers['x-zerto-session'] | Should -BeExactly "e34da0b0-4bc2-4cda-b316-0384e35bdca5"
|
||||||
|
#}
|
||||||
It "return key 'x-zerto-session' value should be a string" {
|
|
||||||
$headers['x-zerto-session'] | Should -BeOfType "String"
|
|
||||||
$headers['x-zerto-session'] | Should -BeExactly "e34da0b0-4bc2-4cda-b316-0384e35bdca5"
|
|
||||||
}
|
|
||||||
|
|
||||||
It "return value has a key called 'accept'" {
|
It "return value has a key called 'accept'" {
|
||||||
$headers.ContainsKey('accept') | Should -Be $true
|
$headers.ContainsKey('accept') | Should -Be $true
|
||||||
}
|
}
|
||||||
|
|
||||||
It "return key 'accept' value should be 'application/json'" {
|
#It "return key 'accept' value should be 'application/json'" {
|
||||||
$headers['accept'] | Should -Be 'application/json'
|
# $headers['accept'] | Should -Be 'application/json'
|
||||||
}
|
#}
|
||||||
|
|
||||||
It "should not require a port to be specified" {
|
It "should not require a port to be specified" {
|
||||||
Connect-ZertoServer -zertoServer $Server -credential $credential
|
Connect-ZertoServer -zertoServer $Server -credential $credential
|
||||||
@@ -134,7 +134,6 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -Exactly 4
|
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -Exactly 4
|
||||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoLocalSite -Exactly 4
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
|||||||
return "1024d377-afb8-4880-82f0-96eeff413ffd"
|
return "1024d377-afb8-4880-82f0-96eeff413ffd"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mock -ModuleName ZertoApiWrapper -CommandName Remove-ZertoVpgSettingsIdentifier {
|
||||||
|
return $null
|
||||||
|
}
|
||||||
|
|
||||||
Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpgSetting {
|
Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpgSetting {
|
||||||
$returnObj = @{
|
$returnObj = @{
|
||||||
Backup = $null
|
Backup = $null
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
|||||||
$ParameterTestCases = @(
|
$ParameterTestCases = @(
|
||||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||||
@{ParameterName = 'vpgName'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
@{ParameterName = 'vpg'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||||
@{ParameterName = 'eventType'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
@{ParameterName = 'eventType'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||||
@{ParameterName = 'siteName'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
@{ParameterName = 'siteName'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
|||||||
|
|
||||||
Context "$global:function::Parameter Unit Tests" {
|
Context "$global:function::Parameter Unit Tests" {
|
||||||
It "$global:function should have exactly 24 parameters defined" {
|
It "$global:function should have exactly 24 parameters defined" {
|
||||||
(Get-Command $global:function).Parameters.Count | Should -Be 24
|
(Get-Command $global:function).Parameters.Count | Should -Be 25
|
||||||
}
|
}
|
||||||
|
|
||||||
$ParameterTestCases = @(
|
$ParameterTestCases = @(
|
||||||
|
|||||||
@@ -5,17 +5,18 @@ $global:function = ((Split-Path -leaf $PSCommandPath).Split('.'))[0]
|
|||||||
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
||||||
|
|
||||||
Context "$global:function::Parameter Unit Tests" {
|
Context "$global:function::Parameter Unit Tests" {
|
||||||
It "$global:function should have exactly 20 parameters defined" {
|
It "$global:function should have exactly 21 parameters defined" {
|
||||||
(Get-Command $global:function).Parameters.Count | Should -Be 20
|
(Get-Command $global:function).Parameters.Count | Should -Be 21
|
||||||
}
|
}
|
||||||
|
|
||||||
$ParameterTestCases = @(
|
$ParameterTestCases = @(
|
||||||
|
@{ParameterName = 'vpgIdentifier'; Type = 'Guid[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||||
@{ParameterName = 'vpgName'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
@{ParameterName = 'vpgName'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||||
@{ParameterName = 'commitPolicy'; Type = 'String'; Mandatory = $false; Validation = 'Set' }
|
@{ParameterName = 'commitPolicy'; Type = 'String'; Mandatory = $false; Validation = 'Set' }
|
||||||
@{ParameterName = 'commitPolicyTimeout'; Type = 'Int'; Mandatory = $false; Validation = 'Range' }
|
@{ParameterName = 'commitPolicyTimeout'; Type = 'Int'; Mandatory = $false; Validation = 'Range' }
|
||||||
@{ParameterName = 'forceShutdown'; Type = 'Switch'; Mandatory = $false; Validation = $null }
|
@{ParameterName = 'forceShutdown'; Type = 'Switch'; Mandatory = $false; Validation = $null }
|
||||||
@{ParameterName = 'disableReverseProtection'; Type = 'Switch'; Mandatory = $true; Validation = $null }
|
@{ParameterName = 'disableReverseProtection'; Type = 'Switch'; Mandatory = $false; Validation = $null }
|
||||||
@{ParameterName = 'keepSourceVms'; Type = 'Switch'; Mandatory = $true; Validation = $null }
|
@{ParameterName = 'keepSourceVms'; Type = 'Switch'; Mandatory = $false; Validation = $null }
|
||||||
@{ParameterName = 'ContinueOnPreScriptFailure'; Type = 'Switch'; Mandatory = $false; Validation = $null }
|
@{ParameterName = 'ContinueOnPreScriptFailure'; Type = 'Switch'; Mandatory = $false; Validation = $null }
|
||||||
@{ParameterName = 'whatIf'; Type = 'Switch'; Mandatory = $false; Validation = 'ShouldProcess' }
|
@{ParameterName = 'whatIf'; Type = 'Switch'; Mandatory = $false; Validation = 'ShouldProcess' }
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -24,13 +24,13 @@
|
|||||||
},
|
},
|
||||||
"LastTest": null,
|
"LastTest": null,
|
||||||
"Link": {
|
"Link": {
|
||||||
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-38?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
"href": "https://192.168.10.20/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-38?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||||
"identifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-38?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
"identifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-38?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||||
"rel": null,
|
"rel": null,
|
||||||
"type": "VmApi"
|
"type": "VmApi"
|
||||||
},
|
},
|
||||||
"Link_{0}": {
|
"Link_{0}": {
|
||||||
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-38?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
"href": "https://192.168.10.20/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-38?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||||
"rel": "self",
|
"rel": "self",
|
||||||
"type": "VmApi"
|
"type": "VmApi"
|
||||||
},
|
},
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
"OutgoingBandWidthInMbps": 0.001953125,
|
"OutgoingBandWidthInMbps": 0.001953125,
|
||||||
"Priority": 1,
|
"Priority": 1,
|
||||||
"ProtectedSite": {
|
"ProtectedSite": {
|
||||||
"href": "https://192.168.10.20:9669/v1/localsite",
|
"href": "https://192.168.10.20/v1/localsite",
|
||||||
"identifier": "9e09efa0-0d00-46ed-929b-f86273b28205",
|
"identifier": "9e09efa0-0d00-46ed-929b-f86273b28205",
|
||||||
"rel": null,
|
"rel": null,
|
||||||
"type": "LocalSiteApi"
|
"type": "LocalSiteApi"
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
"ProvisionedStorageInMB": 77906,
|
"ProvisionedStorageInMB": 77906,
|
||||||
"RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15",
|
"RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15",
|
||||||
"RecoverySite": {
|
"RecoverySite": {
|
||||||
"href": "https://192.168.10.20:9669/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
|
"href": "https://192.168.10.20/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
|
||||||
"identifier": "057cab27-f02a-443a-989d-7f14341fa9c3",
|
"identifier": "057cab27-f02a-443a-989d-7f14341fa9c3",
|
||||||
"rel": null,
|
"rel": null,
|
||||||
"type": "PeerSiteApi"
|
"type": "PeerSiteApi"
|
||||||
@@ -92,13 +92,13 @@
|
|||||||
},
|
},
|
||||||
"LastTest": null,
|
"LastTest": null,
|
||||||
"Link": {
|
"Link": {
|
||||||
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-37?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
"href": "https://192.168.10.20/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-37?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||||
"identifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-37?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
"identifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-37?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||||
"rel": null,
|
"rel": null,
|
||||||
"type": "VmApi"
|
"type": "VmApi"
|
||||||
},
|
},
|
||||||
"Link_{0}": {
|
"Link_{0}": {
|
||||||
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-37?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
"href": "https://192.168.10.20/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-37?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||||
"rel": "self",
|
"rel": "self",
|
||||||
"type": "VmApi"
|
"type": "VmApi"
|
||||||
},
|
},
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
"OutgoingBandWidthInMbps": 0.0009765625,
|
"OutgoingBandWidthInMbps": 0.0009765625,
|
||||||
"Priority": 1,
|
"Priority": 1,
|
||||||
"ProtectedSite": {
|
"ProtectedSite": {
|
||||||
"href": "https://192.168.10.20:9669/v1/localsite",
|
"href": "https://192.168.10.20/v1/localsite",
|
||||||
"identifier": "9e09efa0-0d00-46ed-929b-f86273b28205",
|
"identifier": "9e09efa0-0d00-46ed-929b-f86273b28205",
|
||||||
"rel": null,
|
"rel": null,
|
||||||
"type": "LocalSiteApi"
|
"type": "LocalSiteApi"
|
||||||
@@ -114,7 +114,7 @@
|
|||||||
"ProvisionedStorageInMB": 77906,
|
"ProvisionedStorageInMB": 77906,
|
||||||
"RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15",
|
"RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15",
|
||||||
"RecoverySite": {
|
"RecoverySite": {
|
||||||
"href": "https://192.168.10.20:9669/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
|
"href": "https://192.168.10.20/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
|
||||||
"identifier": "057cab27-f02a-443a-989d-7f14341fa9c3",
|
"identifier": "057cab27-f02a-443a-989d-7f14341fa9c3",
|
||||||
"rel": null,
|
"rel": null,
|
||||||
"type": "PeerSiteApi"
|
"type": "PeerSiteApi"
|
||||||
@@ -160,13 +160,13 @@
|
|||||||
},
|
},
|
||||||
"LastTest": null,
|
"LastTest": null,
|
||||||
"Link": {
|
"Link": {
|
||||||
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-36?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
"href": "https://192.168.10.20/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-36?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||||
"identifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-36?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
"identifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-36?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||||
"rel": null,
|
"rel": null,
|
||||||
"type": "VmApi"
|
"type": "VmApi"
|
||||||
},
|
},
|
||||||
"Link_{0}": {
|
"Link_{0}": {
|
||||||
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-36?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
"href": "https://192.168.10.20/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-36?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||||
"rel": "self",
|
"rel": "self",
|
||||||
"type": "VmApi"
|
"type": "VmApi"
|
||||||
},
|
},
|
||||||
@@ -174,7 +174,7 @@
|
|||||||
"OutgoingBandWidthInMbps": 0.00146484375,
|
"OutgoingBandWidthInMbps": 0.00146484375,
|
||||||
"Priority": 1,
|
"Priority": 1,
|
||||||
"ProtectedSite": {
|
"ProtectedSite": {
|
||||||
"href": "https://192.168.10.20:9669/v1/localsite",
|
"href": "https://192.168.10.20/v1/localsite",
|
||||||
"identifier": "9e09efa0-0d00-46ed-929b-f86273b28205",
|
"identifier": "9e09efa0-0d00-46ed-929b-f86273b28205",
|
||||||
"rel": null,
|
"rel": null,
|
||||||
"type": "LocalSiteApi"
|
"type": "LocalSiteApi"
|
||||||
@@ -182,7 +182,7 @@
|
|||||||
"ProvisionedStorageInMB": 77906,
|
"ProvisionedStorageInMB": 77906,
|
||||||
"RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15",
|
"RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15",
|
||||||
"RecoverySite": {
|
"RecoverySite": {
|
||||||
"href": "https://192.168.10.20:9669/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
|
"href": "https://192.168.10.20/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
|
||||||
"identifier": "057cab27-f02a-443a-989d-7f14341fa9c3",
|
"identifier": "057cab27-f02a-443a-989d-7f14341fa9c3",
|
||||||
"rel": null,
|
"rel": null,
|
||||||
"type": "PeerSiteApi"
|
"type": "PeerSiteApi"
|
||||||
@@ -228,13 +228,13 @@
|
|||||||
},
|
},
|
||||||
"LastTest": null,
|
"LastTest": null,
|
||||||
"Link": {
|
"Link": {
|
||||||
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-26?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
"href": "https://192.168.10.20/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-26?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||||
"identifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-26?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
"identifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-26?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||||
"rel": null,
|
"rel": null,
|
||||||
"type": "VmApi"
|
"type": "VmApi"
|
||||||
},
|
},
|
||||||
"Link_{0}": {
|
"Link_{0}": {
|
||||||
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-26?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
"href": "https://192.168.10.20/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-26?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||||
"rel": "self",
|
"rel": "self",
|
||||||
"type": "VmApi"
|
"type": "VmApi"
|
||||||
},
|
},
|
||||||
@@ -242,7 +242,7 @@
|
|||||||
"OutgoingBandWidthInMbps": 0.01953125,
|
"OutgoingBandWidthInMbps": 0.01953125,
|
||||||
"Priority": 1,
|
"Priority": 1,
|
||||||
"ProtectedSite": {
|
"ProtectedSite": {
|
||||||
"href": "https://192.168.10.20:9669/v1/localsite",
|
"href": "https://192.168.10.20/v1/localsite",
|
||||||
"identifier": "9e09efa0-0d00-46ed-929b-f86273b28205",
|
"identifier": "9e09efa0-0d00-46ed-929b-f86273b28205",
|
||||||
"rel": null,
|
"rel": null,
|
||||||
"type": "LocalSiteApi"
|
"type": "LocalSiteApi"
|
||||||
@@ -250,7 +250,7 @@
|
|||||||
"ProvisionedStorageInMB": 102400,
|
"ProvisionedStorageInMB": 102400,
|
||||||
"RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15",
|
"RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15",
|
||||||
"RecoverySite": {
|
"RecoverySite": {
|
||||||
"href": "https://192.168.10.20:9669/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
|
"href": "https://192.168.10.20/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
|
||||||
"identifier": "057cab27-f02a-443a-989d-7f14341fa9c3",
|
"identifier": "057cab27-f02a-443a-989d-7f14341fa9c3",
|
||||||
"rel": null,
|
"rel": null,
|
||||||
"type": "PeerSiteApi"
|
"type": "PeerSiteApi"
|
||||||
|
|||||||
@@ -28,13 +28,13 @@
|
|||||||
"IOPs": 8,
|
"IOPs": 8,
|
||||||
"LastTest": "2019-07-11T16:51:07.022Z",
|
"LastTest": "2019-07-11T16:51:07.022Z",
|
||||||
"Link": {
|
"Link": {
|
||||||
"href": "https://192.168.222.1:7669/v1/vpgs/99c460c1-a4ec-48dd-8921-bbcca9cd29b9",
|
"href": "https://192.168.222.1/v1/vpgs/99c460c1-a4ec-48dd-8921-bbcca9cd29b9",
|
||||||
"identifier": "99c460c1-a4ec-48dd-8921-bbcca9cd29b9",
|
"identifier": "99c460c1-a4ec-48dd-8921-bbcca9cd29b9",
|
||||||
"rel": null,
|
"rel": null,
|
||||||
"type": "VpgApi"
|
"type": "VpgApi"
|
||||||
},
|
},
|
||||||
"Link_{0}": {
|
"Link_{0}": {
|
||||||
"href": "https://192.168.222.1:7669/v1/vpgs/99c460c1-a4ec-48dd-8921-bbcca9cd29b9",
|
"href": "https://192.168.222.1/v1/vpgs/99c460c1-a4ec-48dd-8921-bbcca9cd29b9",
|
||||||
"rel": "self",
|
"rel": "self",
|
||||||
"type": "VpgApi"
|
"type": "VpgApi"
|
||||||
},
|
},
|
||||||
@@ -42,14 +42,14 @@
|
|||||||
"Priority": 1,
|
"Priority": 1,
|
||||||
"ProgressPercentage": 0,
|
"ProgressPercentage": 0,
|
||||||
"ProtectedSite": {
|
"ProtectedSite": {
|
||||||
"href": "https://192.168.222.1:7669/v1/localsite",
|
"href": "https://192.168.222.1/v1/localsite",
|
||||||
"identifier": "63a62dc2-ef6f-45aa-809f-9dbaeb8c06cf",
|
"identifier": "63a62dc2-ef6f-45aa-809f-9dbaeb8c06cf",
|
||||||
"rel": null,
|
"rel": null,
|
||||||
"type": "LocalSiteApi"
|
"type": "LocalSiteApi"
|
||||||
},
|
},
|
||||||
"ProvisionedStorageInMB": 400,
|
"ProvisionedStorageInMB": 400,
|
||||||
"RecoverySite": {
|
"RecoverySite": {
|
||||||
"href": "https://192.168.222.1:7669/v1/peersites/3e4cdd0d-1064-4022-921f-6265ad6d335a",
|
"href": "https://192.168.222.1/v1/peersites/3e4cdd0d-1064-4022-921f-6265ad6d335a",
|
||||||
"identifier": "3e4cdd0d-1064-4022-921f-6265ad6d335a",
|
"identifier": "3e4cdd0d-1064-4022-921f-6265ad6d335a",
|
||||||
"rel": null,
|
"rel": null,
|
||||||
"type": "PeerSiteApi"
|
"type": "PeerSiteApi"
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
"VpgIdentifier": "99c460c1-a4ec-48dd-8921-bbcca9cd29b9",
|
"VpgIdentifier": "99c460c1-a4ec-48dd-8921-bbcca9cd29b9",
|
||||||
"VpgName": "Exchange",
|
"VpgName": "Exchange",
|
||||||
"Zorg": {
|
"Zorg": {
|
||||||
"href": "https://192.168.222.1:7669/v1/zorgs/00000000-0000-0000-0000-000000000000",
|
"href": "https://192.168.222.1/v1/zorgs/00000000-0000-0000-0000-000000000000",
|
||||||
"identifier": "00000000-0000-0000-0000-000000000000",
|
"identifier": "00000000-0000-0000-0000-000000000000",
|
||||||
"rel": null,
|
"rel": null,
|
||||||
"type": "ZorgApi"
|
"type": "ZorgApi"
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
#Requires -Modules Pester
|
||||||
|
$global:here = (Split-Path -Parent $PSCommandPath)
|
||||||
|
$global:function = ((Split-Path -Leaf $PSCommandPath).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 15 parameters defined" {
|
||||||
|
(Get-Command $global:function).Parameters.Count | Should -Be 15
|
||||||
|
}
|
||||||
|
|
||||||
|
$ParameterTestCases = @(
|
||||||
|
@{ParameterName = 'Vm'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||||
|
@{ParameterName = 'VpgName'; Type = 'String'; Mandatory = $true; 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 "<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
|
||||||
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
|
$true | Should -Be $false -Because "No Validation Selected. Review test cases"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 "Add-ZertoPeerSite::Functional Unit Tests" {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Remove-Variable -Name here -Scope Global
|
||||||
|
Remove-Variable -Name function -Scope Global
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
SkipPublisherCheck = $true
|
SkipPublisherCheck = $true
|
||||||
}
|
}
|
||||||
Target = 'CurrentUser'
|
Target = 'CurrentUser'
|
||||||
Version = '5.5.11'
|
Version = '5.6.0'
|
||||||
Tags = 'Bootstrap'
|
Tags = 'Bootstrap'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
SkipPublisherCheck = $true
|
SkipPublisherCheck = $true
|
||||||
}
|
}
|
||||||
Target = 'CurrentUser'
|
Target = 'CurrentUser'
|
||||||
Version = '1.18.3'
|
Version = '1.21.0'
|
||||||
Tags = 'Bootstrap'
|
Tags = 'Bootstrap'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+60
-59
@@ -1,23 +1,24 @@
|
|||||||
#Requires -Modules 'InvokeBuild'
|
#Requires -Modules 'InvokeBuild'
|
||||||
|
|
||||||
$version = "{0}" -f $(Get-Content .\version.txt)
|
$version = "{0}" -f $(Get-Content .\version.txt)
|
||||||
|
$moduleOutPath = "{0}\publish\ZertoApiWrapper" -f $BuildRoot
|
||||||
|
|
||||||
#Define the default task
|
#Define the default task
|
||||||
task . CreateArtifacts
|
task . build
|
||||||
|
|
||||||
#Region - Helper Functions
|
#Region - Helper Functions
|
||||||
function ImportSourceModule() {
|
function ImportSourceModule {
|
||||||
If (Get-Module -Name ZertoApiWrapper) {
|
If (Get-Module -Name ZertoApiWrapper) {
|
||||||
Remove-Module -Name ZertoApiWrapper -Force -ErrorAction Stop
|
Remove-Module -Name ZertoApiWrapper -Force -ErrorAction Stop
|
||||||
}
|
}
|
||||||
Import-Module "$BuildRoot\ZertoApiWrapper\ZertoApiWrapper.psd1" -ErrorAction Stop
|
Import-Module "$BuildRoot\ZertoApiWrapper\ZertoApiWrapper.psd1" -ErrorAction Stop
|
||||||
}
|
}
|
||||||
|
|
||||||
function ImportBuiltModule() {
|
function ImportBuiltModule {
|
||||||
If (Get-Module -Name ZertoApiWrapper) {
|
If (Get-Module -Name ZertoApiWrapper) {
|
||||||
Remove-Module -Name ZertoApiWrapper -Force -ErrorAction Stop
|
Remove-Module -Name ZertoApiWrapper -Force -ErrorAction Stop
|
||||||
}
|
}
|
||||||
Import-Module "$BuildRoot\temp\ZertoApiWrapper.psd1" -ErrorAction Stop
|
Import-Module ("{0}\ZertoApiWrapper.psd1" -f $moduleOutPath) -ErrorAction Stop
|
||||||
}
|
}
|
||||||
#EndRegion
|
#EndRegion
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ task CheckPSScriptAnalyzerInstalled {
|
|||||||
task AnalyzeSourceFiles CheckPSScriptAnalyzerInstalled, {
|
task AnalyzeSourceFiles CheckPSScriptAnalyzerInstalled, {
|
||||||
$scriptAnalyzerParams = @{
|
$scriptAnalyzerParams = @{
|
||||||
Path = "$BuildRoot\ZertoApiWrapper\"
|
Path = "$BuildRoot\ZertoApiWrapper\"
|
||||||
Severity = @('Error', 'Warning')
|
Severity = @('Error') #, 'Warning')
|
||||||
Recurse = $true
|
Recurse = $true
|
||||||
Verbose = $false
|
Verbose = $false
|
||||||
ExcludeRule = @('PSUseToExportFieldsInManifest', 'PSUseBOMForUnicodeEncodedFile', 'PSUseSingularNouns', 'PSReviewUnusedParameter')
|
ExcludeRule = @('PSUseToExportFieldsInManifest', 'PSUseBOMForUnicodeEncodedFile', 'PSUseSingularNouns', 'PSReviewUnusedParameter')
|
||||||
@@ -65,8 +66,8 @@ task AnalyzeSourceFiles CheckPSScriptAnalyzerInstalled, {
|
|||||||
|
|
||||||
task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, CreatePsm1ForRelease, {
|
task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, CreatePsm1ForRelease, {
|
||||||
$scriptAnalyzerParams = @{
|
$scriptAnalyzerParams = @{
|
||||||
Path = "$BuildRoot\temp\"
|
Path = $moduleOutPath
|
||||||
Severity = @('Error', 'Warning')
|
Severity = @('Error') #, 'Warning')
|
||||||
Recurse = $true
|
Recurse = $true
|
||||||
Verbose = $false
|
Verbose = $false
|
||||||
ExcludeRule = @('PSUseSingularNouns', 'PSUseBOMForUnicodeEncodedFile', 'PSReviewUnusedParameter')
|
ExcludeRule = @('PSUseSingularNouns', 'PSUseBOMForUnicodeEncodedFile', 'PSReviewUnusedParameter')
|
||||||
@@ -81,42 +82,38 @@ task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, CreatePsm1ForRelease, {
|
|||||||
#EndRegion
|
#EndRegion
|
||||||
|
|
||||||
#Region - Clean Operations
|
#Region - Clean Operations
|
||||||
task CleanTemp {
|
|
||||||
if (-not $(Test-Path "$BuildRoot\temp")) {
|
|
||||||
New-Item -Path $BuildRoot -Name "temp" -ItemType "Directory"
|
|
||||||
}
|
|
||||||
Remove-Item -Recurse -Path "$BuildRoot\temp\*"
|
|
||||||
}
|
|
||||||
|
|
||||||
task CleanPublish {
|
task CleanPublish {
|
||||||
if ($(Test-Path "$BuildRoot\publish")) {
|
if ($(Test-Path "$BuildRoot\publish")) {
|
||||||
Remove-Item -Recurse -Path "$BuildRoot\publish\*"
|
Remove-Item -Recurse -Path "$BuildRoot\publish\*"
|
||||||
|
} else {
|
||||||
|
New-Item -Path $BuildRoot -Name "publish" -ItemType Directory
|
||||||
}
|
}
|
||||||
|
New-Item -Path $moduleOutPath -ItemType "Directory"
|
||||||
}
|
}
|
||||||
#EndRegion
|
#EndRegion
|
||||||
|
|
||||||
#Region - Pester Tests
|
#Region - Pester Tests
|
||||||
task SourceFileTests CheckPesterInstalled, {
|
#task SourceFileTests CheckPesterInstalled, {
|
||||||
ImportSourceModule
|
# ImportSourceModule
|
||||||
$testResultsFile = "$BuildRoot\Tests\SourceTestResults.xml"
|
# $testResultsFile = "$BuildRoot\Tests\SourceTestResults.xml"
|
||||||
$script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru -Show Fails
|
# $script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru -Show Fails
|
||||||
$FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount
|
# $FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount
|
||||||
Assert ($results.FailedCount -eq 0) $FailureMessage
|
# Assert ($results.FailedCount -eq 0) $FailureMessage
|
||||||
}
|
#}
|
||||||
|
|
||||||
task BuiltFileTests CreatePsm1ForRelease, CheckPesterInstalled, {
|
#task BuiltFileTests CreatePsm1ForRelease, CheckPesterInstalled, {
|
||||||
ImportBuiltModule
|
# ImportBuiltModule
|
||||||
$testResultsFile = "$BuildRoot\Tests\BuiltTestResults.xml"
|
# $testResultsFile = "$BuildRoot\Tests\BuiltTestResults.xml"
|
||||||
$script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru -Show Fails
|
# $script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru -Show Failed
|
||||||
$FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount
|
# $FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount
|
||||||
Assert ($results.FailedCount -eq 0) $FailureMessage
|
# Assert ($results.FailedCount -eq 0) $FailureMessage
|
||||||
}
|
#}
|
||||||
#EndRegion
|
#EndRegion
|
||||||
|
|
||||||
#Region - Build Help System
|
#Region - Build Help System
|
||||||
$buildMamlParams = @{
|
$buildMamlParams = @{
|
||||||
Inputs = { Get-ChildItem docs\*.md }
|
Inputs = { Get-ChildItem docs\*.md }
|
||||||
Outputs = "$BuildRoot\temp\en-us\ZertoApiWrapper-help.xml"
|
Outputs = "{0}\en-us\ZertoApiWrapper-help.xml" -f $moduleOutPath
|
||||||
}
|
}
|
||||||
|
|
||||||
task BuildMamlHelp CheckPlatyPSInstalled, {
|
task BuildMamlHelp CheckPlatyPSInstalled, {
|
||||||
@@ -126,19 +123,19 @@ task BuildMamlHelp CheckPlatyPSInstalled, {
|
|||||||
platyPS\New-ExternalHelp .\docs -Force -OutputPath $buildMamlParams.Outputs
|
platyPS\New-ExternalHelp .\docs -Force -OutputPath $buildMamlParams.Outputs
|
||||||
}
|
}
|
||||||
|
|
||||||
task UpdateMarkdownHelp CheckPlatyPSInstalled, {
|
task UpdateMarkdownHelp quickBuild, CheckPlatyPSInstalled, {
|
||||||
ImportSourceModule
|
ImportBuiltModule
|
||||||
Update-MarkdownHelpModule -Path docs -AlphabeticParamsOrder
|
Update-MarkdownHelpModule -Path docs -AlphabeticParamsOrder
|
||||||
}
|
}
|
||||||
#EndRegion
|
#EndRegion
|
||||||
|
|
||||||
#Region - Build Module Files
|
#Region - Build Module Files
|
||||||
task CreatePsd1ForRelease CleanTemp, {
|
task CreatePsd1ForRelease CleanPublish, {
|
||||||
$functionsToExport = Get-ChildItem -Path 'ZertoApiWrapper\Public\*.ps1' | ForEach-Object { $_.BaseName }
|
$functionsToExport = Get-ChildItem -Path 'ZertoApiWrapper\Public\*.ps1' | ForEach-Object { $_.BaseName }
|
||||||
$releaseNotes = "Please review the [Release Notes](https://github.com/ZertoPublic/ZertoApiWrapper/releases/tag/{0}) on GitHub." -f $version
|
$releaseNotes = "Please review the [Release Notes](https://github.com/ZertoPublic/ZertoApiWrapper/releases/tag/{0}) on GitHub." -f $version
|
||||||
|
|
||||||
$ManifestParams = @{
|
$ManifestParams = @{
|
||||||
Path = "$BuildRoot\temp\ZertoApiWrapper.psd1"
|
Path = "{0}\ZertoApiWrapper.psd1" -f $moduleOutPath
|
||||||
RootModule = 'ZertoApiWrapper.psm1'
|
RootModule = 'ZertoApiWrapper.psm1'
|
||||||
ModuleVersion = $version
|
ModuleVersion = $version
|
||||||
GUID = '4c0b9e17-141b-4dd5-8549-fb21cccaa325'
|
GUID = '4c0b9e17-141b-4dd5-8549-fb21cccaa325'
|
||||||
@@ -161,43 +158,47 @@ task CreatePsd1ForRelease CleanTemp, {
|
|||||||
|
|
||||||
task CreatePsm1ForRelease CreatePsd1ForRelease, {
|
task CreatePsm1ForRelease CreatePsd1ForRelease, {
|
||||||
$emptyLine = ""
|
$emptyLine = ""
|
||||||
$psm1Path = "$BuildRoot\temp\ZertoApiWrapper.psm1"
|
$psm1Path = "{0}\ZertoApiWrapper.psm1" -f $moduleOutPath
|
||||||
$lines = '#------------------------------------------------------------#'
|
$lines = '#------------------------------------------------------------#'
|
||||||
$Private = @( Get-ChildItem -Path $BuildRoot\ZertoApiWrapper\Private\*.ps1 -ErrorAction Stop )
|
$Private = @( Get-ChildItem -Path $BuildRoot\ZertoApiWrapper\Private\*.ps1 -ErrorAction Stop )
|
||||||
$Public = @( Get-ChildItem -Path $BuildRoot\ZertoApiWrapper\Public\*.ps1 -ErrorAction Stop )
|
$Public = @( Get-ChildItem -Path $BuildRoot\ZertoApiWrapper\Public\*.ps1 -ErrorAction Stop )
|
||||||
Add-Content -Path $psm1Path -Value $lines
|
Add-Content -Path $psm1Path -Value $lines -Encoding 'utf8'
|
||||||
Add-Content -Path $psm1Path -Value "#---------------------Private Functions----------------------#"
|
Add-Content -Path $psm1Path -Value "#---------------------Private Functions----------------------#" -Encoding 'utf8'
|
||||||
Add-Content -Path $psm1Path -Value $lines
|
Add-Content -Path $psm1Path -Value $lines -Encoding 'utf8'
|
||||||
Add-Content -Path $psm1Path -Value $emptyLine
|
Add-Content -Path $psm1Path -Value $emptyLine -Encoding 'utf8'
|
||||||
foreach ($file in $private) {
|
foreach ($file in $private) {
|
||||||
Add-Content -Path $psm1Path -Value $(Get-Content -Path $file.Fullname -Raw)
|
Add-Content -Path $psm1Path -Value $(Get-Content -Path $file.Fullname -Raw) -Encoding 'utf8'
|
||||||
Add-Content -Path $psm1Path -Value $emptyLine
|
Add-Content -Path $psm1Path -Value $emptyLine -Encoding 'utf8'
|
||||||
}
|
}
|
||||||
Add-Content -Path $psm1Path -Value $lines
|
Add-Content -Path $psm1Path -Value $lines -Encoding 'utf8'
|
||||||
Add-Content -Path $psm1Path -Value "#----------------------Public Functions----------------------#"
|
Add-Content -Path $psm1Path -Value "#----------------------Public Functions----------------------#" -Encoding 'utf8'
|
||||||
Add-Content -Path $psm1Path -Value $lines
|
Add-Content -Path $psm1Path -Value $lines -Encoding 'utf8'
|
||||||
Add-Content -Path $psm1Path -Value $emptyLine
|
Add-Content -Path $psm1Path -Value $emptyLine -Encoding 'utf8'
|
||||||
foreach ($file in $public) {
|
foreach ($file in $public) {
|
||||||
Add-Content -Path $psm1Path -Value $(Get-Content -Path $file.Fullname -Raw)
|
Add-Content -Path $psm1Path -Value $(Get-Content -Path $file.Fullname -Raw) -Encoding 'utf8'
|
||||||
Add-Content -Path $psm1Path -Value $emptyLine
|
Add-Content -Path $psm1Path -Value $emptyLine -Encoding 'utf8'
|
||||||
}
|
}
|
||||||
# Add-Content -Path $psm1Path -Value $emptyLine
|
|
||||||
# Add-Content -Path $psm1Path -Value "Export-ModuleMember -Function $exportString"
|
|
||||||
}
|
}
|
||||||
#EndRegion
|
#EndRegion
|
||||||
|
|
||||||
#Region - Artifacts \ Publish
|
#Region - Artifacts \ Publish
|
||||||
# Full Build Process - No Publishing
|
# Full Build Process - No Publishing add this later \/ BuiltFileTests,
|
||||||
task CreateArtifacts CleanPublish, CleanTemp, AnalyzeSourceFiles, SourceFileTests, AnalyzeBuiltFiles, BuiltFileTests, BuildMamlHelp, {
|
task CreateArtifacts CleanPublish, AnalyzeBuiltFiles, BuildMamlHelp, {
|
||||||
if (-not $(Test-Path "$BuildRoot\publish")) {
|
Compress-Archive -Path $moduleOutPath -DestinationPath .\publish\ZertoApiWrapper.zip
|
||||||
New-Item -Path $BuildRoot -Name "publish" -ItemType Directory
|
$MyMatches = Select-String -Path "$BuildRoot\CHANGELOG.md" "^##\s\["
|
||||||
|
$data = Get-Content "$BuildRoot\CHANGELOG.md"
|
||||||
|
$range = ($MyMatches[0].LineNumber - 1)..($MyMatches[1].LineNumber - 3)
|
||||||
|
foreach ($i in $range) {
|
||||||
|
Add-Content -Path "$BuildRoot\publish\ReleaseNotes.md" -Value ($data[$i]).replace("## ", "# ") -Encoding utf8
|
||||||
}
|
}
|
||||||
Compress-Archive -Path .\temp\* -DestinationPath .\publish\ZertoApiWrapper.zip
|
|
||||||
#ImportBuiltModule
|
|
||||||
#(Get-Module ZertoApiWrapper).ReleaseNotes | Add-Content .\publish\release-notes.txt
|
|
||||||
#(Get-Module ZertoApiWrapper).Version.ToString() | Add-Content .\publish\release-version.txt
|
|
||||||
Copy-Item "$BuildRoot\ZertoApiWrapper.build.ps1" "$BuildRoot\publish\ZertoApiWrapper.build.ps1"
|
|
||||||
Copy-Item "$BuildRoot\ZertoApiWrapper.Depend.psd1" "$BuildRoot\publish\ZertoApiWrapper.Depend.psd1"
|
|
||||||
Copy-Item "$BuildRoot\build.ps1" "$BuildRoot\publish\build.ps1"
|
|
||||||
}
|
}
|
||||||
#EndRegion
|
#EndRegion
|
||||||
|
# addd back to line below between analyze and create BuiltFileTests,
|
||||||
|
task build CleanPublish, CreatePsm1ForRelease, AnalyzeBuiltFiles, CreateArtifacts
|
||||||
|
task quickBuild CleanPublish, CreatePsm1ForRelease, AnalyzeBuiltFiles, {
|
||||||
|
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||||
|
ImportBuiltModule
|
||||||
|
}
|
||||||
|
task release build, {
|
||||||
|
Publish-Module -Path $moduleOutPath -NuGetApiKey "1234" -WhatIf
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,15 +6,15 @@ function Add-ZertoPeerSite {
|
|||||||
Mandatory,
|
Mandatory,
|
||||||
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]$_ } )]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]$targetHost,
|
[string]$targetHost,
|
||||||
[Parameter(
|
[Parameter(
|
||||||
HelpMessage = "Target communication port. Default is 9081"
|
HelpMessage = "Target communication port. Default is 9071 for Zerto 10.0 and Later. For ZVR 9.7 and earlier, use port 9081."
|
||||||
)]
|
)]
|
||||||
[ValidateRange(1024, 65535)]
|
[ValidateRange(1024, 65535)]
|
||||||
[int]$targetPort = 9081,
|
[int]$targetPort = 9071,
|
||||||
[Parameter(
|
[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."
|
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 10.0 and later."
|
||||||
)]
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]$token
|
[string]$token
|
||||||
|
|||||||
@@ -0,0 +1,104 @@
|
|||||||
|
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||||
|
function Add-ZertoVpgVm {
|
||||||
|
[CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = "VpgName")]
|
||||||
|
param (
|
||||||
|
[Parameter(
|
||||||
|
Mandatory,
|
||||||
|
HelpMessage = "Vpg Settings Identifier",
|
||||||
|
ValueFromPipeline,
|
||||||
|
ValueFromPipelineByPropertyName,
|
||||||
|
ValueFromRemainingArguments,
|
||||||
|
ParameterSetName = "VpgSettingsIdentifier"
|
||||||
|
)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[Alias("sid", "settingsIdentifier", "vpgSettingsId")]
|
||||||
|
[String]$vpgSettingsIdentifier,
|
||||||
|
[Parameter(
|
||||||
|
Mandatory,
|
||||||
|
HelpMessage = "Target VPG Name to Add the VM",
|
||||||
|
ParameterSetName = "VpgName"
|
||||||
|
)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[String]$VpgName,
|
||||||
|
[Parameter(
|
||||||
|
Mandatory,
|
||||||
|
HelpMessage = "Name of VM(s) to add to the VPG"
|
||||||
|
)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[String[]]$Vm
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
if ($PSCmdlet.ParameterSetName -eq "VpgName") {
|
||||||
|
$VpgIdentifier = Get-ZertoVpg -name $VpgName | Select-Object -ExpandProperty VpgIdentifier
|
||||||
|
if (-not $VpgIdentifier) {
|
||||||
|
Write-Error "Unable to find Vpg with name $VpgName. Please check your parameters and try again." -ErrorAction Stop
|
||||||
|
} else {
|
||||||
|
$vpgSettingsIdentifier = New-ZertoVpgSettingsIdentifier -vpgIdentifier $VpgIdentifier
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$baseUrl = "vpgsettings/{0}/vms" -f $vpgSettingsIdentifier
|
||||||
|
$baseSettings = Get-ZertoVpgSetting -vpgSettingsIdentifier $vpgSettingsIdentifier
|
||||||
|
if ($PSCmdlet.ParameterSetName -eq "VpgSettingsIdentifier") {
|
||||||
|
$VpgName = $baseSettings.Basic.Name
|
||||||
|
}
|
||||||
|
$unprotectedVms = Get-ZertoUnprotectedVm
|
||||||
|
$protectedVms = Get-ZertoProtectedVm
|
||||||
|
$vmMap = Get-Map -inputObject $unprotectedVms -key VmName -value VmIdentifier
|
||||||
|
$vmMap = $vmMap + (Get-Map -inputObject $protectedVms -key VmName -value VmIdentifier)
|
||||||
|
# Create array of VM identifiers
|
||||||
|
$vmIdentifiers = foreach ($machine in ($Vm | Select-Object -Unique)) {
|
||||||
|
if ($vmMap[$machine] -notin $baseSettings.Vms.vmIdentifier ) {
|
||||||
|
# If the VM is unprotected, get the identifier
|
||||||
|
$vmIdentifier = $unprotectedVms | Where-Object { $_.vmName -like $machine } | Select-Object -ExpandProperty vmIdentifier
|
||||||
|
# If the VM is not unprotected, check the protected VMs
|
||||||
|
if ( -not $vmIdentifier) {
|
||||||
|
# Get all identifiers to test if the VM is eligible to be a member of an additional VPG
|
||||||
|
$results = $protectedVms | Where-Object { $_.VmName -like $machine } | Select-Object -ExpandProperty vmIdentifier
|
||||||
|
$recoverySiteIdentifiers = $protectedVms | Where-Object { $_.VmName -like $machine } | Select-Object -ExpandProperty RecoverySite | Select-Object -ExpandProperty identifier
|
||||||
|
# If VM is currently a member of 3 VPGs, skip it. If it cannot be found, skip it. Otherwise, set the identifier
|
||||||
|
if ($baseSettings.basic.RecoverySiteIdentifier -in $recoverySiteIdentifiers) {
|
||||||
|
Write-Warning "$machine is already replicating to target site. It cannot be added to an additional VPG replicating to that site. Please check your configurations and try again. Skipping $machine"
|
||||||
|
continue
|
||||||
|
} elseif ($results.count -eq 3) {
|
||||||
|
Write-Warning "$machine is already a part of 3 VPGs and cannot be part of an additional VPG. Skipping $machine"
|
||||||
|
continue
|
||||||
|
} elseif ($results.count -eq 0) {
|
||||||
|
Write-Warning "$machine not found. Skipping $machine"
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
$vmIdentifier = $results | Select-Object -First 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# Create a custom object to store the information to easily convert to JSON. Return to vmIdentifiers array.
|
||||||
|
$vmIdentifier
|
||||||
|
} else {
|
||||||
|
Write-Warning "$machine is already a member of this VPG Settings object. It will not be added again. Skipping $machine"
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($vmIdentifiers.Count -gt 0 -and $PSCmdlet.ShouldProcess($VmIdentifiers, "Adding VM(s): $Vm to Vpg $VpgName")) {
|
||||||
|
foreach ($id in $VmIdentifiers) {
|
||||||
|
# Build the Body
|
||||||
|
$Body = @{VmIdentifier = $id }
|
||||||
|
# Submit the request. Out to Null to prevent line returns while running.
|
||||||
|
$null = Invoke-ZertoRestRequest -uri $baseUrl -method POST -body ($Body | ConvertTo-Json -Depth 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
$vpgSettingsIdentifier
|
||||||
|
} else {
|
||||||
|
Write-Warning "No VMs found to add. Please check your parameters and try again."
|
||||||
|
if ($PSCmdlet.ParameterSetName -eq "VpgName") {
|
||||||
|
Remove-ZertoVpgSettingsIdentifier -vpgSettingsIdentifier $vpgSettingsIdentifier
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
end {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,32 +5,48 @@ function Connect-ZertoServer {
|
|||||||
param(
|
param(
|
||||||
[Parameter(
|
[Parameter(
|
||||||
Mandatory,
|
Mandatory,
|
||||||
HelpMessage = "IP address or FQDN of your Zerto Management Server"
|
HelpMessage = "IP address or FQDN of your Zerto Management Server",
|
||||||
|
Position = 0
|
||||||
)]
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[Alias("server", "zvm")]
|
[Alias("server", "zvm")]
|
||||||
[string]$zertoServer,
|
[string]$zertoServer,
|
||||||
[Parameter(
|
|
||||||
HelpMessage = "Zerto Virtual Manager management port. Default value is 9669."
|
|
||||||
)]
|
|
||||||
[ValidateNotNullOrEmpty()]
|
|
||||||
[ValidateRange(1024, 65535)]
|
|
||||||
[Alias("port")]
|
|
||||||
[string]$zertoPort = "9669",
|
|
||||||
[Parameter(
|
[Parameter(
|
||||||
Mandatory,
|
Mandatory,
|
||||||
HelpMessage = "Valid credentials to connect to the Zerto Management Server"
|
HelpMessage = "Valid credentials to connect to the Zerto Management Server",
|
||||||
|
Position = 1
|
||||||
)]
|
)]
|
||||||
[System.Management.Automation.PSCredential]$credential,
|
[System.Management.Automation.PSCredential]$credential,
|
||||||
[switch]$returnHeaders
|
[Parameter(
|
||||||
|
HelpMessage = "Zerto Virtual Manager management port. Default value is 443."
|
||||||
|
)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[ValidateRange(443, 65535)]
|
||||||
|
[Alias("port")]
|
||||||
|
[string]$zertoPort = "443",
|
||||||
|
[Parameter(
|
||||||
|
HelpMessage = "Zerto Keycloak client id. Default value is zerto-client."
|
||||||
|
)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[Alias("clientid")]
|
||||||
|
[string]$zertoClientId = "zerto-client",
|
||||||
|
[Parameter(
|
||||||
|
HelpMessage = "Use this switch to indicate that you would like the module to take care of auto re-authorization and reconnection to the ZVM should the token expire. This option will cache your PSCredential object to be reused"
|
||||||
|
)]
|
||||||
|
[switch]$AutoReconnect,
|
||||||
|
[Parameter(
|
||||||
|
HelpMessage = "Use this switch to return the Bearer Token to a specified variable or to the default output."
|
||||||
|
)]
|
||||||
|
[switch]$returnToken
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
$body = '{"AuthenticationMethod": "1"}'
|
$uri = "auth/realms/zerto/protocol/openid-connect/token"
|
||||||
$uri = "session/add"
|
|
||||||
# Set Script Scope Variables for Use in all functions in the module; Server and Port Information
|
# Set Script Scope Variables for Use in all functions in the module; Server and Port Information
|
||||||
Set-Variable -Name zvmServer -Scope Script -Value $zertoServer
|
Set-Variable -Name zvmServer -Scope Script -Value $zertoServer
|
||||||
Set-Variable -Name zvmPort -Scope Script -Value $zertoPort
|
Set-Variable -Name zvmPort -Scope Script -Value $zertoPort
|
||||||
|
Set-Variable -Name zvmClientId -Scope Script -Value $zertoClientId
|
||||||
# Set zvmLastAction Variable to keep track when the API token expires
|
# Set zvmLastAction Variable to keep track when the API token expires
|
||||||
Set-Variable -Name zvmLastAction -Scope Script -Value $(Get-Date).Ticks
|
Set-Variable -Name zvmLastAction -Scope Script -Value $(Get-Date).Ticks
|
||||||
# Set / Clear the zvmHeaders to clear any existing token
|
# Set / Clear the zvmHeaders to clear any existing token
|
||||||
@@ -38,22 +54,25 @@ function Connect-ZertoServer {
|
|||||||
"Accept" = "application/json"
|
"Accept" = "application/json"
|
||||||
"zerto-triggered-by" = "PowershellWes"
|
"zerto-triggered-by" = "PowershellWes"
|
||||||
}
|
}
|
||||||
|
Set-Variable -Name Reconnect -Scope Script -Value $AutoReconnect.IsPresent
|
||||||
|
if ($Script:Reconnect) {
|
||||||
|
Set-Variable -Name CachedCredential -Scope Script -Value $credential
|
||||||
|
}
|
||||||
|
# need to check to see if we need this or if the zvmclientid above is enough
|
||||||
|
Set-Variable -Name zertoClientId -Scope Script -Value $zertoClientId
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
# Send authorization request to the function and send back the results including headers
|
# Send authorization request to the function and send back the results including headers -returnHeaders
|
||||||
$results = Invoke-ZertoRestRequest -uri $uri -credential $credential -returnHeaders -body $body -method POST -ErrorAction Stop
|
$results = Invoke-ZertoRestRequest -uri $uri -credential $credential -method POST -ErrorAction Stop
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
# Build Headers Hashtable with Authorization Token
|
# Build Headers Hashtable with Authorization Token
|
||||||
$Script:zvmHeaders['x-zerto-session'] = $results.Headers['x-zerto-session'][0].ToString()
|
$script:zvmHeaders['Authorization'] = "Bearer " + $results.access_token.ToString()
|
||||||
# Set common Script Scope Variables to be used other functions (Headers and Local Site Info)
|
|
||||||
# Set-Variable -Name zvmHeaders -Scope Script -Value $zertoAuthorizationHeaders
|
|
||||||
Set-Variable -Name zvmLocalInfo -Scope Script -Value (Get-ZertoLocalSite)
|
|
||||||
|
|
||||||
# Have the option to return the headers to a variable
|
# Have the option to return the headers to a variable
|
||||||
if ($returnHeaders) {
|
if ($returnToken) {
|
||||||
return $Script:zvmHeaders
|
return $Script:zvmHeaders
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,14 @@
|
|||||||
function Disconnect-ZertoServer {
|
function Disconnect-ZertoServer {
|
||||||
[cmdletbinding()]
|
[cmdletbinding()]
|
||||||
param()
|
param()
|
||||||
$uri = "session"
|
$uri = "auth/realms/zerto/protocol/openid-connect/logout"
|
||||||
|
|
||||||
# Delete API Authorization
|
# Delete API Authorization
|
||||||
$null = Invoke-ZertoRestRequest -uri $uri -method DELETE
|
$null = Invoke-ZertoRestRequest -uri $uri -method POST
|
||||||
|
|
||||||
# Remove all variables used
|
# Remove all variables used
|
||||||
Remove-Variable -Name zvmServer -Scope Script
|
Remove-Variable -Name zvmServer -Scope Script
|
||||||
Remove-Variable -Name zvmPort -Scope Script
|
Remove-Variable -Name zvmPort -Scope Script
|
||||||
Remove-Variable -Name zvmLastAction -Scope Script
|
Remove-Variable -Name zvmLastAction -Scope Script
|
||||||
Remove-Variable -Name zvmHeaders -Scope Script
|
Remove-Variable -Name zvmHeaders -Scope Script
|
||||||
Remove-Variable -Name zvmLocalInfo -Scope Script
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ function Export-ZertoVpg {
|
|||||||
$vpgSettings = Get-ZertoVpgSetting -vpgSettingsIdentifier $vpgSettingsIdentifier
|
$vpgSettings = Get-ZertoVpgSetting -vpgSettingsIdentifier $vpgSettingsIdentifier
|
||||||
$filePath = "{0}\{1}.json" -f $outputPath, $name
|
$filePath = "{0}\{1}.json" -f $outputPath, $name
|
||||||
$vpgSettings | Convertto-Json -depth 10 | Out-File -FilePath $filePath
|
$vpgSettings | Convertto-Json -depth 10 | Out-File -FilePath $filePath
|
||||||
|
$null = Remove-ZertoVpgSettingsIdentifier -vpgSettingsIdentifier $vpgSettingsIdentifier
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ function Get-ZertoEvent {
|
|||||||
HelpMessage = "The name of the VPG for which you want to return events."
|
HelpMessage = "The name of the VPG for which you want to return events."
|
||||||
)]
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[Alias("vpg")]
|
[Alias("vpgName")]
|
||||||
[string]$vpgName,
|
[string]$vpg,
|
||||||
[Parameter(
|
[Parameter(
|
||||||
ParameterSetName = "filter",
|
ParameterSetName = "filter",
|
||||||
HelpMessage = "The identifier of the VPG for which you want to return events."
|
HelpMessage = "The identifier of the VPG for which you want to return events."
|
||||||
@@ -137,6 +137,10 @@ function Get-ZertoEvent {
|
|||||||
# If a filter is applied, create the filter and return the events that fall in that filter
|
# If a filter is applied, create the filter and return the events that fall in that filter
|
||||||
"filter" {
|
"filter" {
|
||||||
$filter = Get-ZertoApiFilter -filterTable $PSBoundParameters
|
$filter = Get-ZertoApiFilter -filterTable $PSBoundParameters
|
||||||
|
if ($PSBoundParameters.Keys -contains 'vpg') {
|
||||||
|
$vpgIdentifier = (Get-ZertoVpg -name $vpg).vpgIdentifier
|
||||||
|
$filter = $filter.replace("vpg=$vpg", "vpg=$vpgIdentifier")
|
||||||
|
}
|
||||||
$uri = "{0}{1}" -f $baseUri, $filter
|
$uri = "{0}{1}" -f $baseUri, $filter
|
||||||
$returnObject = Invoke-ZertoRestRequest -uri $uri
|
$returnObject = Invoke-ZertoRestRequest -uri $uri
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
function Get-ZertoUnprotectedVm {
|
function Get-ZertoUnprotectedVm {
|
||||||
[cmdletbinding()]
|
[cmdletbinding()]
|
||||||
param()
|
param()
|
||||||
$uri = "virtualizationsites/{0}/vms" -f $script:zvmLocalInfo.siteidentifier
|
$uri = "virtualizationsites/{0}/vms" -f (Get-ZertoLocalSite).siteIdentifier
|
||||||
Invoke-ZertoRestRequest -uri $uri
|
Invoke-ZertoRestRequest -uri $uri
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ function Import-ZertoVmNicSetting {
|
|||||||
$NicUri = "{0}/nics/{1}" -f $uri, $nic.NicIdentifier
|
$NicUri = "{0}/nics/{1}" -f $uri, $nic.NicIdentifier
|
||||||
Invoke-ZertoRestRequest -uri $NicUri -Method "DELETE" > $null
|
Invoke-ZertoRestRequest -uri $NicUri -Method "DELETE" > $null
|
||||||
$nicSettings = Invoke-ZertoRestRequest -uri $NicUri -Method "GET"
|
$nicSettings = Invoke-ZertoRestRequest -uri $NicUri -Method "GET"
|
||||||
|
$nicSettings.failover.Hypervisor.ShouldReplaceIpConfiguration = "True"
|
||||||
$nicSettings.failover.Hypervisor.NetworkIdentifier = $NetworkMap[$vm.LiveNetwork]
|
$nicSettings.failover.Hypervisor.NetworkIdentifier = $NetworkMap[$vm.LiveNetwork]
|
||||||
$nicSettings.failover.Hypervisor.ShouldReplaceMacAddress = $vm.LiveShouldReplaceMac
|
$nicSettings.failover.Hypervisor.ShouldReplaceMacAddress = $vm.LiveShouldReplaceMac
|
||||||
if ($vm.LiveIsDHCP -imatch "true") {
|
if ($vm.LiveIsDHCP -imatch "true") {
|
||||||
@@ -77,6 +78,7 @@ function Import-ZertoVmNicSetting {
|
|||||||
$nicSettings.failover.Hypervisor.IpConfig = $IpConfig
|
$nicSettings.failover.Hypervisor.IpConfig = $IpConfig
|
||||||
$nicSettings.failover.Hypervisor.DnsSuffix = $vm.LiveDnsSuffix
|
$nicSettings.failover.Hypervisor.DnsSuffix = $vm.LiveDnsSuffix
|
||||||
}
|
}
|
||||||
|
$nicSettings.failoverTest.Hypervisor.ShouldReplaceIpConfiguration = "True"
|
||||||
$nicSettings.failoverTest.Hypervisor.NetworkIdentifier = $NetworkMap[$vm.TestNetwork]
|
$nicSettings.failoverTest.Hypervisor.NetworkIdentifier = $NetworkMap[$vm.TestNetwork]
|
||||||
$nicSettings.failoverTest.Hypervisor.ShouldReplaceMacAddress = $vm.TestShouldReplaceMac
|
$nicSettings.failoverTest.Hypervisor.ShouldReplaceMacAddress = $vm.TestShouldReplaceMac
|
||||||
if ($vm.TestIsDHCP -imatch "true" ) {
|
if ($vm.TestIsDHCP -imatch "true" ) {
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ function Install-ZertoVra {
|
|||||||
)]
|
)]
|
||||||
[ValidateRange(1, 16)]
|
[ValidateRange(1, 16)]
|
||||||
[int]$memoryInGB = 3,
|
[int]$memoryInGB = 3,
|
||||||
|
[Parameter(
|
||||||
|
HelpMessage = "Initial number of CPUs to assign to the VRA. Default is 1, Minimum is 1, Maximum is 4"
|
||||||
|
)]
|
||||||
|
[ValidateRange(1, 4)]
|
||||||
|
[int]$NumOfCpus = 1,
|
||||||
[Parameter(
|
[Parameter(
|
||||||
HelpMessage = "Bandwidth group to assign to the VRA. If unspecified will assign to the 'default_group'"
|
HelpMessage = "Bandwidth group to assign to the VRA. If unspecified will assign to the 'default_group'"
|
||||||
)]
|
)]
|
||||||
@@ -111,7 +116,7 @@ function Install-ZertoVra {
|
|||||||
# If the VRA does not exist, proceed with the installation. If it does exist, bypass and
|
# If the VRA does not exist, proceed with the installation. If it does exist, bypass and
|
||||||
if ( -not (Get-ZertoVra -vraName $vraName) ) {
|
if ( -not (Get-ZertoVra -vraName $vraName) ) {
|
||||||
# Get identifiers for each item provided by name.
|
# Get identifiers for each item provided by name.
|
||||||
$siteIdentifier = $script:zvmLocalInfo.SiteIdentifier
|
$siteIdentifier = (Get-ZertoLocalSite).SiteIdentifier
|
||||||
$hostIdentifier = Get-ZertoVirtualizationSite -siteIdentifier $siteIdentifier -hosts | Where-Object { $_.VirtualizationHostName -eq $hostName } | Select-Object hostIdentifier -ExpandProperty hostIdentifier
|
$hostIdentifier = Get-ZertoVirtualizationSite -siteIdentifier $siteIdentifier -hosts | Where-Object { $_.VirtualizationHostName -eq $hostName } | Select-Object hostIdentifier -ExpandProperty hostIdentifier
|
||||||
$networkIdentifier = Get-ZertoVirtualizationSite -siteIdentifier $siteIdentifier -networks | Where-Object { $_.VirtualizationNetworkName -eq $networkName } | Select-Object NetworkIdentifier -ExpandProperty NetworkIdentifier
|
$networkIdentifier = Get-ZertoVirtualizationSite -siteIdentifier $siteIdentifier -networks | Where-Object { $_.VirtualizationNetworkName -eq $networkName } | Select-Object NetworkIdentifier -ExpandProperty NetworkIdentifier
|
||||||
$datastoreIdentifier = Get-ZertoVirtualizationSite -siteIdentifier $siteIdentifier -datastores | Where-Object { $_.DatastoreName -eq $datastoreName } | Select-Object DatastoreIdentifier -ExpandProperty DatastoreIdentifier
|
$datastoreIdentifier = Get-ZertoVirtualizationSite -siteIdentifier $siteIdentifier -datastores | Where-Object { $_.DatastoreName -eq $datastoreName } | Select-Object DatastoreIdentifier -ExpandProperty DatastoreIdentifier
|
||||||
@@ -136,6 +141,7 @@ function Install-ZertoVra {
|
|||||||
}
|
}
|
||||||
$vraBasic['HostIdentifier'] = $hostIdentifier.toString()
|
$vraBasic['HostIdentifier'] = $hostIdentifier.toString()
|
||||||
$vraBasic['MemoryInGB'] = $memoryInGB
|
$vraBasic['MemoryInGB'] = $memoryInGB
|
||||||
|
$vraBasic['NumOfCpus'] = $NumOfCpus
|
||||||
$vraBasic['NetworkIdentifier'] = $networkIdentifier.toString()
|
$vraBasic['NetworkIdentifier'] = $networkIdentifier.toString()
|
||||||
$vraBasic['UsePublicKeyInsteadOfCredentials'] = $true
|
$vraBasic['UsePublicKeyInsteadOfCredentials'] = $true
|
||||||
$vraBasicNetwork = [ordered]@{ }
|
$vraBasicNetwork = [ordered]@{ }
|
||||||
|
|||||||
@@ -1,22 +1,57 @@
|
|||||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||||
function Invoke-ZertoMove {
|
function Invoke-ZertoMove {
|
||||||
[CmdletBinding( DefaultParameterSetName = "main", SupportsShouldProcess = $true )]
|
[CmdletBinding( DefaultParameterSetName = "id", SupportsShouldProcess = $true )]
|
||||||
param(
|
param(
|
||||||
[Parameter(
|
[Parameter(
|
||||||
|
ParameterSetName = 'name',
|
||||||
|
HelpMessage = "Name(s) of the VPG(s) you want to move.",
|
||||||
|
Mandatory
|
||||||
|
)]
|
||||||
|
[Parameter(
|
||||||
|
ParameterSetName = 'commitName',
|
||||||
HelpMessage = "Name(s) of the VPG(s) you want to move.",
|
HelpMessage = "Name(s) of the VPG(s) you want to move.",
|
||||||
Mandatory
|
Mandatory
|
||||||
)]
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string[]]$vpgName,
|
[string[]]$vpgName,
|
||||||
[Parameter(
|
[Parameter(
|
||||||
|
ParameterSetName = 'id',
|
||||||
|
HelpMessage = "ID(s) of the VPG(s) you want to move.",
|
||||||
|
Mandatory,
|
||||||
|
ValueFromPipelineByPropertyName
|
||||||
|
)]
|
||||||
|
[Parameter(
|
||||||
|
ParameterSetName = 'commitId',
|
||||||
|
HelpMessage = "ID(s) of the VPG(s) you want to move.",
|
||||||
|
Mandatory,
|
||||||
|
ValueFromPipelineByPropertyName
|
||||||
|
)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[guid[]]$vpgIdentifier,
|
||||||
|
[Parameter(
|
||||||
|
ParameterSetName = 'commitName',
|
||||||
HelpMessage = "'Rollback': After the seconds specified in the commitValue setting have elapsed, the failover is rolled back.
|
HelpMessage = "'Rollback': After the seconds specified in the commitValue setting have elapsed, the failover is rolled back.
|
||||||
'Commit': After the seconds specified in the commitValue setting have elapsed, the failover continues, committing the virtual machines in the recovery site.
|
'Commit': After the seconds specified in the commitValue setting have elapsed, the failover continues, committing the virtual machines in the recovery site.
|
||||||
'None': The virtual machines in the VPG being failed over remain in the Before Commit state until either they are committed with Commit a failover, or rolled back with Roll back a failover.
|
'None': The virtual machines in the VPG being failed over remain in the Before Commit state until either they are committed with Commit a failover, or rolled back with Roll back a failover.
|
||||||
Default is the Site Settings setting."
|
Default is the Site Settings setting.",
|
||||||
|
Mandatory
|
||||||
|
)]
|
||||||
|
[Parameter(
|
||||||
|
ParameterSetName = 'commitId',
|
||||||
|
HelpMessage = "'Rollback': After the seconds specified in the commitValue setting have elapsed, the failover is rolled back.
|
||||||
|
'Commit': After the seconds specified in the commitValue setting have elapsed, the failover continues, committing the virtual machines in the recovery site.
|
||||||
|
'None': The virtual machines in the VPG being failed over remain in the Before Commit state until either they are committed with Commit a failover, or rolled back with Roll back a failover.
|
||||||
|
Default is the Site Settings setting.",
|
||||||
|
Mandatory
|
||||||
)]
|
)]
|
||||||
[ValidateSet("Rollback", "Commit", "None")]
|
[ValidateSet("Rollback", "Commit", "None")]
|
||||||
[string]$commitPolicy,
|
[string]$commitPolicy,
|
||||||
[Parameter(
|
[Parameter(
|
||||||
|
ParameterSetName = 'commitName',
|
||||||
|
HelpMessage = "The amount of time, in seconds, the Move is in a 'Before Commit' state, before performing the commitPolicy setting. If omitted, the site settings default will be applied."
|
||||||
|
)]
|
||||||
|
[Parameter(
|
||||||
|
ParameterSetName = 'commitId',
|
||||||
HelpMessage = "The amount of time, in seconds, the Move is in a 'Before Commit' state, before performing the commitPolicy setting. If omitted, the site settings default will be applied."
|
HelpMessage = "The amount of time, in seconds, the Move is in a 'Before Commit' state, before performing the commitPolicy setting. If omitted, the site settings default will be applied."
|
||||||
)]
|
)]
|
||||||
# Min 5 Minutes, Max 24 Hours, Default Site Settigns.
|
# Min 5 Minutes, Max 24 Hours, Default Site Settigns.
|
||||||
@@ -27,15 +62,11 @@ function Invoke-ZertoMove {
|
|||||||
)]
|
)]
|
||||||
[switch]$forceShutdown,
|
[switch]$forceShutdown,
|
||||||
[Parameter(
|
[Parameter(
|
||||||
ParameterSetName = "disableReverseProtection",
|
HelpMessage = "Do not enable reverse protection. The VPG definition is kept with the status Needs Configuration and the reverse settings in the VPG definition are not set."
|
||||||
HelpMessage = "Do not enable reverse protection. The VPG definition is kept with the status Needs Configuration and the reverse settings in the VPG definition are not set.",
|
|
||||||
Mandatory
|
|
||||||
)]
|
)]
|
||||||
[switch]$disableReverseProtection,
|
[switch]$disableReverseProtection,
|
||||||
[Parameter(
|
[Parameter(
|
||||||
ParameterSetName = "keepSourceVms",
|
HelpMessage = "Prevent the protected virtual machines from being deleted in the protected site. Using this setting disables reverse protection."
|
||||||
HelpMessage = "Prevent the protected virtual machines from being deleted in the protected site. Using this setting disables reverse protection.",
|
|
||||||
Mandatory
|
|
||||||
)]
|
)]
|
||||||
[switch]$keepSourceVms,
|
[switch]$keepSourceVms,
|
||||||
[Parameter(
|
[Parameter(
|
||||||
@@ -46,52 +77,50 @@ function Invoke-ZertoMove {
|
|||||||
|
|
||||||
begin {
|
begin {
|
||||||
$baseUri = "vpgs"
|
$baseUri = "vpgs"
|
||||||
|
$body = @{
|
||||||
|
forceShutdown = $forceShutdown.IsPresent
|
||||||
|
ContinueOnPreScriptFailure = $ContinueOnPreScriptFailure.IsPresent
|
||||||
|
keepSourceVms = $keepSourceVms.IsPresent
|
||||||
|
reverseProtection = -not $disableReverseProtection.IsPresent
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $keepSourceVms.IsPresent -and -not $disableReverseProtection.IsPresent ) {
|
||||||
|
Write-Verbose 'Disabling reverse protection as keepSourceVms requires it'
|
||||||
|
$body['reverseProtection'] = $false
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($PSBoundParameters.ContainsKey('commitPolicy')) {
|
||||||
|
$body['commitPolicy'] = $commitPolicy
|
||||||
|
if ($PSBoundParameters.ContainsKey('commitPolicyTimeout')) {
|
||||||
|
$body['commitPolicyTimeout'] = $commitPolicyTimeout
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
$body = @{ }
|
|
||||||
#TODO - use a foreach loop to populate the body without all the if statments
|
|
||||||
if ($PSBoundParameters.ContainsKey('commitPolicy')) {
|
|
||||||
$body['commitPolicy'] = $commitPolicy
|
|
||||||
}
|
|
||||||
if ($PSBoundParameters.ContainsKey('commitPolicyTimeout')) {
|
|
||||||
$body['commitPolicyTimeout'] = $commitPolicyTimeout
|
|
||||||
}
|
|
||||||
if ($PSBoundParameters.ContainsKey('forceShutdown')) {
|
|
||||||
$body['forceShutdown'] = $true
|
|
||||||
} else {
|
|
||||||
$body['forceShutdown'] = $false
|
|
||||||
}
|
|
||||||
if ($PSBoundParameters.ContainsKey('ContinueOnPreScriptFailure')) {
|
|
||||||
$body['ContinueOnPreScriptFailure'] = $true
|
|
||||||
} else {
|
|
||||||
$body['ContinueOnPreScriptFailure'] = $false
|
|
||||||
}
|
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
"disableReverseProtection" {
|
{ $_ -in 'name', 'commitName' } {
|
||||||
$body['reverseProtection'] = $false
|
$vpgIds = foreach ($name in $vpgName) {
|
||||||
$body['keepSourceVms'] = $false
|
$vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier
|
||||||
|
if ( -not $vpgId ) {
|
||||||
|
Write-Error "VPG: '$name' not found. Please check the name and try again. Skipping"
|
||||||
|
} else {
|
||||||
|
Write-Verbose "VPG: $name, ID: $vpgId"
|
||||||
|
$vpgId
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"keepSourceVms" {
|
{ $_ -in 'id', 'commitId' } {
|
||||||
$body['reverseProtection'] = $false
|
$vpgIds = $vpgIdentifier
|
||||||
$body['keepSourceVms'] = $true
|
|
||||||
}
|
|
||||||
|
|
||||||
"main" {
|
|
||||||
$body['reverseProtection'] = $true
|
|
||||||
$body['keepSourceVms'] = $false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($name in $vpgName) {
|
|
||||||
$vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier
|
foreach ($thisId in $vpgIds) {
|
||||||
if ( -not $vpgId ) {
|
$uri = "{0}/{1}/move" -f $baseUri, $thisId
|
||||||
Write-Error "VPG: $name not found. Please check the name and try again. Skipping"
|
if ($PSCmdlet.ShouldProcess("Moving VPG: $thisId with settings: $($body | ConvertTo-Json)")) {
|
||||||
} else {
|
Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json)
|
||||||
$uri = "{0}/{1}/move" -f $baseUri, $vpgId
|
|
||||||
if ($PSCmdlet.ShouldProcess("Moving VPG: $name with settings: $($body | convertto-json)")) {
|
|
||||||
Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||||
function Invoke-ZertoMoveCommit {
|
function Invoke-ZertoMoveCommit {
|
||||||
[cmdletbinding(SupportsShouldProcess = $true)]
|
[cmdletbinding(SupportsShouldProcess = $true, DefaultParameterSetName = "Main")]
|
||||||
param(
|
param(
|
||||||
[Parameter(
|
[Parameter(
|
||||||
HelpMessage = "Name(s) of the VPG(s) to commit.",
|
HelpMessage = "Name(s) of the VPG(s) to commit.",
|
||||||
@@ -9,11 +9,16 @@ function Invoke-ZertoMoveCommit {
|
|||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string[]]$vpgName,
|
[string[]]$vpgName,
|
||||||
[Parameter(
|
[Parameter(
|
||||||
HelpMessage = "Set this to True to reverse protect the VPG(s) to the source site. If not set, will use selection made during move initiation. True or False"
|
HelpMessage = "Use this switch to reverse protect the VPG(s) to the source site. If neither 'ReverseProtction' nor 'KeepSourceVms' switch is specified, the commit process will use selection made during move initiation.",
|
||||||
|
ParameterSetName = 'ReverseProtect',
|
||||||
|
Mandatory
|
||||||
|
|
||||||
)]
|
)]
|
||||||
[switch]$reverseProtection,
|
[switch]$reverseProtection,
|
||||||
[Parameter(
|
[Parameter(
|
||||||
HelpMessage = "Use this switch to keep the source VMs. If not set, they will be destroyed."
|
HelpMessage = "Use this switch to keep the source VMs at the source site. If neither 'ReverseProtction' nor 'KeepSourceVms' switch is specified, the commit process will use selection made during move initiation.",
|
||||||
|
ParameterSetName = 'KeepSource',
|
||||||
|
Mandatory
|
||||||
)]
|
)]
|
||||||
[switch]$keepSourceVms
|
[switch]$keepSourceVms
|
||||||
)
|
)
|
||||||
@@ -21,10 +26,16 @@ function Invoke-ZertoMoveCommit {
|
|||||||
begin {
|
begin {
|
||||||
$baseUri = "vpgs"
|
$baseUri = "vpgs"
|
||||||
$body = @{ }
|
$body = @{ }
|
||||||
if ($reverseProtection) {
|
Switch ($PSCmdlet.ParameterSetName){
|
||||||
$body["ReverseProtection"] = $true
|
'KeepSource' {
|
||||||
} elseif ($keepSourceVms) {
|
$body["KeepSourceVms"] = $true
|
||||||
$body["KeepSourceVms"] = $true
|
$body["ReverseProtection"] = $false
|
||||||
|
}
|
||||||
|
|
||||||
|
'ReverseProtect' {
|
||||||
|
$body["ReverseProtection"] = $true
|
||||||
|
$body["KeepSourceVms"] = $false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
<#
|
||||||
|
.ExternalHelp ./en-us/ZertoApiWrapper-help.xml
|
||||||
|
#>
|
||||||
function Invoke-ZertoRestRequest {
|
function Invoke-ZertoRestRequest {
|
||||||
[cmdletbinding()]
|
[cmdletbinding()]
|
||||||
param(
|
param(
|
||||||
@@ -41,24 +43,71 @@ function Invoke-ZertoRestRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# If the Headers exist and the Last action was more than 30 minutes ago, Session is Expired
|
# If the Headers exist and the Last action was more than 30 minutes ago, Session is Expired
|
||||||
if ( (Test-Path variable:script:zvmHeaders) -and $([datetime]$script:zvmLastAction).addMinutes(30) -lt $(Get-Date) ) {
|
if ( (Test-Path variable:script:zvmHeaders) -and (Test-Path variable:script:AuthExpiresAt) -and $([datetime]$script:AuthExpiresAt) -lt $(Get-Date) -and $Script:Reconnect -eq $False ) {
|
||||||
|
Remove-Variable -Name AuthExpiresAt -Scope Script
|
||||||
Throw "Authorization Token has Expired. Please re-authorize to the Zerto Virtual Manager"
|
Throw "Authorization Token has Expired. Please re-authorize to the Zerto Virtual Manager"
|
||||||
} else {
|
} elseif (( (Test-Path variable:script:zvmHeaders) -and (Test-Path variable:script:AuthExpiresAt) -and $([datetime]$script:AuthExpiresAt) -lt $(Get-Date) -and $Script:Reconnect -eq $True )) {
|
||||||
|
Write-Verbose "Authorization had expired. Attempting Reauthorization."
|
||||||
|
Remove-Variable -Name AuthExpiresAt -Scope Script
|
||||||
|
Connect-ZertoServer -zertoServer $Script:zvmServer -zertoPort $script:zvmPort -credential $Script:CachedCredential
|
||||||
|
}# else {
|
||||||
|
|
||||||
|
# Build the URI to be submitted
|
||||||
|
$submittedURI = "https://{0}:{1}/{2}/{3}" -f $script:zvmServer, $script:zvmPort, $apiVersion, $uri
|
||||||
|
try {
|
||||||
|
# Set the zvmLastAction time and try to submit the REST Request
|
||||||
|
$script:zvmLastAction = (Get-Date).Ticks
|
||||||
|
# If running PwSh - Use this Invoke-RestMethod with passed Variables
|
||||||
|
if ($PSVersionTable.PSVersion.Major -ge 6) {
|
||||||
|
# If we are authenticating to the ZVM, Use this block to use Invoke-WebRequest and format the Headers and Body as expected.
|
||||||
|
if ($uri -eq "auth/realms/zerto/protocol/openid-connect/token" -and $method -eq "POST") {
|
||||||
|
$data = @{
|
||||||
|
'client_id' = $script:zertoClientId
|
||||||
|
'username' = $credential.GetNetworkCredential().UserName
|
||||||
|
'password' = $credential.GetNetworkCredential().Password
|
||||||
|
'grant_type' = 'password'
|
||||||
|
'scope' = 'openid'
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = @{
|
||||||
|
'Uri' = 'https://' + $script:zvmServer + ':' + $script:zvmPort + '/auth/realms/zerto/protocol/openid-connect/token'
|
||||||
|
'Method' = 'Post'
|
||||||
|
'Body' = $data
|
||||||
|
'ContentType' = 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
$apiRequestResults = Invoke-RestMethod @params -SkipCertificateCheck
|
||||||
|
|
||||||
|
$ExpiresIn = $apiRequestResults.expires_in
|
||||||
|
$script:AuthExpiresAt = (Get-Date).AddSeconds($ExpiresIn)
|
||||||
|
$script:refreshToken = $apiRequestResults.refresh_token
|
||||||
|
$responseHeaders = @{ }
|
||||||
|
$responseHeaders['Authorization'] = "Bearer " + @($apiRequestResults.access_token)
|
||||||
|
|
||||||
|
# If we are logging out from the ZVM, use this block to use Invoke-WebRequest and format the Headers and Body as expected.
|
||||||
|
} elseif ($uri -eq "auth/realms/zerto/protocol/openid-connect/logout" -and $method -eq "POST") {
|
||||||
|
$data = @{
|
||||||
|
'client_id' = $script:zertoClientId
|
||||||
|
'logout' = 'true'
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = @{
|
||||||
|
'Uri' = 'https://' + $script:zvmServer + ':' + $script:zvmPort + '/auth/realms/zerto/protocol/openid-connect/logout'
|
||||||
|
'Method' = 'Post'
|
||||||
|
'Body' = $data
|
||||||
|
'ContentType' = 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
|
||||||
|
$apiRequestResults = Invoke-RestMethod @params -SkipCertificateCheck
|
||||||
|
|
||||||
# Build the URI to be submitted
|
|
||||||
$submittedURI = "https://{0}:{1}/{2}/{3}" -f $script:zvmServer, $script:zvmPort, $apiVersion, $uri
|
|
||||||
try {
|
|
||||||
# Set the zvmLastAction time and try to submit the REST Request
|
|
||||||
$script:zvmLastAction = (Get-Date).Ticks
|
|
||||||
# If running PwSh - Use this Invoke-RestMethod with passed Variables
|
|
||||||
if ($PSVersionTable.PSVersion.Major -ge 6) {
|
|
||||||
$apiRequestResults = Invoke-RestMethod -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -Body $body -ContentType $contentType -Credential $credential -SkipCertificateCheck -ResponseHeadersVariable responseHeaders -TimeoutSec 100
|
|
||||||
} else {
|
} else {
|
||||||
# If running PowerShell 5.1 --> Do the Following
|
$apiRequestResults = Invoke-RestMethod -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -Body $body -ContentType $contentType -Credential $credential -SkipCertificateCheck -ResponseHeadersVariable responseHeaders -TimeoutSec 100
|
||||||
# Check to see if All Certs are Trusted. If not, Create the Policy to Trust All Certificates
|
}
|
||||||
if ([System.Net.ServicePointManager]::CertificatePolicy.GetType().Name -ne "TrustAllCertsPolicy") {
|
} else {
|
||||||
Try {
|
# If running PowerShell 5.1 --> Do the Following
|
||||||
$type = @'
|
# Check to see if All Certs are Trusted. If not, Create the Policy to Trust All Certificates
|
||||||
|
if ([System.Net.ServicePointManager]::CertificatePolicy.GetType().Name -ne "TrustAllCertsPolicy") {
|
||||||
|
Try {
|
||||||
|
$type = @'
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
public class TrustAllCertsPolicy : ICertificatePolicy {
|
public class TrustAllCertsPolicy : ICertificatePolicy {
|
||||||
@@ -67,42 +116,59 @@ public class TrustAllCertsPolicy : ICertificatePolicy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
'@
|
'@
|
||||||
Add-Type -TypeDefinition $type -ErrorAction SilentlyContinue
|
Add-Type -TypeDefinition $type -ErrorAction SilentlyContinue
|
||||||
} Catch {
|
} Catch {
|
||||||
if ($error[0].Exception -ne "Cannot add type. The type name 'TrustAllCertsPolicy already exists.") {
|
if ($error[0].Exception -ne "Cannot add type. The type name 'TrustAllCertsPolicy already exists.") {
|
||||||
Write-Debug $error[0]
|
Write-Debug $error[0]
|
||||||
}
|
|
||||||
}
|
}
|
||||||
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
|
}
|
||||||
|
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
|
||||||
|
|
||||||
}
|
|
||||||
# If we are authenticating to the ZVM, Use this block to use Invoke-WebRequest and format the Headers as expected.
|
|
||||||
if ($uri -eq "session/add" -and $method -eq "POST") {
|
|
||||||
$apiRequestResults = Invoke-WebRequest -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -Body $body -ContentType $contentType -Credential $credential -TimeoutSec 100
|
|
||||||
$responseHeaders = @{ }
|
|
||||||
$responseHeaders['x-zerto-session'] = @($apiRequestResults.Headers['x-zerto-session'])
|
|
||||||
} elseif ($method -ne "GET") {
|
|
||||||
# If the Method is something other than 'GET' use this call with a body parameter
|
|
||||||
$apiRequestResults = Invoke-RestMethod -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -Body $body -ContentType $contentType -Credential $credential -TimeoutSec 100
|
|
||||||
} else {
|
|
||||||
# If the Method we are calling is 'GET' use this call without a body parameter
|
|
||||||
$apiRequestResults = Invoke-RestMethod -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -ContentType $contentType -Credential $credential -TimeoutSec 100
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch {
|
# If we are authenticating to the ZVM, Use this block to use Invoke-WebRequest and format the Headers as expected.
|
||||||
# If an error is encountered, Catch
|
if ($uri -eq "auth/realms/zerto/protocol/openid-connect/token" -and $method -eq "POST") {
|
||||||
Write-Error -ErrorRecord $_ -ErrorAction $callerErrorActionPreference
|
$data = @{
|
||||||
}
|
'client_id' = $script:zertoClientId
|
||||||
|
'username' = $credential.GetNetworkCredential().UserName
|
||||||
|
'password' = $credential.GetNetworkCredential().Password
|
||||||
|
'grant_type' = 'password'
|
||||||
|
}
|
||||||
|
|
||||||
# If the calling function does not need the headers (Default Action) return the results of the API Call
|
$params = @{
|
||||||
if (-not $returnHeaders) {
|
'Uri' = 'https://' + $script:zvmServer + ':' + $script:zvmPort + '/auth/realms/zerto/protocol/openid-connect/token'
|
||||||
return $apiRequestResults
|
'Method' = 'POST'
|
||||||
} else {
|
'Body' = $data
|
||||||
#If Headers are required, build a PS Custom Object with the Results and the Headers
|
'ContentType' = 'application/x-www-form-urlencoded'
|
||||||
$apiRequestAndHeaderResults = New-Object -TypeName psobject
|
}
|
||||||
$apiRequestAndHeaderResults | Add-Member -MemberType NoteProperty -Name "apiRequestResults" -Value $apiRequestResults
|
$apiRequestResults = Invoke-RestMethod @params
|
||||||
$apiRequestAndHeaderResults | Add-Member -MemberType NoteProperty -Name "Headers" -Value $responseHeaders
|
|
||||||
return $apiRequestAndHeaderResults
|
$ExpiresIn = $apiRequestResults.expires_in
|
||||||
|
$script:AuthExpiresAt = (Get-Date).AddSeconds($ExpiresIn)
|
||||||
|
$script:refreshToken = $apiRequestResults.refresh_token
|
||||||
|
$responseHeaders = @{ }
|
||||||
|
$responseHeaders['Authorization'] = "Bearer " + @($apiRequestResults.access_token)
|
||||||
|
} elseif ($method -ne "GET") {
|
||||||
|
# If the Method is something other than 'GET' use this call with a body parameter
|
||||||
|
$apiRequestResults = Invoke-RestMethod -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -Body $body -ContentType $contentType -Credential $credential -TimeoutSec 100
|
||||||
|
} else {
|
||||||
|
# If the Method we are calling is 'GET' use this call without a body parameter
|
||||||
|
$apiRequestResults = Invoke-RestMethod -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -ContentType $contentType -Credential $credential -TimeoutSec 100
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch {
|
||||||
|
# If an error is encountered, Catch
|
||||||
|
Write-Error -ErrorRecord $_ -ErrorAction $callerErrorActionPreference
|
||||||
|
}
|
||||||
|
|
||||||
|
# If the calling function does not need the headers (Default Action) return the results of the API Call
|
||||||
|
if (-not $returnHeaders) {
|
||||||
|
return $apiRequestResults
|
||||||
|
} else {
|
||||||
|
#If Headers are required, build a PS Custom Object with the Results and the Headers
|
||||||
|
$apiRequestAndHeaderResults = New-Object -TypeName psobject
|
||||||
|
$apiRequestAndHeaderResults | Add-Member -MemberType NoteProperty -Name "apiRequestResults" -Value $apiRequestResults
|
||||||
|
$apiRequestAndHeaderResults | Add-Member -MemberType NoteProperty -Name "Headers" -Value $responseHeaders
|
||||||
|
return $apiRequestAndHeaderResults
|
||||||
|
#}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||||
function New-ZertoVpg {
|
function New-ZertoVpg {
|
||||||
[cmdletbinding(SupportsShouldProcess = $true)]
|
[cmdletbinding(SupportsShouldProcess = $true, DefaultParameterSetName = "recoveryHostDatastore")]
|
||||||
param(
|
param(
|
||||||
[Parameter(
|
[Parameter(
|
||||||
HelpMessage = "Name of the VPG",
|
HelpMessage = "Name of the VPG",
|
||||||
@@ -165,7 +165,7 @@ function New-ZertoVpg {
|
|||||||
begin {
|
begin {
|
||||||
# Create an identifiers table, and start converting names to identifiers.
|
# Create an identifiers table, and start converting names to identifiers.
|
||||||
$identifiersTable = @{ }
|
$identifiersTable = @{ }
|
||||||
$identifiersTable['recoverySiteIdentifier'] = $(Get-ZertoPeerSite -peerName $recoverySite).siteIdentifier
|
$identifiersTable['recoverySiteIdentifier'] = Get-ZertoVirtualizationSite | Where-Object { $_.VirtualizationSiteName -like $recoverySite } | Select-Object -ExpandProperty SiteIdentifier
|
||||||
$peerSiteNetworks = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -networks)
|
$peerSiteNetworks = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -networks)
|
||||||
$identifiersTable['failoverNetworkIdentifier'] = $peerSiteNetworks | Where-Object { $_.VirtualizationNetworkName -like $recoveryNetwork } | Select-Object -ExpandProperty NetworkIdentifier
|
$identifiersTable['failoverNetworkIdentifier'] = $peerSiteNetworks | Where-Object { $_.VirtualizationNetworkName -like $recoveryNetwork } | Select-Object -ExpandProperty NetworkIdentifier
|
||||||
$identifiersTable['testNetworkIdentifier'] = $peerSiteNetworks | Where-Object { $_.VirtualizationNetworkName -like $testNetwork } | Select-Object -ExpandProperty NetworkIdentifier
|
$identifiersTable['testNetworkIdentifier'] = $peerSiteNetworks | Where-Object { $_.VirtualizationNetworkName -like $testNetwork } | Select-Object -ExpandProperty NetworkIdentifier
|
||||||
@@ -182,18 +182,18 @@ function New-ZertoVpg {
|
|||||||
# Get identifiers based on parameter set name
|
# Get identifiers based on parameter set name
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
"recoveryClusterDatastoreCluster" {
|
"recoveryClusterDatastoreCluster" {
|
||||||
$identifiersTable['clusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -hostclusters | Where-Object { $_.VirtualizationClusterName -like $recoveryCluster }).ClusterIdentifier
|
$identifiersTable['clusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -hostClusters | Where-Object { $_.VirtualizationClusterName -like $recoveryCluster }).ClusterIdentifier
|
||||||
$identifiersTable['datastoreClusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastoreclusters | Where-Object { $_.DatastoreClusterName -like $datastoreCluster }).DatastoreClusterIdentifier
|
$identifiersTable['datastoreClusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastoreClusters | Where-Object { $_.DatastoreClusterName -like $datastoreCluster }).DatastoreClusterIdentifier
|
||||||
}
|
}
|
||||||
|
|
||||||
"recoveryClusterDatastore" {
|
"recoveryClusterDatastore" {
|
||||||
$identifiersTable['clusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -hostclusters | Where-Object { $_.VirtualizationClusterName -like $recoveryCluster }).ClusterIdentifier
|
$identifiersTable['clusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -hostClusters | Where-Object { $_.VirtualizationClusterName -like $recoveryCluster }).ClusterIdentifier
|
||||||
$identifiersTable['datastoreIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastores | Where-Object { $_.DatastoreName -like $datastore }).DatastoreIdentifier
|
$identifiersTable['datastoreIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastores | Where-Object { $_.DatastoreName -like $datastore }).DatastoreIdentifier
|
||||||
}
|
}
|
||||||
|
|
||||||
"recoveryHostDatastoreCluster" {
|
"recoveryHostDatastoreCluster" {
|
||||||
$identifiersTable['recoveryHostIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -hosts | Where-Object { $_.VirtualizationHostName -like $recoveryHost }).HostIdentifier
|
$identifiersTable['recoveryHostIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -hosts | Where-Object { $_.VirtualizationHostName -like $recoveryHost }).HostIdentifier
|
||||||
$identifiersTable['datastoreClusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastoreclusters | Where-Object { $_.DatastoreClusterName -like $datastoreCluster }).DatastoreClusterIdentifier
|
$identifiersTable['datastoreClusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastoreClusters | Where-Object { $_.DatastoreClusterName -like $datastoreCluster }).DatastoreClusterIdentifier
|
||||||
}
|
}
|
||||||
|
|
||||||
"recoveryHostDatastore" {
|
"recoveryHostDatastore" {
|
||||||
@@ -202,12 +202,12 @@ function New-ZertoVpg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
"recoveryResourcePoolDatastoreCluster" {
|
"recoveryResourcePoolDatastoreCluster" {
|
||||||
$identifiersTable['recoveryResourcePoolIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -resourcepools | Where-Object { $_.ResourcePoolName -like $recoveryResourcePool }).ResourcePoolIdentifier
|
$identifiersTable['recoveryResourcePoolIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -resourcePools | Where-Object { $_.ResourcePoolName -like $recoveryResourcePool }).ResourcePoolIdentifier
|
||||||
$identifiersTable['datastoreClusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastoreclusters | Where-Object { $_.DatastoreClusterName -like $datastoreCluster }).DatastoreClusterIdentifier
|
$identifiersTable['datastoreClusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastoreClusters | Where-Object { $_.DatastoreClusterName -like $datastoreCluster }).DatastoreClusterIdentifier
|
||||||
}
|
}
|
||||||
|
|
||||||
"recoveryResourcePoolDatastore" {
|
"recoveryResourcePoolDatastore" {
|
||||||
$identifiersTable['recoveryResourcePoolIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -resourcepools | Where-Object { $_.ResourcePoolName -like $recoveryResourcePool }).ResourcePoolIdentifier
|
$identifiersTable['recoveryResourcePoolIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -resourcePools | Where-Object { $_.ResourcePoolName -like $recoveryResourcePool }).ResourcePoolIdentifier
|
||||||
$identifiersTable['datastoreIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastores | Where-Object { $_.DatastoreName -like $datastore }).DatastoreIdentifier
|
$identifiersTable['datastoreIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastores | Where-Object { $_.DatastoreName -like $datastore }).DatastoreIdentifier
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -295,11 +295,11 @@ function New-ZertoVpg {
|
|||||||
|
|
||||||
"recoveryHostDatastoreCluster" {
|
"recoveryHostDatastoreCluster" {
|
||||||
$baseSettings.Recovery.DefaultDatastoreClusterIdentifier = $identifiersTable['datastoreClusterIdentifier']
|
$baseSettings.Recovery.DefaultDatastoreClusterIdentifier = $identifiersTable['datastoreClusterIdentifier']
|
||||||
$baseSettings.Recovery.DefaultHostIdentifier = $identifiersTable['hostIdentifier']
|
$baseSettings.Recovery.DefaultHostIdentifier = $identifiersTable['recoveryHostIdentifier']
|
||||||
}
|
}
|
||||||
|
|
||||||
"recoveryHostDatastore" {
|
"recoveryHostDatastore" {
|
||||||
$baseSettings.Recovery.DefaultHostIdentifier = $identifiersTable['hostIdentifier']
|
$baseSettings.Recovery.DefaultHostIdentifier = $identifiersTable['recoveryHostIdentifier']
|
||||||
$baseSettings.Recovery.DefaultDatastoreIdentifier = $identifiersTable['datastoreIdentifier']
|
$baseSettings.Recovery.DefaultDatastoreIdentifier = $identifiersTable['datastoreIdentifier']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||||
|
function Remove-ZertoVpgVm {
|
||||||
|
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = "High")]
|
||||||
|
param (
|
||||||
|
[Parameter(
|
||||||
|
Mandatory,
|
||||||
|
HelpMessage = "Name of the VPG that contains the VM you wish to remove",
|
||||||
|
ParameterSetName = "VpgName"
|
||||||
|
)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[String]$VpgName,
|
||||||
|
[Parameter(
|
||||||
|
Mandatory,
|
||||||
|
HelpMessage = "Name of VM(s) to remove from the VPG"
|
||||||
|
)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[String[]]$Vm
|
||||||
|
)
|
||||||
|
|
||||||
|
begin {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
$VpgData = Get-ZertoVpg -vpgName $VpgName
|
||||||
|
if (-not $VpgData) {
|
||||||
|
Write-Error "Unable to find Vpg with name $VpgName. Please check your parameters and try again." -ErrorAction Stop
|
||||||
|
} else {
|
||||||
|
$protectedVms = Get-ZertoProtectedVm -vpgName $VpgData.VpgName
|
||||||
|
}
|
||||||
|
$VmIdentifiers = foreach ($machine in ($vm | Select-Object -Unique)) {
|
||||||
|
if ($machine -in $protectedVms.VmName) {
|
||||||
|
$protectedVms | Where-Object ( { $_.VmName -like $machine }) | Select-Object -ExpandProperty VmIdentifier
|
||||||
|
} else {
|
||||||
|
Write-Warning "Virtual Machine: '$machine' is not found in Vpg: '$VpgName'. Check your parameters. Skipping $machine"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($VmIdentifiers.Count -gt 0 -and $PSCmdlet.ShouldProcess(($Vm | Select-Object -Unique), "Removing VM(s): $($Vm | Select-Object -Unique) from Vpg $VpgName")) {
|
||||||
|
$vpgSettingsIdentifier = New-ZertoVpgSettingsIdentifier -vpgIdentifier $VpgData.VpgIdentifier
|
||||||
|
foreach ($identifier in $VmIdentifiers) {
|
||||||
|
$url = "vpgSettings/{0}/vms/{1}" -f $vpgSettingsIdentifier, $identifier
|
||||||
|
Invoke-ZertoRestRequest -uri $url -method DELETE
|
||||||
|
}
|
||||||
|
Save-ZertoVpgSetting -vpgSettingsIdentifier $vpgSettingsIdentifier
|
||||||
|
} else {
|
||||||
|
Write-Warning "No VMs found to remove. Please check your parameters and try again."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
end {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ function Save-ZertoVpgSetting {
|
|||||||
ValueFromPipelineByPropertyName = $true
|
ValueFromPipelineByPropertyName = $true
|
||||||
)]
|
)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[Alias("vpgSettingsId")]
|
[Alias("sid", "settingsIdentifier", "vpgSettingsId")]
|
||||||
[string]$vpgSettingsIdentifier
|
[string]$vpgSettingsIdentifier
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ function Set-ZertoLicense {
|
|||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
if ($PSCmdlet.ShouldProcess()) {
|
if ($PSCmdlet.ShouldProcess("Applying License Key: $licenseKey to server: $($script:zvmServer)")) {
|
||||||
Invoke-ZertoRestRequest -uri $baseUri -body $($body | ConvertTo-Json) -method "PUT"
|
Invoke-ZertoRestRequest -uri $baseUri -body $($body | ConvertTo-Json) -method "PUT"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,18 +27,25 @@ function Start-ZertoCloneVpg {
|
|||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
$baseUri = "vpgs"
|
$baseUri = "vpgs"
|
||||||
$vpgInfo = Get-ZertoVpg -name $vpgName
|
$vpgInfo = Get-ZertoVpg -name $vpgName
|
||||||
if ( -not $vpgInfo ) {
|
if ( -not $vpgInfo ) {
|
||||||
Write-Error "VPG: $vpgName could not be found. Please check the name and try again."
|
Write-Error "VPG: $vpgName could not be found. Please check the name and try again."
|
||||||
}
|
}
|
||||||
$vpgIdentifier = $vpgInfo.vpgIdentifier
|
$vpgIdentifier = $vpgInfo.vpgIdentifier
|
||||||
|
$body = @{ }
|
||||||
if ( $PSBoundParameters.ContainsKey('datastoreName') ) {
|
if ( $PSBoundParameters.ContainsKey('datastoreName') ) {
|
||||||
$recoverysiteIdentifier = $vpgInfo.recoverysite.identifier
|
$recoverysiteIdentifier = $vpgInfo.recoverysite.identifier
|
||||||
$recoverySiteDatastores = Get-ZertoVirtualizationSite -siteIdentifier $recoverysiteIdentifier -datastores
|
$recoverySiteDatastores = Get-ZertoVirtualizationSite -siteIdentifier $recoverysiteIdentifier -datastores
|
||||||
$datastoreIdentifier = $($recoverySiteDatastores | Where-Object { $_.datastoreName -like $datastoreName }).DatastoreIdentifier
|
$datastoreIdentifier = $($recoverySiteDatastores | Where-Object { $_.datastoreName -like $datastoreName }).DatastoreIdentifier
|
||||||
if ( -not $datastoreIdentifier ) {
|
if ( -not $datastoreIdentifier ) {
|
||||||
Write-Error "Datastore: $datastoreName is not a valid datastore. Please check the name and try again." -ErrorAction Stop
|
Write-Error "Datastore: $datastoreName is not a valid datastore. Please check the name and try again." -ErrorAction Stop
|
||||||
|
} else {
|
||||||
|
$body['DatastoreIdentifier'] = $datastoreIdentifier
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( $PSBoundParameters.ContainsKey('vmName') ) {
|
if ( $PSBoundParameters.ContainsKey('vmName') ) {
|
||||||
@@ -55,32 +62,20 @@ function Start-ZertoCloneVpg {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$body['VmIdentifiers'] = $vmIdentifiers
|
$body['VmIdentifiers'] = $vmIdentifiers
|
||||||
if ($checkpointIdentifier) {
|
|
||||||
$body['CheckpointIdentifier'] = $checkpointIdentifier
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
process {
|
|
||||||
$uri = "{0}/{1}/CloneStart" -f $baseUri, $vpgIdentifier
|
|
||||||
$body = [ordered]@{ }
|
|
||||||
if ( $PSBoundParameters.ContainsKey('checkpointIdentifier') ) {
|
if ( $PSBoundParameters.ContainsKey('checkpointIdentifier') ) {
|
||||||
$body['checkpointId'] = $checkpointIdentifier
|
$body['checkpointId'] = $checkpointIdentifier
|
||||||
}
|
}
|
||||||
if ( $datastoreIdentifier ) {
|
|
||||||
$body['DatastoreIdentifier'] = $datastoreIdentifier
|
|
||||||
}
|
|
||||||
if ( $vmIdentifiers ) {
|
|
||||||
$body['VmIdentifiers'] = $vmIdentifiers
|
|
||||||
}
|
|
||||||
Write-Verbose $body
|
Write-Verbose $body
|
||||||
|
$uri = "{0}/{1}/CloneStart" -f $baseUri, $vpgIdentifier
|
||||||
if ($PSCmdlet.ShouldProcess("Clone Vpg")) {
|
if ($PSCmdlet.ShouldProcess("Clone Vpg")) {
|
||||||
Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -method "POST"
|
Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -method "POST"
|
||||||
|
Write-Verbose "Call Submitted to $uri"
|
||||||
|
Write-Verbose "With the following information: $($body | ConvertTo-Json)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
Write-Verbose "Call Submitted to $uri"
|
|
||||||
Write-Verbose "With the following information: $($body | ConvertTo-Json)"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
RootModule = '.\ZertoApiWrapper.psm1'
|
RootModule = '.\ZertoApiWrapper.psm1'
|
||||||
|
|
||||||
# Version number of this module.
|
# Version number of this module.
|
||||||
ModuleVersion = '0.0.1'
|
ModuleVersion = '2.1.0'
|
||||||
|
|
||||||
# Supported PSEditions
|
# Supported PSEditions
|
||||||
# CompatiblePSEditions = @()
|
# CompatiblePSEditions = @()
|
||||||
|
|||||||
+87
-90
@@ -10,11 +10,12 @@ trigger:
|
|||||||
branches:
|
branches:
|
||||||
include:
|
include:
|
||||||
- master
|
- master
|
||||||
- PowerShellBackPort
|
- zvma-updates
|
||||||
|
|
||||||
# Trigger CI on pull requests to master and develop branches
|
# Trigger CI on pull requests to master and develop branches
|
||||||
pr:
|
pr:
|
||||||
- master
|
- master
|
||||||
|
- zvma-updates
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Windows PowerShell 5.1 Build Job
|
# Windows PowerShell 5.1 Build Job
|
||||||
@@ -24,26 +25,18 @@ jobs:
|
|||||||
pool:
|
pool:
|
||||||
vmImage: windows-latest
|
vmImage: windows-latest
|
||||||
steps:
|
steps:
|
||||||
# Run build.ps1 script in PowerShell Core
|
# Run build.ps1 script in PowerShell Core
|
||||||
- powershell: |
|
- powershell: |
|
||||||
.\build.ps1 -Verbose
|
.\build.ps1 -Verbose
|
||||||
displayName: 'Build and Test'
|
displayName: "Build and Test"
|
||||||
# Upload test results to Azure Pipeline
|
# Upload test results to Azure Pipeline
|
||||||
- task: PublishTestResults@2
|
- task: PublishTestResults@2
|
||||||
inputs:
|
inputs:
|
||||||
testRunner: 'NUnit'
|
testRunner: "NUnit"
|
||||||
testResultsFiles: '**/SourceTestResults.xml'
|
testResultsFiles: "**/BuiltTestResults.xml"
|
||||||
testRunTitle: 'PS_Win2016_Source'
|
testRunTitle: "PS_Win2016_Built"
|
||||||
displayName: 'Publish Test Results'
|
displayName: "Publish Test Results"
|
||||||
condition: always()
|
condition: always()
|
||||||
- task: PublishTestResults@2
|
|
||||||
inputs:
|
|
||||||
testRunner: 'NUnit'
|
|
||||||
testResultsFiles: '**/BuiltTestResults.xml'
|
|
||||||
testRunTitle: 'PS_Win2016_Built'
|
|
||||||
displayName: 'Publish Test Results'
|
|
||||||
condition: always()
|
|
||||||
|
|
||||||
|
|
||||||
# Windows PowerShell Core Build Job
|
# Windows PowerShell Core Build Job
|
||||||
- job: Build_PSCore_Windows
|
- job: Build_PSCore_Windows
|
||||||
@@ -52,25 +45,24 @@ jobs:
|
|||||||
pool:
|
pool:
|
||||||
vmImage: windows-latest
|
vmImage: windows-latest
|
||||||
steps:
|
steps:
|
||||||
# Run build.ps1 script in PowerShell Core
|
# Run build.ps1 script in PowerShell Core
|
||||||
- pwsh: |
|
- pwsh: |
|
||||||
.\build.ps1 -Verbose
|
.\build.ps1 -Verbose
|
||||||
displayName: 'Build and Test'
|
displayName: "Build and Test"
|
||||||
# Upload test results to Azure Pipeline
|
# Upload test results to Azure Pipeline
|
||||||
- task: PublishTestResults@2
|
- task: PublishTestResults@2
|
||||||
inputs:
|
inputs:
|
||||||
testRunner: 'NUnit'
|
testRunner: "NUnit"
|
||||||
testResultsFiles: '**/SourceTestResults.xml'
|
testResultsFiles: "**/BuiltTestResults.xml"
|
||||||
testRunTitle: 'PSCore_Win2016_Source'
|
testRunTitle: "PSCore_Win2016_Built"
|
||||||
displayName: 'Publish Test Results'
|
displayName: "Publish Test Results"
|
||||||
condition: always()
|
condition: always()
|
||||||
- task: PublishTestResults@2
|
# Publish module as an artifact
|
||||||
inputs:
|
- task: PublishBuildArtifacts@1
|
||||||
testRunner: 'NUnit'
|
inputs:
|
||||||
testResultsFiles: '**/BuiltTestResults.xml'
|
PathtoPublish: "publish/ZertoApiWrapper"
|
||||||
testRunTitle: 'PSCore_Win2016_Built'
|
ArtifactName: "ZertoApiWrapper"
|
||||||
displayName: 'Publish Test Results'
|
publishLocation: "Container"
|
||||||
condition: always()
|
|
||||||
|
|
||||||
# Linux Build Job
|
# Linux Build Job
|
||||||
- job: Build_PSCore_Ubuntu
|
- job: Build_PSCore_Ubuntu
|
||||||
@@ -79,37 +71,24 @@ jobs:
|
|||||||
pool:
|
pool:
|
||||||
vmImage: ubuntu-latest
|
vmImage: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
# Run build.ps1 script in PowerShell Core
|
# Run build.ps1 script in PowerShell Core
|
||||||
- pwsh: |
|
- pwsh: |
|
||||||
.\build.ps1 -verbose
|
.\build.ps1 -verbose
|
||||||
displayName: 'Build and Test'
|
displayName: "Build and Test"
|
||||||
# Upload test results to Azure Pipeline
|
# Upload test results to Azure Pipeline
|
||||||
- task: PublishTestResults@2
|
- task: PublishTestResults@2
|
||||||
inputs:
|
inputs:
|
||||||
testRunner: 'NUnit'
|
testRunner: "NUnit"
|
||||||
testResultsFiles: '**/SourceTestResults.xml'
|
testResultsFiles: "**/BuiltTestResults.xml"
|
||||||
testRunTitle: 'PSCore_Ubuntu_Source'
|
testRunTitle: "PSCore_Ubuntu_Built"
|
||||||
displayName: 'Publish Test Results'
|
displayName: "Publish Test Results"
|
||||||
condition: always()
|
condition: always()
|
||||||
- task: PublishTestResults@2
|
- task: PublishPipelineArtifact@1
|
||||||
inputs:
|
displayName: "Publish Data"
|
||||||
testRunner: 'NUnit'
|
inputs:
|
||||||
testResultsFiles: '**/BuiltTestResults.xml'
|
artifactName: "ReleaseData"
|
||||||
testRunTitle: 'PSCore_Ubuntu_Built'
|
targetPath: ./publish
|
||||||
displayName: 'Publish Test Results'
|
condition: always()
|
||||||
condition: always()
|
|
||||||
- task: PublishPipelineArtifact@0
|
|
||||||
displayName: 'Publish compiled module Artifact'
|
|
||||||
inputs:
|
|
||||||
artifactName: 'ZertoApiWrapper'
|
|
||||||
targetPath: ./temp
|
|
||||||
condition: always()
|
|
||||||
- task: PublishPipelineArtifact@0
|
|
||||||
displayName: 'Publish Data'
|
|
||||||
inputs:
|
|
||||||
artifactName: 'ReleaseData'
|
|
||||||
targetPath: ./publish
|
|
||||||
condition: always()
|
|
||||||
|
|
||||||
# MacOS Build Job
|
# MacOS Build Job
|
||||||
- job: Build_PSCore_MacOS
|
- job: Build_PSCore_MacOS
|
||||||
@@ -118,22 +97,40 @@ jobs:
|
|||||||
pool:
|
pool:
|
||||||
vmImage: macOS-latest
|
vmImage: macOS-latest
|
||||||
steps:
|
steps:
|
||||||
# Run build.ps1 script in PowerShell Core
|
# Run build.ps1 script in PowerShell Core
|
||||||
- pwsh: |
|
- pwsh: |
|
||||||
.\build.ps1 -verbose
|
.\build.ps1 -verbose
|
||||||
displayName: 'Build and Test'
|
displayName: "Build and Test"
|
||||||
# Upload test results to Azure Pipeline
|
# Upload test results to Azure Pipeline
|
||||||
- task: PublishTestResults@2
|
- task: PublishTestResults@2
|
||||||
inputs:
|
inputs:
|
||||||
testRunner: 'NUnit'
|
testRunner: "NUnit"
|
||||||
testResultsFiles: '**/SourceTestResults.xml'
|
testResultsFiles: "**/BuiltTestResults.xml"
|
||||||
testRunTitle: 'PSCore_MacOS1013_Source'
|
testRunTitle: "PSCore_MacOS1013_Built"
|
||||||
displayName: 'Publish Test Results'
|
displayName: "Publish Test Results"
|
||||||
condition: always()
|
condition: always()
|
||||||
- task: PublishTestResults@2
|
|
||||||
inputs:
|
# Publish Module to Gallery
|
||||||
testRunner: 'NUnit'
|
- job: Publish
|
||||||
testResultsFiles: '**/BuiltTestResults.xml'
|
dependsOn:
|
||||||
testRunTitle: 'PSCore_MacOS1013_Built'
|
- Build_PS_Windows
|
||||||
displayName: 'Publish Test Results'
|
- Build_PSCore_Windows
|
||||||
condition: always()
|
- Build_PSCore_Ubuntu
|
||||||
|
- Build_PSCore_MacOS
|
||||||
|
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/zvma-updates'))
|
||||||
|
pool:
|
||||||
|
vmImage: 'windows-latest'
|
||||||
|
steps:
|
||||||
|
# Download the artifact
|
||||||
|
- task: DownloadBuildArtifacts@0
|
||||||
|
inputs:
|
||||||
|
artifactName: 'ZertoApiWrapper' # The name of the artifact you specified in the build job
|
||||||
|
downloadPath: '$(Build.ArtifactStagingDirectory)'
|
||||||
|
|
||||||
|
# Publish the module to the PowerShell Gallery
|
||||||
|
- powershell: |
|
||||||
|
Install-Module -Name PowerShellGet -Force -Scope CurrentUser
|
||||||
|
$env:PSModulePath = "$(Build.ArtifactStagingDirectory);"+$env:PSModulePath
|
||||||
|
$apiKey = "$(PowerShellGalleryApiKey)"
|
||||||
|
Publish-Module -Path "$(Build.ArtifactStagingDirectory)\ZertoApiWrapper" -NuGetApiKey $apiKey
|
||||||
|
displayName: 'Publish to PowerShell Gallery'
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
param([validateSet("build", "release")]$operation = "build")
|
||||||
|
|
||||||
# Bootstrap the environment
|
# Bootstrap the environment
|
||||||
$null = Get-PackageProvider -Name NuGet -ForceBootstrap
|
$null = Get-PackageProvider -Name NuGet -ForceBootstrap
|
||||||
|
|
||||||
@@ -11,6 +13,7 @@ Invoke-PSDepend `
|
|||||||
-Force `
|
-Force `
|
||||||
-Import `
|
-Import `
|
||||||
-Install `
|
-Install `
|
||||||
-Tags 'Bootstrap'
|
-Tags 'Bootstrap' `
|
||||||
|
-ErrorAction Continue
|
||||||
|
|
||||||
Invoke-Build .
|
Invoke-Build $operation
|
||||||
|
|||||||
@@ -31,10 +31,10 @@ Pairs the current Zerto Virtual Manager to the Zerto Virtual Manager at IP addre
|
|||||||
|
|
||||||
### Example 2
|
### Example 2
|
||||||
```powershell
|
```powershell
|
||||||
PS C:\> Add-ZertoPeerSite -targetHost "192.168.2.100" -token "GeneratedFromTargetZVM"
|
PS C:\> Add-ZertoPeerSite -targetHost "192.168.2.100" -targetPort "9071" -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.
|
Pairs the current Zerto Virtual Manager to the Zerto Virtual Manager at IP address 192.168.2.100 over Port 9071. Use this method when pairing Zerto Virtual Managers that are version 7.5 or later.
|
||||||
|
|
||||||
## PARAMETERS
|
## PARAMETERS
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,138 @@
|
|||||||
|
---
|
||||||
|
external help file: ZertoApiWrapper-help.xml
|
||||||
|
Module Name: ZertoApiWrapper
|
||||||
|
online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Add-ZertoVpgVm.md
|
||||||
|
schema: 2.0.0
|
||||||
|
---
|
||||||
|
|
||||||
|
# Add-ZertoVpgVm
|
||||||
|
|
||||||
|
## SYNOPSIS
|
||||||
|
Adds one or more virtual machines to an existing VPG. A VPG Settings Identifier will be returned for use in either further customization of the VPG or passed to the `Save-ZertoVpgSetting` command to commit the changes.
|
||||||
|
|
||||||
|
## SYNTAX
|
||||||
|
|
||||||
|
### VpgName (Default)
|
||||||
|
```
|
||||||
|
Add-ZertoVpgVm -VpgName <String> -Vm <String[]> [-WhatIf] [-Confirm] [<CommonParameters>]
|
||||||
|
```
|
||||||
|
|
||||||
|
### VpgSettingsIdentifier
|
||||||
|
```
|
||||||
|
Add-ZertoVpgVm -vpgSettingsIdentifier <String> -Vm <String[]> [-WhatIf] [-Confirm] [<CommonParameters>]
|
||||||
|
```
|
||||||
|
|
||||||
|
## DESCRIPTION
|
||||||
|
Adds one or more virtual machines to an existing VPG. A VPG Settings Identifier will be returned for use in either further customization of the VPG or passed to the `Save-ZertoVpgSetting` command to commit the changes.
|
||||||
|
|
||||||
|
Internal logic to the function will only process unique items and ensure that VMs meet requirements to replicate to the target site. These requirements include not currently a member of the specified VPG, not currently replicating to the target site, and not a member of 3 or more VPGs.
|
||||||
|
|
||||||
|
## EXAMPLES
|
||||||
|
|
||||||
|
### Example 1
|
||||||
|
```powershell
|
||||||
|
PS C:\> Add-ZertoVpgVm -VpgSettingsIdentifier $vpgSettingsIdentifier -Vm "VM 1", "Vm 2"
|
||||||
|
```
|
||||||
|
|
||||||
|
Adds "VM 1" and "VM 2" to the Vpg with VpgSettingsIdentifer specified in `$VpgSettingsIdentifier`. This variable was obtained via other functions that create and return a Vpg Settings Identifier. The Vpg Settings Identifier passed into the function will be returned.
|
||||||
|
|
||||||
|
### Example 2
|
||||||
|
```powershell
|
||||||
|
PS C:\> Add-ZertoVpgVm -VpgName "My Vpg" -Vm "VM 1", "Vm 2"
|
||||||
|
```
|
||||||
|
|
||||||
|
Adds "VM 1" and "VM 2" to the Vpg named "My Vpg". In this case, a new Vpg Settings Identifier will be created and returned.
|
||||||
|
|
||||||
|
## PARAMETERS
|
||||||
|
|
||||||
|
### -Vm
|
||||||
|
Name of VM(s) to add to the VPG
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: String[]
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: True
|
||||||
|
Position: Named
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -VpgName
|
||||||
|
Target VPG Name to Add the VM
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: String
|
||||||
|
Parameter Sets: VpgName
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: True
|
||||||
|
Position: Named
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -vpgSettingsIdentifier
|
||||||
|
Vpg Settings Identifier
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: String
|
||||||
|
Parameter Sets: VpgSettingsIdentifier
|
||||||
|
Aliases: sid, settingsIdentifier, vpgSettingsId
|
||||||
|
|
||||||
|
Required: True
|
||||||
|
Position: Named
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: True (ByPropertyName, ByValue)
|
||||||
|
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
|
||||||
|
|
||||||
|
### System.String
|
||||||
|
|
||||||
|
## OUTPUTS
|
||||||
|
|
||||||
|
### System.Object
|
||||||
|
|
||||||
|
## NOTES
|
||||||
|
|
||||||
|
## RELATED LINKS
|
||||||
|
[Adding VMs to a VPG Settings Object](https://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20(ZVM)%20-%20vSphere%20Online%20Help/content/zvr_apis/vpg_management_api.htm?tocpath=ZVR%20RESTful%20APIs%7CZerto%20APIs%7C_____20#statusapis_4057192544_1358357)
|
||||||
+135
-112
@@ -1,112 +1,135 @@
|
|||||||
---
|
---
|
||||||
external help file: ZertoApiWrapper-help.xml
|
external help file: ZertoApiWrapper-help.xml
|
||||||
Module Name: ZertoApiWrapper
|
Module Name: ZertoApiWrapper
|
||||||
online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Connect-ZertoServer.md
|
online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Connect-ZertoServer.md
|
||||||
schema: 2.0.0
|
schema: 2.0.0
|
||||||
---
|
---
|
||||||
|
|
||||||
# Connect-ZertoServer
|
# Connect-ZertoServer
|
||||||
|
|
||||||
## SYNOPSIS
|
## SYNOPSIS
|
||||||
Establishes a connection to a ZVM.
|
Establishes a connection to a ZVM.
|
||||||
|
|
||||||
## SYNTAX
|
## SYNTAX
|
||||||
|
|
||||||
```
|
```
|
||||||
Connect-ZertoServer [-zertoServer] <String> [[-zertoPort] <String>] [-credential] <PSCredential>
|
Connect-ZertoServer [-zertoServer] <String> [-credential] <PSCredential> [-zertoPort <String>] [-AutoReconnect]
|
||||||
[-returnHeaders] [<CommonParameters>]
|
[-returnHeaders] [<CommonParameters>]
|
||||||
```
|
```
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
Establishes a connection to a ZVM using credentials provided via a PSCredential Object leveraging the Zerto Session API end point.
|
Establishes a connection to a ZVM using credentials provided via a PSCredential Object leveraging the Zerto Session API end point.
|
||||||
|
|
||||||
## EXAMPLES
|
## EXAMPLES
|
||||||
|
|
||||||
### Example 1
|
### Example 1
|
||||||
```powershell
|
```powershell
|
||||||
PS C:\> Connect-ZertoServer -zertoServer "192.168.1.100" -zertoPort "9669" -credential $credential
|
PS C:\> Connect-ZertoServer -zertoServer "192.168.1.100" -zertoPort "443" -credential $credential
|
||||||
```
|
```
|
||||||
|
|
||||||
Establishes a connection to ZVM 192.168.1.100 on port 9669 with supplied PSCredential object.
|
Establishes a connection to ZVM 192.168.1.100 on port 443 with supplied PSCredential object.
|
||||||
|
|
||||||
## PARAMETERS
|
### Example 2
|
||||||
|
```powershell
|
||||||
### -credential
|
PS C:\> Connect-ZertoServer -zertoServer "192.168.1.100" -zertoPort "443" -credential $credential -AutoReconnect
|
||||||
Valid credentials to connect to the Zerto Management Server
|
```
|
||||||
|
|
||||||
```yaml
|
Establishes a connection to ZVM 192.168.1.100 on port 443 with supplied PSCredential object. Adding the `-AutoReconnect` switch
|
||||||
Type: PSCredential
|
will cache the PSCredential object should the session need to be reauthorized due to an expired token.
|
||||||
Parameter Sets: (All)
|
|
||||||
Aliases:
|
## PARAMETERS
|
||||||
|
|
||||||
Required: True
|
### -AutoReconnect
|
||||||
Position: 2
|
Use this switch to indicate that you would like the module to take care of auto re-authorization and reconnection to the ZVM should the token expire. This option will cache your PSCredential object to be reused
|
||||||
Default value: None
|
|
||||||
Accept pipeline input: False
|
```yaml
|
||||||
Accept wildcard characters: False
|
Type: SwitchParameter
|
||||||
```
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
### -returnHeaders
|
|
||||||
Use this switch to return the headers to a specified variable or to the default output.
|
Required: False
|
||||||
|
Position: Named
|
||||||
```yaml
|
Default value: None
|
||||||
Type: SwitchParameter
|
Accept pipeline input: False
|
||||||
Parameter Sets: (All)
|
Accept wildcard characters: False
|
||||||
Aliases:
|
```
|
||||||
|
|
||||||
Required: False
|
### -credential
|
||||||
Position: Named
|
Valid credentials to connect to the Zerto Management Server
|
||||||
Default value: None
|
|
||||||
Accept pipeline input: False
|
```yaml
|
||||||
Accept wildcard characters: False
|
Type: PSCredential
|
||||||
```
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
### -zertoPort
|
|
||||||
Zerto Virtual Manager management port.
|
Required: True
|
||||||
Default value is 9669.
|
Position: 1
|
||||||
|
Default value: None
|
||||||
```yaml
|
Accept pipeline input: False
|
||||||
Type: String
|
Accept wildcard characters: False
|
||||||
Parameter Sets: (All)
|
```
|
||||||
Aliases: port
|
|
||||||
|
### -returnHeaders
|
||||||
Required: False
|
Use this switch to return the headers to a specified variable or to the default output.
|
||||||
Position: 1
|
|
||||||
Default value: "9669"
|
```yaml
|
||||||
Accept pipeline input: False
|
Type: SwitchParameter
|
||||||
Accept wildcard characters: False
|
Parameter Sets: (All)
|
||||||
```
|
Aliases:
|
||||||
|
|
||||||
### -zertoServer
|
Required: False
|
||||||
IP address or FQDN of your Zerto Management Server
|
Position: Named
|
||||||
|
Default value: None
|
||||||
```yaml
|
Accept pipeline input: False
|
||||||
Type: String
|
Accept wildcard characters: False
|
||||||
Parameter Sets: (All)
|
```
|
||||||
Aliases: server, zvm
|
|
||||||
|
### -zertoPort
|
||||||
Required: True
|
Zerto Virtual Manager management port.
|
||||||
Position: 0
|
Default value is 443.
|
||||||
Default value: None
|
|
||||||
Accept pipeline input: False
|
```yaml
|
||||||
Accept wildcard characters: False
|
Type: String
|
||||||
```
|
Parameter Sets: (All)
|
||||||
|
Aliases: port
|
||||||
### 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).
|
Required: False
|
||||||
|
Position: Named
|
||||||
## INPUTS
|
Default value: "443"
|
||||||
|
Accept pipeline input: False
|
||||||
### None
|
Accept wildcard characters: False
|
||||||
## OUTPUTS
|
```
|
||||||
|
|
||||||
### System.Object
|
### -zertoServer
|
||||||
## NOTES
|
IP address or FQDN of your Zerto Management Server
|
||||||
|
|
||||||
## RELATED LINKS
|
```yaml
|
||||||
|
Type: String
|
||||||
[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)
|
Parameter Sets: (All)
|
||||||
|
Aliases: server, zvm
|
||||||
[PSCredential Documentation](https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.pscredential?view=pscore-6.0.0)
|
|
||||||
|
Required: True
|
||||||
[Get-Credential Documentation](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/get-credential?view=powershell-6)
|
Position: 0
|
||||||
|
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 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)
|
||||||
|
|||||||
+25
-8
@@ -19,7 +19,7 @@ Get-ZertoEvent [<CommonParameters>]
|
|||||||
|
|
||||||
### filter
|
### filter
|
||||||
```
|
```
|
||||||
Get-ZertoEvent [-startDate <String>] [-endDate <String>] [-vpgName <String>] [-vpgIdentifier <String>]
|
Get-ZertoEvent [-startDate <String>] [-endDate <String>] [-vpg <String>] [-vpgIdentifier <String>]
|
||||||
[-eventType <String>] [-siteName <String>] [-siteIdentifier <String>] [-zorgIdentifier <String>]
|
[-eventType <String>] [-siteName <String>] [-siteIdentifier <String>] [-zorgIdentifier <String>]
|
||||||
[-entityType <String>] [-userName <String>] [-category <String>] [-eventCategory <String>]
|
[-entityType <String>] [-userName <String>] [-category <String>] [-eventCategory <String>]
|
||||||
[-alertIdentifier <String>] [<CommonParameters>]
|
[-alertIdentifier <String>] [<CommonParameters>]
|
||||||
@@ -66,13 +66,27 @@ PS C:\> Get-ZertoEvent -eventId "Need an eventID"
|
|||||||
|
|
||||||
Returns information for each -eventID specified.
|
Returns information for each -eventID specified.
|
||||||
|
|
||||||
### Example 1
|
### Example 3
|
||||||
```powershell
|
```powershell
|
||||||
PS C:\> Get-ZertoEvent -startDate "2019-01-01" -endDate "2019-01-07" -vpg "My Vpg"
|
PS C:\> Get-ZertoEvent -startDate "2019-01-01" -endDate "2019-01-07" -vpg "My Vpg"
|
||||||
```
|
```
|
||||||
|
|
||||||
Returns all events between Jan. 01, 2019 and Jan. 07, 2019 (inclusive) for the vpg "My Vpg"
|
Returns all events between Jan. 01, 2019 and Jan. 07, 2019 (inclusive) for the vpg "My Vpg"
|
||||||
|
|
||||||
|
### Example 4
|
||||||
|
```powershell
|
||||||
|
PS C:\> Get-ZertoEvent -userName "Domain.tld\MyUser
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns all events associated with the username passed into the command.
|
||||||
|
|
||||||
|
### Example 5
|
||||||
|
```powershell
|
||||||
|
PS C:\> Get-ZertoEvent -startDate "2019-01-01T12:30:00" -endDate "2019-01-01T13:30:00" -vpg "My Vpg"
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns all events between Jan. 01, 2019 12:30 PM and Jan. 01, 2019 1:30 PM (inclusive) for the vpg "My Vpg"
|
||||||
|
|
||||||
## PARAMETERS
|
## PARAMETERS
|
||||||
|
|
||||||
### -alertIdentifier
|
### -alertIdentifier
|
||||||
@@ -112,6 +126,7 @@ The type of event to return. This filter behaves in the same way as the eventCat
|
|||||||
Type: String
|
Type: String
|
||||||
Parameter Sets: filter
|
Parameter Sets: filter
|
||||||
Aliases:
|
Aliases:
|
||||||
|
Accepted values: All, Events, Alerts
|
||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: Named
|
Position: Named
|
||||||
@@ -159,6 +174,7 @@ The type of entity for which you wish to return results. Possible Values are: 'V
|
|||||||
Type: String
|
Type: String
|
||||||
Parameter Sets: filter
|
Parameter Sets: filter
|
||||||
Aliases:
|
Aliases:
|
||||||
|
Accepted values: VPG, VRA, Unknown, Site
|
||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: Named
|
Position: Named
|
||||||
@@ -174,6 +190,7 @@ This filter behaves in the same way as the category filter. If both category and
|
|||||||
Type: String
|
Type: String
|
||||||
Parameter Sets: filter
|
Parameter Sets: filter
|
||||||
Aliases:
|
Aliases:
|
||||||
|
Accepted values: All, Events, Alerts
|
||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: Named
|
Position: Named
|
||||||
@@ -292,13 +309,13 @@ Accept pipeline input: False
|
|||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
|
|
||||||
### -vpgIdentifier
|
### -vpg
|
||||||
The identifier of the VPG for which you want to return events.
|
The name of the VPG for which you want to return events.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: String
|
Type: String
|
||||||
Parameter Sets: filter
|
Parameter Sets: filter
|
||||||
Aliases: vpgId
|
Aliases: vpgName
|
||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: Named
|
Position: Named
|
||||||
@@ -307,13 +324,13 @@ Accept pipeline input: False
|
|||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
|
|
||||||
### -vpgName
|
### -vpgIdentifier
|
||||||
The name of the VPG for which you want to return events.
|
The identifier of the VPG for which you want to return events.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: String
|
Type: String
|
||||||
Parameter Sets: filter
|
Parameter Sets: filter
|
||||||
Aliases: vpg
|
Aliases: vpgId
|
||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: Named
|
Position: Named
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ The priority specified for the VPG. Possible values are: 'Low', 'Medium', or 'Hi
|
|||||||
Type: String
|
Type: String
|
||||||
Parameter Sets: filter
|
Parameter Sets: filter
|
||||||
Aliases:
|
Aliases:
|
||||||
|
Accepted values: Low, Medium, High
|
||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: Named
|
Position: Named
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ Possible values are: 'Failover', 'Failover Test', or 'Move'
|
|||||||
Type: String
|
Type: String
|
||||||
Parameter Sets: filter
|
Parameter Sets: filter
|
||||||
Aliases:
|
Aliases:
|
||||||
|
Accepted values: Failover, Failover Test, Move
|
||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: Named
|
Position: Named
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ The status of the task. Possible values are: 'InProgress', 'Paused', 'Failed', '
|
|||||||
Type: String
|
Type: String
|
||||||
Parameter Sets: filter
|
Parameter Sets: filter
|
||||||
Aliases:
|
Aliases:
|
||||||
|
Accepted values: InProgress, Paused, Failed, Completed, Cancelling
|
||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: Named
|
Position: Named
|
||||||
|
|||||||
@@ -271,6 +271,7 @@ The VPG priority. Possible values are: 'Low', 'Medium', 'High'
|
|||||||
Type: String
|
Type: String
|
||||||
Parameter Sets: filter
|
Parameter Sets: filter
|
||||||
Aliases:
|
Aliases:
|
||||||
|
Accepted values: Low, Medium, High
|
||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: Named
|
Position: Named
|
||||||
|
|||||||
@@ -165,6 +165,22 @@ Accept pipeline input: False
|
|||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### -numofCPU
|
||||||
|
Initial number of vCPUs to assign to the VRA.
|
||||||
|
Default is 1, Minimum is 1, Maximum is 4
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: Int32
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: False
|
||||||
|
Position: Named
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
### -memoryInGB
|
### -memoryInGB
|
||||||
Initial amount of memory to assign to the VRA in GB.
|
Initial amount of memory to assign to the VRA in GB.
|
||||||
Default is 3, Minimum is 1, Maximum is 16
|
Default is 3, Minimum is 1, Maximum is 16
|
||||||
|
|||||||
+62
-25
@@ -12,23 +12,30 @@ Start a move of a VPG.
|
|||||||
|
|
||||||
## SYNTAX
|
## SYNTAX
|
||||||
|
|
||||||
### main (Default)
|
### id (Default)
|
||||||
```
|
```
|
||||||
Invoke-ZertoMove [-vpgName] <String[]> [[-commitPolicy] <String>] [[-commitPolicyTimeout] <Int32>]
|
Invoke-ZertoMove -vpgIdentifier <Guid[]> [-forceShutdown] [-disableReverseProtection] [-keepSourceVms]
|
||||||
[-forceShutdown] [-ContinueOnPreScriptFailure] [-WhatIf] [-Confirm] [<CommonParameters>]
|
[-ContinueOnPreScriptFailure] [-WhatIf] [-Confirm] [<CommonParameters>]
|
||||||
```
|
```
|
||||||
|
|
||||||
### disableReverseProtection
|
### commitName
|
||||||
```
|
```
|
||||||
Invoke-ZertoMove [-vpgName] <String[]> [[-commitPolicy] <String>] [[-commitPolicyTimeout] <Int32>]
|
Invoke-ZertoMove -vpgName <String[]> -commitPolicy <String> [-commitPolicyTimeout <Int32>] [-forceShutdown]
|
||||||
[-forceShutdown] [-disableReverseProtection] [-ContinueOnPreScriptFailure] [-WhatIf] [-Confirm]
|
[-disableReverseProtection] [-keepSourceVms] [-ContinueOnPreScriptFailure] [-WhatIf] [-Confirm]
|
||||||
[<CommonParameters>]
|
[<CommonParameters>]
|
||||||
```
|
```
|
||||||
|
|
||||||
### keepSourceVms
|
### name
|
||||||
```
|
```
|
||||||
Invoke-ZertoMove [-vpgName] <String[]> [[-commitPolicy] <String>] [[-commitPolicyTimeout] <Int32>]
|
Invoke-ZertoMove -vpgName <String[]> [-forceShutdown] [-disableReverseProtection] [-keepSourceVms]
|
||||||
[-forceShutdown] [-keepSourceVms] [-ContinueOnPreScriptFailure] [-WhatIf] [-Confirm] [<CommonParameters>]
|
[-ContinueOnPreScriptFailure] [-WhatIf] [-Confirm] [<CommonParameters>]
|
||||||
|
```
|
||||||
|
|
||||||
|
### commitId
|
||||||
|
```
|
||||||
|
Invoke-ZertoMove -vpgIdentifier <Guid[]> -commitPolicy <String> [-commitPolicyTimeout <Int32>] [-forceShutdown]
|
||||||
|
[-disableReverseProtection] [-keepSourceVms] [-ContinueOnPreScriptFailure] [-WhatIf] [-Confirm]
|
||||||
|
[<CommonParameters>]
|
||||||
```
|
```
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
@@ -38,10 +45,24 @@ Start a move of a VPG.
|
|||||||
|
|
||||||
### Example 1
|
### Example 1
|
||||||
```powershell
|
```powershell
|
||||||
PS C:\> Invoke-ZertoMove -vpgName "MyVpg"
|
PS C:\> Invoke-ZertoMove -vpgName 'MyVpg'
|
||||||
```
|
```
|
||||||
|
|
||||||
Starts a move operation of VPG "MyVpg"
|
Specify the name of a vpg to move
|
||||||
|
|
||||||
|
### Example 2
|
||||||
|
```powershell
|
||||||
|
PS C:\> Invoke-ZertoMove -vpgIdentifier '2fbbf6b5-cddc-4653-b1fe-564f069eeb64'
|
||||||
|
```
|
||||||
|
|
||||||
|
Specify the identifier of a vpg to move
|
||||||
|
|
||||||
|
### Example 3
|
||||||
|
```powershell
|
||||||
|
PS C:\> Get-ZertoVpg | Invoke-ZertoMove
|
||||||
|
```
|
||||||
|
|
||||||
|
Utilize the pipeline to move multiple vpgs
|
||||||
|
|
||||||
## PARAMETERS
|
## PARAMETERS
|
||||||
|
|
||||||
@@ -56,11 +77,12 @@ Default is the Site Settings setting.
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: String
|
Type: String
|
||||||
Parameter Sets: (All)
|
Parameter Sets: commitName, commitId
|
||||||
Aliases:
|
Aliases:
|
||||||
|
Accepted values: Rollback, Commit, None
|
||||||
|
|
||||||
Required: False
|
Required: True
|
||||||
Position: 1
|
Position: Named
|
||||||
Default value: None
|
Default value: None
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
@@ -72,11 +94,11 @@ If omitted, the site settings default will be applied.
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: Int32
|
Type: Int32
|
||||||
Parameter Sets: (All)
|
Parameter Sets: commitName, commitId
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: 2
|
Position: Named
|
||||||
Default value: None
|
Default value: None
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
@@ -91,7 +113,7 @@ Parameter Sets: (All)
|
|||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: 6
|
Position: Named
|
||||||
Default value: None
|
Default value: None
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
@@ -102,10 +124,10 @@ Do not enable reverse protection. The VPG definition is kept with the status Nee
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: SwitchParameter
|
Type: SwitchParameter
|
||||||
Parameter Sets: disableReverseProtection
|
Parameter Sets: (All)
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: True
|
Required: False
|
||||||
Position: Named
|
Position: Named
|
||||||
Default value: None
|
Default value: None
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
@@ -121,7 +143,7 @@ Parameter Sets: (All)
|
|||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: False
|
Required: False
|
||||||
Position: 3
|
Position: Named
|
||||||
Default value: None
|
Default value: None
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
@@ -132,13 +154,28 @@ Use this switch to Prevent the protected virtual machines from being deleted in
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: SwitchParameter
|
Type: SwitchParameter
|
||||||
Parameter Sets: keepSourceVms
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: False
|
||||||
|
Position: Named
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -vpgIdentifier
|
||||||
|
ID(s) of the VPG(s) you want to move.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: Guid[]
|
||||||
|
Parameter Sets: id, commitId
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: True
|
Required: True
|
||||||
Position: 5
|
Position: Named
|
||||||
Default value: None
|
Default value: None
|
||||||
Accept pipeline input: False
|
Accept pipeline input: True (ByPropertyName)
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -147,11 +184,11 @@ Name(s) of the VPG(s) you want to move.
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: String[]
|
Type: String[]
|
||||||
Parameter Sets: (All)
|
Parameter Sets: commitName, name
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: True
|
Required: True
|
||||||
Position: 0
|
Position: Named
|
||||||
Default value: None
|
Default value: None
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
|
|||||||
@@ -12,9 +12,19 @@ Commit a VPG currently undergoing a move operation.
|
|||||||
|
|
||||||
## SYNTAX
|
## SYNTAX
|
||||||
|
|
||||||
|
### Main (Default)
|
||||||
```
|
```
|
||||||
Invoke-ZertoMoveCommit [-vpgName] <String[]> [-reverseProtection] [-keepSourceVms] [-WhatIf] [-Confirm]
|
Invoke-ZertoMoveCommit -vpgName <String[]> [-WhatIf] [-Confirm] [<CommonParameters>]
|
||||||
[<CommonParameters>]
|
```
|
||||||
|
|
||||||
|
### ReverseProtect
|
||||||
|
```
|
||||||
|
Invoke-ZertoMoveCommit -vpgName <String[]> [-reverseProtection] [-WhatIf] [-Confirm] [<CommonParameters>]
|
||||||
|
```
|
||||||
|
|
||||||
|
### KeepSource
|
||||||
|
```
|
||||||
|
Invoke-ZertoMoveCommit -vpgName <String[]> [-keepSourceVms] [-WhatIf] [-Confirm] [<CommonParameters>]
|
||||||
```
|
```
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
@@ -27,20 +37,33 @@ Commit a VPG currently undergoing a move operation.
|
|||||||
PS C:\> Invoke-ZertoMoveCommit -vpgName "MyVpg"
|
PS C:\> Invoke-ZertoMoveCommit -vpgName "MyVpg"
|
||||||
```
|
```
|
||||||
|
|
||||||
Commit VPG "MyVpg" after a move has been started.
|
Commit VPG "MyVpg" after a move operation has been completed. This commit process with use the `-KeepSourceVms` or `-ReverseProtection` selection made during the move initation.
|
||||||
|
|
||||||
|
### Example 2
|
||||||
|
```powershell
|
||||||
|
PS C:\> Invoke-ZertoMoveCommit -vpgName "MyVpg" -keepSourceVms
|
||||||
|
```
|
||||||
|
|
||||||
|
Commit VPG "MyVpg" after a move operation has been completed specifying to keep the vms at the source location and NOT reverse protection. This commit process will overrule any reverse protection or keep source vms selection made during the move initiation.
|
||||||
|
|
||||||
|
### Example 3
|
||||||
|
```powershell
|
||||||
|
PS C:\> Invoke-ZertoMoveCommit -vpgName "MyVpg" -reverseProtection
|
||||||
|
```
|
||||||
|
|
||||||
|
Commit VPG "MyVpg" after a move operation has been completed specifying to reverse protection of the VMs back to the source location. The VMs at the source location will be removed from inventory at the source location and the disks will be used as pre-seed volumes. This commit process will overrule any reverse protection or keep source vms selection made during the move initiation.
|
||||||
|
|
||||||
## PARAMETERS
|
## PARAMETERS
|
||||||
|
|
||||||
### -keepSourceVms
|
### -keepSourceVms
|
||||||
Use this switch to keep the source VMs.
|
"Use this switch to keep the source VMs at the source site. If neither 'ReverseProtction' nor 'KeepSourceVms' switch is specified, the commit process will use selection made during move initiation."
|
||||||
If not set, they will be destroyed.
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: SwitchParameter
|
Type: SwitchParameter
|
||||||
Parameter Sets: (All)
|
Parameter Sets: KeepSource
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: False
|
Required: True
|
||||||
Position: Named
|
Position: Named
|
||||||
Default value: None
|
Default value: None
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
@@ -48,14 +71,14 @@ Accept wildcard characters: False
|
|||||||
```
|
```
|
||||||
|
|
||||||
### -reverseProtection
|
### -reverseProtection
|
||||||
Set this to True to reverse protect the VPG(s) to the source site. If not set, will use selection made during move initiation. True or False
|
"Use this switch to reverse protect the VPG(s) to the source site. If neither 'ReverseProtction' nor 'KeepSourceVms' switch is specified, the commit process will use selection made during move initiation."
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: SwitchParameter
|
Type: SwitchParameter
|
||||||
Parameter Sets: (All)
|
Parameter Sets: ReverseProtect
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: False
|
Required: True
|
||||||
Position: Named
|
Position: Named
|
||||||
Default value: None
|
Default value: None
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
@@ -71,7 +94,7 @@ Parameter Sets: (All)
|
|||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: True
|
Required: True
|
||||||
Position: 0
|
Position: Named
|
||||||
Default value: None
|
Default value: None
|
||||||
Accept pipeline input: False
|
Accept pipeline input: False
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
|
|||||||
+13
-13
@@ -8,10 +8,20 @@ schema: 2.0.0
|
|||||||
# New-ZertoVpg
|
# New-ZertoVpg
|
||||||
|
|
||||||
## SYNOPSIS
|
## SYNOPSIS
|
||||||
Creates a New VPG with default settings only. Customization of VM settings can be accomplished with other module level functions.
|
Creates a New VPG with default settings only. Customization of VM settings can be accomplished with other module level functions. Returns a VpgSettingsIdentifier to be passed into the `Save-ZertoVpgSetting` function to create the VPG.
|
||||||
|
|
||||||
## SYNTAX
|
## SYNTAX
|
||||||
|
|
||||||
|
### recoveryHostDatastore (Default)
|
||||||
|
```
|
||||||
|
New-ZertoVpg -vpgName <String> [-vpgPriority <String>] [-journalHistoryInHours <Int32>] -protectedVm <String[]>
|
||||||
|
-recoverySite <String> -recoveryHost <String> -datastore <String> -recoveryFolder <String>
|
||||||
|
[-rpoInSeconds <Int32>] [-testIntervalInMinutes <Int32>] [-serviceProfile <String>]
|
||||||
|
[-useWanCompression <Boolean>] [-zorg <String>] -recoveryNetwork <String> -testNetwork <String>
|
||||||
|
[-journalDatastore <String>] [-journalHardLimitInMb <UInt64>] [-journalWarningThresholdInMb <UInt64>]
|
||||||
|
[-WhatIf] [-Confirm] [<CommonParameters>]
|
||||||
|
```
|
||||||
|
|
||||||
### recoveryClusterDatastoreCluster
|
### recoveryClusterDatastoreCluster
|
||||||
```
|
```
|
||||||
New-ZertoVpg -vpgName <String> [-vpgPriority <String>] [-journalHistoryInHours <Int32>] -protectedVm <String[]>
|
New-ZertoVpg -vpgName <String> [-vpgPriority <String>] [-journalHistoryInHours <Int32>] -protectedVm <String[]>
|
||||||
@@ -42,16 +52,6 @@ New-ZertoVpg -vpgName <String> [-vpgPriority <String>] [-journalHistoryInHours <
|
|||||||
[-WhatIf] [-Confirm] [<CommonParameters>]
|
[-WhatIf] [-Confirm] [<CommonParameters>]
|
||||||
```
|
```
|
||||||
|
|
||||||
### recoveryHostDatastore
|
|
||||||
```
|
|
||||||
New-ZertoVpg -vpgName <String> [-vpgPriority <String>] [-journalHistoryInHours <Int32>] -protectedVm <String[]>
|
|
||||||
-recoverySite <String> -recoveryHost <String> -datastore <String> -recoveryFolder <String>
|
|
||||||
[-rpoInSeconds <Int32>] [-testIntervalInMinutes <Int32>] [-serviceProfile <String>]
|
|
||||||
[-useWanCompression <Boolean>] [-zorg <String>] -recoveryNetwork <String> -testNetwork <String>
|
|
||||||
[-journalDatastore <String>] [-journalHardLimitInMb <UInt64>] [-journalWarningThresholdInMb <UInt64>]
|
|
||||||
[-WhatIf] [-Confirm] [<CommonParameters>]
|
|
||||||
```
|
|
||||||
|
|
||||||
### recoveryResourcePoolDatastoreCluster
|
### recoveryResourcePoolDatastoreCluster
|
||||||
```
|
```
|
||||||
New-ZertoVpg -vpgName <String> [-vpgPriority <String>] [-journalHistoryInHours <Int32>] -protectedVm <String[]>
|
New-ZertoVpg -vpgName <String> [-vpgPriority <String>] [-journalHistoryInHours <Int32>] -protectedVm <String[]>
|
||||||
@@ -176,7 +176,7 @@ Name of the datastore where the VM(s), Volume(s), and Journal(s) will reside.
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: String
|
Type: String
|
||||||
Parameter Sets: recoveryClusterDatastore, recoveryHostDatastore, recoveryResourcePoolDatastore
|
Parameter Sets: recoveryHostDatastore, recoveryClusterDatastore, recoveryResourcePoolDatastore
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: True
|
Required: True
|
||||||
@@ -312,7 +312,7 @@ Name of the host where the VM(s) will be recovered.
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Type: String
|
Type: String
|
||||||
Parameter Sets: recoveryHostDatastoreCluster, recoveryHostDatastore
|
Parameter Sets: recoveryHostDatastore, recoveryHostDatastoreCluster
|
||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: True
|
Required: True
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ Remove-ZertoVpg -vpgidentifier <String[]> [-keepRecoveryVolumes] [-force] [-What
|
|||||||
|
|
||||||
### vpgName
|
### vpgName
|
||||||
```
|
```
|
||||||
Remove-ZertoVpg [-vpgName] <String[]> [-keepRecoveryVolumes] [-force] [-WhatIf] [-Confirm] [<CommonParameters>]
|
Remove-ZertoVpg -vpgName <String[]> [-keepRecoveryVolumes] [-force] [-WhatIf] [-Confirm] [<CommonParameters>]
|
||||||
```
|
```
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
@@ -122,7 +122,7 @@ Parameter Sets: vpgName
|
|||||||
Aliases:
|
Aliases:
|
||||||
|
|
||||||
Required: True
|
Required: True
|
||||||
Position: 0
|
Position: Named
|
||||||
Default value: None
|
Default value: None
|
||||||
Accept pipeline input: True (ByPropertyName, ByValue)
|
Accept pipeline input: True (ByPropertyName, ByValue)
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
|
|||||||
@@ -0,0 +1,121 @@
|
|||||||
|
---
|
||||||
|
external help file: ZertoApiWrapper-help.xml
|
||||||
|
Module Name: ZertoApiWrapper
|
||||||
|
online version: https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Resume-ZertoVpgVm.md
|
||||||
|
schema: 2.0.0
|
||||||
|
---
|
||||||
|
|
||||||
|
# Remove-ZertoVpgVm
|
||||||
|
|
||||||
|
## SYNOPSIS
|
||||||
|
Removes one or more VMs from a specified VPG. A Task Identifier is returned to track progress.
|
||||||
|
|
||||||
|
## SYNTAX
|
||||||
|
|
||||||
|
```
|
||||||
|
Remove-ZertoVpgVm -VpgName <String> -Vm <String[]> [-WhatIf] [-Confirm] [<CommonParameters>]
|
||||||
|
```
|
||||||
|
|
||||||
|
## DESCRIPTION
|
||||||
|
Removes one or more VMs from a specified VPG. A Task Identifier is returned to track progress. Internal logic will remove duplicate VM names from the list of VMs provided as well as ensure membership in the VPG specified prior to attempting to remove the VM from the VPG. Finally the VPG is saved to commit the changes. ChangeImpact is set to 'High' to get the confirmation prompt.
|
||||||
|
|
||||||
|
## EXAMPLES
|
||||||
|
|
||||||
|
### Example 1
|
||||||
|
```powershell
|
||||||
|
PS C:\> Remove-ZertoVpgVm -VpgName 'My Vpg' -Vm 'Vm 1'
|
||||||
|
```
|
||||||
|
|
||||||
|
Removes 'Vm 1' from Vpg named 'My Vpg'
|
||||||
|
|
||||||
|
### Example 2
|
||||||
|
```powershell
|
||||||
|
PS C:\> Remove-ZertoVpgVm -VpgName 'My Vpg' -Vm 'Vm 1', 'Vm 2'
|
||||||
|
```
|
||||||
|
|
||||||
|
Removes 'Vm 1' and 'Vm 2' from Vpg named 'My Vpg'.
|
||||||
|
|
||||||
|
### Example 3
|
||||||
|
```powershell
|
||||||
|
PS C:\> Remove-ZertoVpgVm -VpgName 'My Vpg' -Vm 'Vm 1', 'Vm 2' -Confirm:$False
|
||||||
|
```
|
||||||
|
|
||||||
|
Removes 'Vm 1' and 'Vm 2' from Vpg named 'My Vpg' and bypasses the confirmation prompt
|
||||||
|
|
||||||
|
## PARAMETERS
|
||||||
|
|
||||||
|
### -Vm
|
||||||
|
Name of VM(s) to remove from the VPG
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: String[]
|
||||||
|
Parameter Sets: (All)
|
||||||
|
Aliases:
|
||||||
|
|
||||||
|
Required: True
|
||||||
|
Position: Named
|
||||||
|
Default value: None
|
||||||
|
Accept pipeline input: False
|
||||||
|
Accept wildcard characters: False
|
||||||
|
```
|
||||||
|
|
||||||
|
### -VpgName
|
||||||
|
Name of the VPG that contains the VM you wish to remove
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
Type: String
|
||||||
|
Parameter Sets: (All)
|
||||||
|
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
|
||||||
|
|
||||||
|
### None
|
||||||
|
|
||||||
|
## OUTPUTS
|
||||||
|
|
||||||
|
### System.Object
|
||||||
|
## NOTES
|
||||||
|
|
||||||
|
## RELATED LINKS
|
||||||
|
[Remove Vms from a VPG Settings Object](https://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20(ZVM)%20-%20vSphere%20Online%20Help/content/zvr_apis/vpg_management_api.htm?tocpath=ZVR%20RESTful%20APIs%7CZerto%20APIs%7C_____20#statusapis_4057192544_1361409)
|
||||||
@@ -36,10 +36,10 @@ VpgSettings Identifier to save
|
|||||||
```yaml
|
```yaml
|
||||||
Type: String
|
Type: String
|
||||||
Parameter Sets: (All)
|
Parameter Sets: (All)
|
||||||
Aliases: vpgSettingsId
|
Aliases: sid, settingsIdentifier, vpgSettingsId
|
||||||
|
|
||||||
Required: True
|
Required: True
|
||||||
Position: 1
|
Position: 0
|
||||||
Default value: None
|
Default value: None
|
||||||
Accept pipeline input: True (ByPropertyName, ByValue)
|
Accept pipeline input: True (ByPropertyName, ByValue)
|
||||||
Accept wildcard characters: False
|
Accept wildcard characters: False
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
1.4.1
|
2.1.0
|
||||||
|
|||||||
Reference in New Issue
Block a user