13 Commits

Author SHA1 Message Date
Wes Carroll e16d4d8105 Merge branch 'master' into AzureVpg_v2 2020-09-08 09:06:39 -04:00
Wes Carroll 143d5f801e Start Param Params 2020-09-08 08:06:18 -04:00
Wes Carroll f46c620302 Create Add-ZertoAzureVpgVm Function 2020-08-28 13:59:07 -04:00
Wes Carroll 3c60b0c0f3 Create Help File for New-ZertoAzureVpg 2020-08-28 13:59:06 -04:00
Wes Carroll d832812c13 Spelling Typo 2020-08-28 13:59:06 -04:00
Wes Carroll 80e0db3883 Create Add-ZertoAzureVpg function 2020-08-28 13:59:06 -04:00
Wes Carroll 809f9af60d Create Get-ZertoAzureResource function tests 2020-08-28 13:59:06 -04:00
Wes Carroll 5a9cba00d5 Get-ZertoAzureResource Help Creation 2020-08-28 13:59:06 -04:00
Wes Carroll 549238a22d Update Changelog with changes 2020-08-28 13:59:06 -04:00
Wes Carroll 253c9ba1b9 Add siteidentifier valid site validation 2020-08-28 13:59:06 -04:00
Wes Carroll 794f87dbf8 Add helpmessages for each switch 2020-08-28 13:59:06 -04:00
Wes Carroll ca45adcd5d Azure VPG Helper Functions Consolidated 2020-08-28 13:59:06 -04:00
Wes Carroll 5a3f2d8eec Azure VPG Helper Functions Creation 2020-08-28 13:59:06 -04:00
128 changed files with 1338 additions and 506 deletions
+3 -36
View File
@@ -5,46 +5,13 @@ 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/),
and this project is transitioning to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [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]
## Unreleased
### 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.
#### New
* Added `Get-ZertoAzureResource` function to the module. This function is designed to retrieve information about resources in Azure that can be utilized when creating VPGs targeting the specified Azure site. Please read the [help file](https://github.com/ZertoPublic/ZertoApiWrapper/blob/master/docs/Get-ZertoAzureResource.md) for more information and examples.
## [1.5.1]
### Zerto Virtual Manager
-1
View File
@@ -36,7 +36,6 @@ All recent updates can now be tracked via the [Change Log](https://github.com/Ze
## TODO
* Support ZVM appliance (different connection flow)
* JFLR Functionality
* Create VPG (Per-VM modification and Backup Settings)
* Edit VPG
+31 -31
View File
@@ -21,7 +21,7 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
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 -Type String
Get-Command $global:function | Should -HaveParameter zertoPort -DefaultValue "443"
Get-Command $global:function | Should -HaveParameter zertoPort -DefaultValue "9669"
}
It "port variable does not accecpt an empty or null input" {
@@ -46,10 +46,10 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
{ 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 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
@@ -73,7 +73,7 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
$server = '192.168.1.100'
$password = ConvertTo-SecureString -String "NotARealPassword" -AsPlainText -Force
$credential = New-Object pscredential('NotARealUser', $password)
#$now = $(Get-Date).ticks
$now = $(Get-Date).ticks
Connect-ZertoServer -zertoServer $server -credential $credential
}
@@ -84,7 +84,7 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
It "Module Scope zvmPort variable tests" {
$script:zvmPort | Should -Not -BeNullOrEmpty
$script:zvmPort | Should -Be '443'
$script:zvmPort | Should -Be '9669'
}
It "Module Scope zvmLastAction variable tests" {
@@ -92,38 +92,38 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
$script:zvmLastAction | Should -BeGreaterOrEqual $now
}
#It "Module Scope zvmHeaders variable tests" {
# $script:zvmHeaders | Should -Not -BeNullOrEmpty
# $script:zvmHeaders | Should -BeOfType PSCustomObject
# $script:zvmHeaders.keys.count | Should -BeExactly 3
#$script:zvmHeaders.ContainsKey('x-zerto-session') | Should -BeTrue
# $script:zvmHeaders.ContainsKey('Accept') | Should -BeTrue
#$script:zvmHeaders['x-zerto-session'] | Should -BeOfType String
# $script:zvmHeaders['Accept'] | Should -BeOfType String
#}
It "Module Scope zvmHeaders variable tests" {
$script:zvmHeaders | Should -Not -BeNullOrEmpty
$script:zvmHeaders | Should -BeOfType PSCustomObject
$script:zvmHeaders.keys.count | Should -BeExactly 3
$script:zvmHeaders.ContainsKey('x-zerto-session') | Should -BeTrue
$script:zvmHeaders.ContainsKey('Accept') | Should -BeTrue
$script:zvmHeaders['x-zerto-session'] | Should -BeOfType String
$script:zvmHeaders['Accept'] | Should -BeOfType String
}
#$headers = Connect-ZertoServer -zertoServer $Server -credential $credential -returnHeaders
#It "returns a Hashtable with 2 keys" {
# $headers | Should -BeOfType Hashtable
# $headers.keys.count | Should -Be 3
#}
$headers = Connect-ZertoServer -zertoServer $Server -credential $credential -returnHeaders
It "returns a Hashtable with 2 keys" {
$headers | Should -BeOfType Hashtable
$headers.keys.count | Should -Be 3
}
#It "return value has a key called 'x-zerto-session'" {
# $headers.ContainsKey('x-zerto-session') | Should -Be $true
#}
It "return value has a key called 'x-zerto-session'" {
$headers.ContainsKey('x-zerto-session') | Should -Be $true
}
#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 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'" {
$headers.ContainsKey('accept') | Should -Be $true
}
#It "return key 'accept' value should be 'application/json'" {
# $headers['accept'] | Should -Be 'application/json'
#}
It "return key 'accept' value should be 'application/json'" {
$headers['accept'] | Should -Be 'application/json'
}
It "should not require a port to be specified" {
Connect-ZertoServer -zertoServer $Server -credential $credential
-4
View File
@@ -46,10 +46,6 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
return "1024d377-afb8-4880-82f0-96eeff413ffd"
}
Mock -ModuleName ZertoApiWrapper -CommandName Remove-ZertoVpgSettingsIdentifier {
return $null
}
Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpgSetting {
$returnObj = @{
Backup = $null
@@ -0,0 +1,56 @@
#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 17 parameters defined" {
(Get-Command $global:function).Parameters.Count | Should -Be 17
}
$ParameterTestCases = @(
@{ParameterName = 'siteName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
@{ParameterName = 'SiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
@{ParameterName = 'SecurityGroup'; Type = 'Switch'; Mandatory = $true; Validation = 'None' }
@{ParameterName = 'Subnet'; Type = 'Switch'; Mandatory = $true; Validation = 'None' }
@{ParameterName = 'Network'; Type = 'Switch'; Mandatory = $true; Validation = 'None' }
@{ParameterName = 'VmInstanceType'; Type = 'Switch'; Mandatory = $true; Validation = 'None' }
)
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) {
'None' {
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
$attrs.Count | Should -Be 3
}
'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"
}
}
}
}
Context "$global:function::Functional Unit Tests" {
}
}
Remove-Variable -Name here -Scope Global
Remove-Variable -Name function -Scope Global
+1 -1
View File
@@ -6,7 +6,7 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
Context "$global:function::Parameter Unit Tests" {
It "$global:function should have exactly 24 parameters defined" {
(Get-Command $global:function).Parameters.Count | Should -Be 25
(Get-Command $global:function).Parameters.Count | Should -Be 24
}
$ParameterTestCases = @(
+16 -16
View File
@@ -24,13 +24,13 @@
},
"LastTest": null,
"Link": {
"href": "https://192.168.10.20/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-38?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
"href": "https://192.168.10.20:9669/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",
"rel": null,
"type": "VmApi"
},
"Link_{0}": {
"href": "https://192.168.10.20/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-38?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-38?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
"rel": "self",
"type": "VmApi"
},
@@ -38,7 +38,7 @@
"OutgoingBandWidthInMbps": 0.001953125,
"Priority": 1,
"ProtectedSite": {
"href": "https://192.168.10.20/v1/localsite",
"href": "https://192.168.10.20:9669/v1/localsite",
"identifier": "9e09efa0-0d00-46ed-929b-f86273b28205",
"rel": null,
"type": "LocalSiteApi"
@@ -46,7 +46,7 @@
"ProvisionedStorageInMB": 77906,
"RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15",
"RecoverySite": {
"href": "https://192.168.10.20/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
"href": "https://192.168.10.20:9669/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
"identifier": "057cab27-f02a-443a-989d-7f14341fa9c3",
"rel": null,
"type": "PeerSiteApi"
@@ -92,13 +92,13 @@
},
"LastTest": null,
"Link": {
"href": "https://192.168.10.20/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-37?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
"href": "https://192.168.10.20:9669/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",
"rel": null,
"type": "VmApi"
},
"Link_{0}": {
"href": "https://192.168.10.20/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-37?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-37?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
"rel": "self",
"type": "VmApi"
},
@@ -106,7 +106,7 @@
"OutgoingBandWidthInMbps": 0.0009765625,
"Priority": 1,
"ProtectedSite": {
"href": "https://192.168.10.20/v1/localsite",
"href": "https://192.168.10.20:9669/v1/localsite",
"identifier": "9e09efa0-0d00-46ed-929b-f86273b28205",
"rel": null,
"type": "LocalSiteApi"
@@ -114,7 +114,7 @@
"ProvisionedStorageInMB": 77906,
"RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15",
"RecoverySite": {
"href": "https://192.168.10.20/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
"href": "https://192.168.10.20:9669/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
"identifier": "057cab27-f02a-443a-989d-7f14341fa9c3",
"rel": null,
"type": "PeerSiteApi"
@@ -160,13 +160,13 @@
},
"LastTest": null,
"Link": {
"href": "https://192.168.10.20/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-36?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
"href": "https://192.168.10.20:9669/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",
"rel": null,
"type": "VmApi"
},
"Link_{0}": {
"href": "https://192.168.10.20/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-36?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-36?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
"rel": "self",
"type": "VmApi"
},
@@ -174,7 +174,7 @@
"OutgoingBandWidthInMbps": 0.00146484375,
"Priority": 1,
"ProtectedSite": {
"href": "https://192.168.10.20/v1/localsite",
"href": "https://192.168.10.20:9669/v1/localsite",
"identifier": "9e09efa0-0d00-46ed-929b-f86273b28205",
"rel": null,
"type": "LocalSiteApi"
@@ -182,7 +182,7 @@
"ProvisionedStorageInMB": 77906,
"RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15",
"RecoverySite": {
"href": "https://192.168.10.20/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
"href": "https://192.168.10.20:9669/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
"identifier": "057cab27-f02a-443a-989d-7f14341fa9c3",
"rel": null,
"type": "PeerSiteApi"
@@ -228,13 +228,13 @@
},
"LastTest": null,
"Link": {
"href": "https://192.168.10.20/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-26?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
"href": "https://192.168.10.20:9669/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",
"rel": null,
"type": "VmApi"
},
"Link_{0}": {
"href": "https://192.168.10.20/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-26?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-26?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
"rel": "self",
"type": "VmApi"
},
@@ -242,7 +242,7 @@
"OutgoingBandWidthInMbps": 0.01953125,
"Priority": 1,
"ProtectedSite": {
"href": "https://192.168.10.20/v1/localsite",
"href": "https://192.168.10.20:9669/v1/localsite",
"identifier": "9e09efa0-0d00-46ed-929b-f86273b28205",
"rel": null,
"type": "LocalSiteApi"
@@ -250,7 +250,7 @@
"ProvisionedStorageInMB": 102400,
"RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15",
"RecoverySite": {
"href": "https://192.168.10.20/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
"href": "https://192.168.10.20:9669/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
"identifier": "057cab27-f02a-443a-989d-7f14341fa9c3",
"rel": null,
"type": "PeerSiteApi"
+5 -5
View File
@@ -28,13 +28,13 @@
"IOPs": 8,
"LastTest": "2019-07-11T16:51:07.022Z",
"Link": {
"href": "https://192.168.222.1/v1/vpgs/99c460c1-a4ec-48dd-8921-bbcca9cd29b9",
"href": "https://192.168.222.1:7669/v1/vpgs/99c460c1-a4ec-48dd-8921-bbcca9cd29b9",
"identifier": "99c460c1-a4ec-48dd-8921-bbcca9cd29b9",
"rel": null,
"type": "VpgApi"
},
"Link_{0}": {
"href": "https://192.168.222.1/v1/vpgs/99c460c1-a4ec-48dd-8921-bbcca9cd29b9",
"href": "https://192.168.222.1:7669/v1/vpgs/99c460c1-a4ec-48dd-8921-bbcca9cd29b9",
"rel": "self",
"type": "VpgApi"
},
@@ -42,14 +42,14 @@
"Priority": 1,
"ProgressPercentage": 0,
"ProtectedSite": {
"href": "https://192.168.222.1/v1/localsite",
"href": "https://192.168.222.1:7669/v1/localsite",
"identifier": "63a62dc2-ef6f-45aa-809f-9dbaeb8c06cf",
"rel": null,
"type": "LocalSiteApi"
},
"ProvisionedStorageInMB": 400,
"RecoverySite": {
"href": "https://192.168.222.1/v1/peersites/3e4cdd0d-1064-4022-921f-6265ad6d335a",
"href": "https://192.168.222.1:7669/v1/peersites/3e4cdd0d-1064-4022-921f-6265ad6d335a",
"identifier": "3e4cdd0d-1064-4022-921f-6265ad6d335a",
"rel": null,
"type": "PeerSiteApi"
@@ -67,7 +67,7 @@
"VpgIdentifier": "99c460c1-a4ec-48dd-8921-bbcca9cd29b9",
"VpgName": "Exchange",
"Zorg": {
"href": "https://192.168.222.1/v1/zorgs/00000000-0000-0000-0000-000000000000",
"href": "https://192.168.222.1:7669/v1/zorgs/00000000-0000-0000-0000-000000000000",
"identifier": "00000000-0000-0000-0000-000000000000",
"rel": null,
"type": "ZorgApi"
+1 -1
View File
@@ -31,7 +31,7 @@
SkipPublisherCheck = $true
}
Target = 'CurrentUser'
Version = '1.21.0'
Version = '1.19.0'
Tags = 'Bootstrap'
}
+20 -20
View File
@@ -52,7 +52,7 @@ task CheckPSScriptAnalyzerInstalled {
task AnalyzeSourceFiles CheckPSScriptAnalyzerInstalled, {
$scriptAnalyzerParams = @{
Path = "$BuildRoot\ZertoApiWrapper\"
Severity = @('Error') #, 'Warning')
Severity = @('Error', 'Warning')
Recurse = $true
Verbose = $false
ExcludeRule = @('PSUseToExportFieldsInManifest', 'PSUseBOMForUnicodeEncodedFile', 'PSUseSingularNouns', 'PSReviewUnusedParameter')
@@ -67,7 +67,7 @@ task AnalyzeSourceFiles CheckPSScriptAnalyzerInstalled, {
task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, CreatePsm1ForRelease, {
$scriptAnalyzerParams = @{
Path = $moduleOutPath
Severity = @('Error') #, 'Warning')
Severity = @('Error', 'Warning')
Recurse = $true
Verbose = $false
ExcludeRule = @('PSUseSingularNouns', 'PSUseBOMForUnicodeEncodedFile', 'PSReviewUnusedParameter')
@@ -93,21 +93,21 @@ task CleanPublish {
#EndRegion
#Region - Pester Tests
#task SourceFileTests CheckPesterInstalled, {
# ImportSourceModule
# $testResultsFile = "$BuildRoot\Tests\SourceTestResults.xml"
# $script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru -Show Fails
# $FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount
# Assert ($results.FailedCount -eq 0) $FailureMessage
#}
task SourceFileTests CheckPesterInstalled, {
ImportSourceModule
$testResultsFile = "$BuildRoot\Tests\SourceTestResults.xml"
$script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru -Show Fails
$FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount
Assert ($results.FailedCount -eq 0) $FailureMessage
}
#task BuiltFileTests CreatePsm1ForRelease, CheckPesterInstalled, {
# ImportBuiltModule
# $testResultsFile = "$BuildRoot\Tests\BuiltTestResults.xml"
# $script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru -Show Failed
# $FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount
# Assert ($results.FailedCount -eq 0) $FailureMessage
#}
task BuiltFileTests CreatePsm1ForRelease, CheckPesterInstalled, {
ImportBuiltModule
$testResultsFile = "$BuildRoot\Tests\BuiltTestResults.xml"
$script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru -Show Failed
$FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount
Assert ($results.FailedCount -eq 0) $FailureMessage
}
#EndRegion
#Region - Build Help System
@@ -182,8 +182,8 @@ task CreatePsm1ForRelease CreatePsd1ForRelease, {
#EndRegion
#Region - Artifacts \ Publish
# Full Build Process - No Publishing add this later \/ BuiltFileTests,
task CreateArtifacts CleanPublish, AnalyzeBuiltFiles, BuildMamlHelp, {
# Full Build Process - No Publishing
task CreateArtifacts CleanPublish, AnalyzeBuiltFiles, BuiltFileTests, BuildMamlHelp, {
Compress-Archive -Path $moduleOutPath -DestinationPath .\publish\ZertoApiWrapper.zip
$MyMatches = Select-String -Path "$BuildRoot\CHANGELOG.md" "^##\s\["
$data = Get-Content "$BuildRoot\CHANGELOG.md"
@@ -193,8 +193,8 @@ task CreateArtifacts CleanPublish, AnalyzeBuiltFiles, BuildMamlHelp, {
}
}
#EndRegion
# addd back to line below between analyze and create BuiltFileTests,
task build CleanPublish, CreatePsm1ForRelease, AnalyzeBuiltFiles, CreateArtifacts
task build CleanPublish, CreatePsm1ForRelease, AnalyzeBuiltFiles, BuiltFileTests, CreateArtifacts
task quickBuild CleanPublish, CreatePsm1ForRelease, AnalyzeBuiltFiles, {
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
ImportBuiltModule
@@ -0,0 +1,170 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Add-ZertoAzureVpgVm {
[Cmdletbinding()]
param(
[Parameter(
Mandatory,
HelpMessage = "VPG Settings Identifier of the target VPG.",
ValueFromPipeline,
ValueFromPipelineByPropertyName
)]
[ValidateNotNullOrEmpty()]
[Guid]$VpgSettingsIdentifier,
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[String]$VmName,
[ValidateNotNullOrEmpty()]
[String]$LiveNetworkName,
[ValidateNotNullOrEmpty()]
[String]$LiveSubnetName,
[ValidateNotNullOrEmpty()]
[String]$LiveSecurityGroupName,
[ValidateNotNullOrEmpty()]
[String]$LiveInstanceType,
[ValidateSet("UnmanagedStandard", "ManagedPremiumSSD", "ManagedStandardSSD", "ManagedStandardHDD")]
[String]$LiveDiskType,
[ValidateScript( { $_ -match [IPAddress]$_ })]
[String]$LiveIpAddress,
[ValidateNotNullOrEmpty()]
[String]$TestNetworkName,
[ValidateNotNullOrEmpty()]
[String]$TestSubnetName,
[ValidateNotNullOrEmpty()]
[String]$TestSecurityGroupName,
[ValidateNotNullOrEmpty()]
[String]$TestInstanceType,
[ValidateSet("UnmanagedStandard", "ManagedPremiumSSD", "ManagedStandardSSD", "ManagedStandardHDD")]
[String]$TestDiskType,
[ValidateScript( { $_ -match [IPAddress]$_ })]
[String]$TestIpAddress,
[ValidateNotNullOrEmpty()]
[String[]]$TempDrive
)
begin {
}
process {
# Get Target Site Identifier from the settings for resource lookups
$TargetSiteIdentifier = Get-ZertoVpgSetting -vpgSettingsIdentifier $VpgSettingsIdentifier -basic | Select-Object -ExpandProperty RecoverySiteIdentifier
# Add VM to VPG. Setting to Null as this function returns the VpgSettingsIdentifier
$null = Add-ZertoVpgVm -vpgSettingsIdentifier $VpgSettingsIdentifier -vm $VmName
# Getting the VmIdentifier
$VmIdentifier = Get-ZertoVpgSetting -vpgSettingsIdentifier $VpgSettingsIdentifier -vms | Where-Object { $_.VmName -match $VmName } | Select-Object -ExpandProperty VmIdentifier
# Setting the URI fragment for use later
$VmSettingsUri = "vpgSettings/{0}/vms/{1}" -f $VpgSettingsIdentifier, $VmIdentifier
# Getting all default settings for the specified VM to update per passed parameters
$VmSettings = Get-ZertoVpgSetting -vpgSettingsIdentifier $VpgSettingsIdentifier -vmIdentifier $VmIdentifier
# Create Maps for quick lookups and validations
$NetworksMap = GetMap -InputObject (Get-ZertoAzureResource -SiteIdentifier $TargetSiteIdentifier -Network) -Key "VirtualNetworkName" -Value "VirtualNetworkIdentifier"
$SubnetsMap = GetMap -InputObject (Get-ZertoAzureResource -SiteIdentifier $TargetSiteIdentifier -Subnet) -Key "SubnetName" -Value "SubnetIdentifier"
$SecurityGroupsMap = GetMap -InputObject (Get-ZertoAzureResource -SiteIdentifier $TargetSiteIdentifier -SecurityGroup) -Key "SecurityGroupName" -Value "SecurityGroupIdentifier"
$Instances = Get-ZertoAzureResource -SiteIdentifier $TargetSiteIdentifier -VmInstanceType
# Iterate through the bound parameters and set attributes accordingly
Switch ($PSBoundParameters.Keys) {
"LiveNetworkName" {
if ($null -eq $NetworksMap[$LiveNetworkName]) {
Write-Error "Unable to find network with name $LiveNetworkName. Please check the name and try again." -ErrorAction Stop
} else {
$VmSettings.Recovery.PublicCloud.Failover.VirtualNetworkIdentifier = $NetworksMap[$LiveNetworkName]
}
}
"LiveSubnetName" {
if ($null -eq $SubnetsMap[$LiveSubnetName]) {
Write-Error "Unable to find subnet with name $LiveSubnetName. Please check the name and try again." -ErrorAction Stop
} else {
$VmSettings.Nics[0].Failover.PublicCloud.SubnetIdentifier = $SubnetsMap[$LiveSubnetName]
}
}
"LiveSecurityGroupName" {
if ($null -eq $null -eq $SecurityGroupsMap[$LiveSecurityGroupName]) {
Write-Error "Unable to find security group with name $LiveSecurityGroupName. Please check the name and try again." -ErrorAction Stop
} else {
$VmSettings.Nics[0].Failover.PublicCloud.SecurityGroupIdentifier = $SecurityGroupsMap[$LiveSecurityGroupName]
}
}
"LiveInstanceType" {
if ($LiveInstanceType -notin $Instances.VmInstanceType) {
Write-Error "Unable to find a supported VM Instance Type with name $LiveInstanceType. Please check the name and try again." -ErrorAction Stop
} else {
$LiveInstanceType = $Instances.Where( { $_.VmInstanceType -match $LiveInstanceType }) | Select-Object -ExpandProperty VmInstanceType
$VmSettings.Recovery.PublicCloud.Failover.VmInstanceType = $LiveInstanceType
}
}
"TestNetworkName" {
if ($null -eq $NetworksMap[$TestNetworkName]) {
Write-Error "Unable to find network with name $TestNetworkName. Please check the name and try again." -ErrorAction Stop
} else {
$VmSettings.Recovery.PublicCloud.FailoverTest.VirtualNetworkIdentifier = $NetworksMap[$TestNetworkName]
}
}
"TestSubnetName" {
if ($null -eq $SubnetsMap[$TestSubnetName]) {
Write-Error "Unable to find subnet with name $TestSubnetName. Please check the name and try again." -ErrorAction Stop
} else {
$VmSettings.Nics[0].FailoverTest.PublicCloud.SubnetIdentifier = $SubnetsMap[$TestSubnetName]
}
}
"TestSecurityGroupName" {
if ($null -eq $SecurityGroupsMap) {
Write-Error "Unable to find security group with name $TestSecurityGroupName. Please check the name and try again." -ErrorAction Stop
} else {
$VmSettings.Nics[0].FailoverTest.PublicCloud.SecurityGroupIdentifier = $SecurityGroupsMap[$TestSecurityGroupName]
}
}
"TestInstanceType" {
if ($TestInstanceType -notin $Instances.VmInstanceType) {
Write-Error "Unable to find a supported VM Instance Type with name $TestInstanceType. Please check the name and try again." -ErrorAction Stop
} else {
$TestInstanceType = $Instances.Where( { $_.VmInstanceType -match $TestInstanceType }) | Select-Object -ExpandProperty VmInstanceType
$VmSettings.Recovery.PublicCloud.FailoverTest.VmInstanceType = $TestInstanceType
}
}
"LiveDiskType" {
$VmSettings.Recovery.PublicCloud.Failover.Azure.RecoveryDiskType = $LiveDiskType
}
"TestDiskType" {
$VmSettings.Recovery.PublicCloud.FailoverTest.Azure.RecoveryDiskType = $TestDiskType
}
"LiveIpAddress" {
$VmSettings.Nics[0].Failover.PublicCloud.PrivateIP = $LiveIpAddress
}
"TestIpAddress" {
$VmSettings.Nics[0].FailoverTest.PublicCloud.PrivateIP = $TestIpAddress
}
} # End Switch Statement
# Update the VPG VM Settings Object with the updated attributes
$null = Invoke-ZertoRestRequest -uri $VmSettingsUri -method PUT -body ($VmSettings | ConvertTo-Json -Depth 10)
# If any Temp Drives are specified, loop through them and set them as such
if ($PSBoundParameters.Keys -contains "TempDrive") {
foreach ($drive in $TempDrive) {
$driveUri = "{0}/volumes/{1}" -f $VmSettingsUri, $drive
$driveSettings = Invoke-ZertoRestRequest -uri $driveUri
$driveSettings.IsSwap = $True
$null = Invoke-ZertoRestRequest -uri $driveUri -method PUT -body ($driveSettings | ConvertTo-Json -Depth 10)
}
}
}
end {
}
}
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Add-ZertoPeerSite {
[cmdletbinding( SupportsShouldProcess = $true )]
param(
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Add-ZertoVpgVm {
[CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = "VpgName")]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Checkpoint-ZertoVpg {
[cmdletbinding()]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Connect-ZertoAnalytics {
[cmdletbinding()]
param(
+12 -21
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Connect-ZertoServer {
[cmdletbinding()]
[OutputType([hashtable])]
@@ -19,35 +18,29 @@ function Connect-ZertoServer {
)]
[System.Management.Automation.PSCredential]$credential,
[Parameter(
HelpMessage = "Zerto Virtual Manager management port. Default value is 443."
HelpMessage = "Zerto Virtual Manager management port. Default value is 9669."
)]
[ValidateNotNullOrEmpty()]
[ValidateRange(443, 65535)]
[ValidateRange(1024, 65535)]
[Alias("port")]
[string]$zertoPort = "443",
[Parameter(
HelpMessage = "Zerto Keycloak client id. Default value is zerto-client."
)]
[ValidateNotNullOrEmpty()]
[Alias("clientid")]
[string]$zertoClientId = "zerto-client",
[string]$zertoPort = "9669",
[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."
HelpMessage = "Use this switch to return the headers to a specified variable or to the default output."
)]
[switch]$returnToken
[switch]$returnHeaders
)
begin {
$uri = "auth/realms/zerto/protocol/openid-connect/token"
$body = '{"AuthenticationMethod": "1"}'
$uri = "session/add"
# 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 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-Variable -Name zvmLastAction -Scope Script -Value $(Get-Date).Ticks
# Set / Clear the zvmHeaders to clear any existing token
@@ -59,21 +52,19 @@ function Connect-ZertoServer {
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 {
# Send authorization request to the function and send back the results including headers -returnHeaders
$results = Invoke-ZertoRestRequest -uri $uri -credential $credential -method POST -ErrorAction Stop
# Send authorization request to the function and send back the results including headers
$results = Invoke-ZertoRestRequest -uri $uri -credential $credential -returnHeaders -body $body -method POST -ErrorAction Stop
}
end {
# Build Headers Hashtable with Authorization Token
$script:zvmHeaders['Authorization'] = "Bearer " + $results.access_token.ToString()
$Script:zvmHeaders['x-zerto-session'] = $results.Headers['x-zerto-session'][0].ToString()
# Have the option to return the headers to a variable
if ($returnToken) {
if ($returnHeaders) {
return $Script:zvmHeaders
}
}
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Copy-ZertoVpg {
[CmdletBinding(SupportsShouldProcess)]
param (
@@ -1,12 +1,11 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Disconnect-ZertoServer {
[cmdletbinding()]
param()
$uri = "auth/realms/zerto/protocol/openid-connect/logout"
$uri = "session"
# Delete API Authorization
$null = Invoke-ZertoRestRequest -uri $uri -method POST
$null = Invoke-ZertoRestRequest -uri $uri -method DELETE
# Remove all variables used
Remove-Variable -Name zvmServer -Scope Script
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Edit-ZertoVra {
[cmdletbinding( SupportsShouldProcess = $true )]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Export-ZertoVmNicSetting {
[CmdletBinding()]
param (
+1 -3
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Export-ZertoVpg {
[cmdletbinding()]
param(
@@ -39,7 +38,6 @@ function Export-ZertoVpg {
$vpgSettings = Get-ZertoVpgSetting -vpgSettingsIdentifier $vpgSettingsIdentifier
$filePath = "{0}\{1}.json" -f $outputPath, $name
$vpgSettings | Convertto-Json -depth 10 | Out-File -FilePath $filePath
$null = Remove-ZertoVpgSettingsIdentifier -vpgSettingsIdentifier $vpgSettingsIdentifier
}
}
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAAlert {
[cmdletbinding( DefaultParameterSetName = "zOrg")]
param(
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZADatastore {
[CmdletBinding(DefaultParameterSetName = "AllInfo")]
param (
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAEvent {
[cmdletbinding()]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAJournalAverageHistory {
[CmdletBinding()]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAJournalAverageSize {
[CmdletBinding()]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAJournalBreach {
[CmdletBinding()]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAJournalHistoryStat {
[CmdletBinding()]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAJournalSiteAverageHistory {
[CmdletBinding()]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAJournalSiteAverageSize {
[CmdletBinding()]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAJournalSiteHistoryStat {
[CmdletBinding()]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAJournalSiteHistorySummary {
[CmdletBinding()]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAJournalSiteSizeStat {
[CmdletBinding()]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAJournalStatusProportion {
[CmdletBinding()]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAJournalStorageStat {
[CmdletBinding()]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAJournalSummary {
[CmdletBinding()]
param (
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZALicense {
[cmdletbinding()]
param()
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAMonitoring {
[cmdletbinding()]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZANetworkSiteAverageIOPS {
[CmdletBinding(DefaultParameterSetName = "ProtectedSite")]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZANetworkSiteAveragePerformance {
[CmdletBinding(DefaultParameterSetName = "ProtectedSite")]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZANetworkSiteStat {
[CmdletBinding(DefaultParameterSetName = "ProtectedSite")]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZANetworkSiteSummary {
[CmdletBinding(DefaultParameterSetName = "ProtectedSite")]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZANetworkVpgAverageIOPS {
[CmdletBinding()]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZANetworkVpgAveragePerformance {
[CmdletBinding()]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZANetworkVpgStat {
[CmdletBinding()]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZANetworkVpgSummary {
[CmdletBinding()]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAPlannerJournalSizeReport {
[cmdletbinding()]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAPlannerNetworkPerformanceReport {
[cmdletbinding()]
param(
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAPlannerSite {
[cmdletbinding()]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAPlannerStatsReport {
[cmdletbinding()]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAPlannerWanReport {
[cmdletbinding()]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAPlannerZcasReport {
[cmdletbinding()]
param(
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAProtectedVm {
[cmdletbinding(DefaultParameterSetName = "AllVMs")]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAProtectedVmReport {
[cmdletbinding()]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZARPOAccountAverage {
[CmdletBinding()]
param (
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZARPOAverage {
[CmdletBinding()]
param (
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZARPOBreach {
[CmdletBinding()]
param (
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZARPOStat {
[CmdletBinding()]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZARPOStatusProportion {
[CmdletBinding()]
param (
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZARPOSummary {
[CmdletBinding()]
param (
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZASite {
[cmdletbinding()]
param(
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZASitePair {
[cmdletbinding()]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZASiteTopology {
[cmdletbinding()]
param(
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZATask {
[cmdletbinding( DefaultParameterSetName = "zOrg")]
param(
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAVolume {
[CmdletBinding(DefaultParameterSetName = "VpgIdentifier")]
param (
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAVpg {
[cmdletbinding(DefaultParameterSetName = 'zOrg')]
param(
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZAzOrg {
[cmdletbinding()]
param()
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoAlert {
[cmdletbinding( defaultParameterSetName = "main" )]
param(
@@ -0,0 +1,137 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoAzureResource {
[CmdletBinding(DefaultParameterSetName = "SiteNameVmInstanceType")]
param (
[Parameter(
Mandatory,
HelpMessage = "Name the Azure Site you wish to get the information.",
ParameterSetName = "SiteNameSecurityGroup"
)]
[Parameter(
Mandatory,
HelpMessage = "Name the Azure Site you wish to get the information.",
ParameterSetName = "SiteNameSubnet"
)]
[Parameter(
Mandatory,
HelpMessage = "Name the Azure Site you wish to get the information.",
ParameterSetName = "SiteNameNetwork"
)]
[Parameter(
Mandatory,
HelpMessage = "Name the Azure Site you wish to get the information.",
ParameterSetName = "SiteNameVmInstanceType"
)]
[ValidateNotNullOrEmpty()]
[String]$SiteName,
[Parameter(
Mandatory,
HelpMessage = "Site Identifier of the Azure Site you wish to get the information.",
ParameterSetName = "SiteIdentifierSecurityGroup"
)]
[Parameter(
Mandatory,
HelpMessage = "Site Identifier of the Azure Site you wish to get the information.",
ParameterSetName = "SiteIdentifierSubnet"
)]
[Parameter(
Mandatory,
HelpMessage = "Site Identifier of the Azure Site you wish to get the information.",
ParameterSetName = "SiteIdentifierNetwork"
)]
[Parameter(
Mandatory,
HelpMessage = "Site Identifier of the Azure Site you wish to get the information.",
ParameterSetName = "SiteIdentifierVmInstanceType"
)]
[ValidateNotNullOrEmpty()]
[String]$SiteIdentifier,
[Parameter(
Mandatory,
ParameterSetName = "SiteIdentifierSecurityGroup",
HelpMessage = "Use this switch to get information about the supported Security Groups"
)]
[Parameter(
Mandatory,
ParameterSetName = "SiteNameSecurityGroup",
HelpMessage = "Use this switch to get information about the supported Security Groups"
)]
[Switch]$SecurityGroup,
[Parameter(
Mandatory,
ParameterSetName = "SiteIdentifierSubnet",
HelpMessage = "Use this switch to get information about the supported Subnets"
)]
[Parameter(
Mandatory,
ParameterSetName = "SiteNameSubnet",
HelpMessage = "Use this switch to get information about the supported Subnets"
)]
[Switch]$Subnet,
[Parameter(
Mandatory,
ParameterSetName = "SiteIdentifierNetwork",
HelpMessage = "Use this switch to get information about the supported Networks (VNets)."
)]
[Parameter(
Mandatory,
ParameterSetName = "SiteNameNetwork",
HelpMessage = "Use this switch to get information about the supported Networks (VNets)."
)]
[Switch]$Network,
[Parameter(
Mandatory,
ParameterSetName = "SiteIdentifierVmInstanceType",
HelpMessage = "Use this switch to get information about the supported Vm Instance Types."
)]
[Parameter(
Mandatory,
ParameterSetName = "SiteNameVmInstanceType",
HelpMessage = "Use this switch to get information about the supported Vm Instance Types."
)]
[Switch]$VmInstanceType
)
begin {
}
process {
if ($PSCmdlet.ParameterSetName -match "SiteName") {
$SiteInfo = Get-ZertoPeerSite | Where-Object { $_.PeerSiteName -match $SiteName }
if ($null -eq $SiteInfo) {
Write-Error "Unable to find a peer site with the name $SiteName. Please check your parameters and try again." -ErrorAction Stop
}
$SiteIdentifier = $SiteInfo | Select-Object -ExpandProperty SiteIdentifier
} else {
$SiteInfo = Get-ZertoPeerSite -siteIdentifier $SiteIdentifier
if ($null -eq $SiteInfo) {
Write-Error "Unable to find a peer site with identifier of $SiteIdentifier. Please check your parameters and try again." -ErrorAction Stop
}
}
if ($SiteInfo.SiteType -notmatch "Azure") {
Write-Error "Specified site is not an Azure site. Please specify an Azure site and try again." -ErrorAction Stop
}
$baseUri = "virtualizationsites/{0}/publicCloud" -f $SiteIdentifier
switch -wildcard ($PSCmdlet.ParameterSetName) {
"*VmInstanceType" {
$uri = "{0}/VmInstanceType" -f $baseUri
}
"*Subnet" {
$uri = "{0}/subnets" -f $baseUri
}
"*Network" {
$uri = "{0}/virtualNetworks" -f $baseUri
}
"*SecurityGroup" {
$uri = "{0}/securityGroups" -f $baseUri
}
}
Invoke-ZertoRestRequest -uri $uri
}
end {
}
}
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoDatastore {
[cmdletbinding( DefaultParameterSetName = "main" )]
param(
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoEvent {
[cmdletbinding( defaultParameterSetName = "main" )]
param(
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoLicense {
[cmdletbinding()]
param()
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoLocalSite {
[cmdletbinding()]
param(
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoPeerSite {
[cmdletbinding( defaultParameterSetName = "main" )]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoProtectedVm {
[cmdletbinding( DefaultParameterSetName = "main" )]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoRecoveryReport {
[cmdletbinding( DefaultParameterSetName = "main" )]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoResourcesReport {
[cmdletbinding( DefaultParameterSetName = "main" )]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoServiceProfile {
[cmdletbinding( DefaultParameterSetName = "main" )]
param (
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoTask {
[cmdletbinding( DefaultParameterSetName = "main" )]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoUnprotectedVm {
[cmdletbinding()]
param()
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoVirtualizationSite {
[cmdletbinding( DefaultParameterSetName = "main" )]
param(
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoVolume {
[cmdletbinding( DefaultParameterSetName = "main" )]
param(
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoVpg {
[cmdletbinding( DefaultParameterSetName = "main" )]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoVpgSetting {
[cmdletbinding(
DefaultParameterSetName = "main",
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoVra {
[cmdletbinding(
DefaultParameterSetName = "main"
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoZorg {
[cmdletbinding( DefaultParameterSetName = "default" )]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Get-ZertoZsspSession {
[cmdletbinding( DefaultParameterSetName = "default" )]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Import-ZertoVmNicSetting {
[CmdletBinding(SupportsShouldProcess)]
param(
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Import-ZertoVpg {
[cmdletbinding()]
param(
+1 -8
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Install-ZertoVra {
[cmdletbinding( SupportsShouldProcess )]
param(
@@ -26,11 +25,6 @@ function Install-ZertoVra {
)]
[ValidateRange(1, 16)]
[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(
HelpMessage = "Bandwidth group to assign to the VRA. If unspecified will assign to the 'default_group'"
)]
@@ -142,7 +136,6 @@ function Install-ZertoVra {
}
$vraBasic['HostIdentifier'] = $hostIdentifier.toString()
$vraBasic['MemoryInGB'] = $memoryInGB
$vraBasic['NumOfCpus'] = $NumOfCpus
$vraBasic['NetworkIdentifier'] = $networkIdentifier.toString()
$vraBasic['UsePublicKeyInsteadOfCredentials'] = $true
$vraBasicNetwork = [ordered]@{ }
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Invoke-ZARestRequest {
[cmdletbinding()]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Invoke-ZertoEvacuateVra {
[CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = "VraIdentifier")]
param (
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Invoke-ZertoFailover {
[cmdletbinding( SupportsShouldProcess = $true )]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Invoke-ZertoFailoverCommit {
[cmdletbinding( SupportsShouldProcess = $true )]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Invoke-ZertoFailoverRollback {
[cmdletbinding()]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Invoke-ZertoForceSync {
[cmdletbinding()]
param(
+1 -2
View File
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Invoke-ZertoMove {
[CmdletBinding( DefaultParameterSetName = "id", SupportsShouldProcess = $true )]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Invoke-ZertoMoveCommit {
[cmdletbinding(SupportsShouldProcess = $true, DefaultParameterSetName = "Main")]
param(
@@ -1,5 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml
#>
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Invoke-ZertoMoveRollback {
[cmdletbinding(SupportsShouldProcess = $true)]
param(
@@ -1,3 +1,4 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Invoke-ZertoRestRequest {
[cmdletbinding()]
param(
@@ -40,15 +41,12 @@ function Invoke-ZertoRestRequest {
}
# If the Headers exist and the Last action was more than 30 minutes ago, Session is Expired
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
if ( (Test-Path variable:script:zvmHeaders) -and $([datetime]$script:zvmLastAction).addMinutes(30) -lt $(Get-Date) -and $Script:Reconnect -eq $False ) {
Throw "Authorization Token has Expired. Please re-authorize to the Zerto Virtual Manager"
} elseif (( (Test-Path variable:script:zvmHeaders) -and (Test-Path variable:script:AuthExpiresAt) -and $([datetime]$script:AuthExpiresAt) -lt $(Get-Date) -and $Script:Reconnect -eq $True )) {
} elseif (( (Test-Path variable:script:zvmHeaders) -and $([datetime]$script:zvmLastAction).addMinutes(30) -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 {
@@ -56,48 +54,7 @@ function Invoke-ZertoRestRequest {
$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'
}
$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
} else {
$apiRequestResults = Invoke-RestMethod -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -Body $body -ContentType $contentType -Credential $credential -SkipCertificateCheck -ResponseHeadersVariable responseHeaders -TimeoutSec 100
}
$apiRequestResults = Invoke-RestMethod -Uri $submittedURI -Headers $script:zvmHeaders -Method $method -Body $body -ContentType $contentType -Credential $credential -SkipCertificateCheck -ResponseHeadersVariable responseHeaders -TimeoutSec 100
} else {
# If running PowerShell 5.1 --> Do the Following
# Check to see if All Certs are Trusted. If not, Create the Policy to Trust All Certificates
@@ -122,27 +79,10 @@ public class TrustAllCertsPolicy : ICertificatePolicy {
}
# If we are authenticating to the ZVM, Use this block to use Invoke-WebRequest and format the Headers 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'
}
$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
$ExpiresIn = $apiRequestResults.expires_in
$script:AuthExpiresAt = (Get-Date).AddSeconds($ExpiresIn)
$script:refreshToken = $apiRequestResults.refresh_token
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['Authorization'] = "Bearer " + @($apiRequestResults.access_token)
$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

Some files were not shown because too many files have changed in this diff Show More