@@ -1,2 +1,7 @@
|
||||
|
||||
*.zip
|
||||
temp/*
|
||||
Tests/Public/TestResults.xml
|
||||
Tests/TestResults.xml
|
||||
publish/*
|
||||
CodeCoverage.xml
|
||||
|
||||
@@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
ZertoApiWrapper
|
||||
Copyright (C) 2019 Wes Carroll
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
ZertoApiWrapper Copyright (C) 2019 Wes Carroll
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
PowerShell Core wrapper for Zerto Virtual Manager API
|
||||
|
||||
## Current Build Status
|
||||
|
||||
[](https://app.codacy.com/app/wcarroll/ZertoApiWrapper?utm_source=github.com&utm_medium=referral&utm_content=wcarroll/ZertoApiWrapper&utm_campaign=Badge_Grade_Settings)
|
||||
[](https://dev.azure.com/wescarroll/ZertoApiWrapper/_build/latest?definitionId=1&branchName=master)
|
||||
|
||||
## Legal Disclaimer
|
||||
|
||||
This script is an example script and is not supported under any Zerto support program or service. The author and Zerto further disclaim all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose.
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
|
||||
* New Feature 1
|
||||
* New Feature 2
|
||||
* New SubFeature 1
|
||||
* What is happening???
|
||||
@@ -1,23 +1,30 @@
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$modulePath = $filePath -replace "Private", ""
|
||||
$file = Get-ChildItem "$filePath\$fileName"
|
||||
|
||||
. "$filePath\$fileName"
|
||||
$oneItemTest = [ordered]@{"OneItem" = "Test"}
|
||||
$twoItemTest = [ordered]@{"OneItem" = "Test"; "SecondItem" = "Yours"}
|
||||
$boolItemTest = [ordered]@{"OneItem" = "Test"; "BoolItem" = $true}
|
||||
. $file.FullName
|
||||
$singleBoolItemTest = @{"BoolItem" = $True}
|
||||
$oneItemTest = @{"OneItem" = "Test"}
|
||||
$twoItemTest = @{"OneItem" = "Test"; "SecondItem" = "Yours"}
|
||||
$boolItemTest = @{"OneItem" = "Test"; "BoolItem" = $true}
|
||||
|
||||
Describe "Get-ZertoApiFilter" {
|
||||
Describe $file.BaseName -Tag Unit {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
$file.Fullname | should exist
|
||||
}
|
||||
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file.Fullname -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
|
||||
it "converts bool to text" {
|
||||
Get-ZertoApiFilter -filtertable $singleBoolItemTest | should -Be "?BoolItem=True"
|
||||
}
|
||||
it "one item test" {
|
||||
Get-ZertoApiFilter -filtertable $oneItemTest | should be "?OneItem=Test"
|
||||
}
|
||||
it "two item test" {
|
||||
Get-ZertoApiFilter -filtertable $twoItemTest | should be "?OneItem=Test&SecondItem=Yours"
|
||||
}
|
||||
it "bool item test" {
|
||||
Get-ZertoApiFilter -filtertable $boolItemTest | should be "?OneItem=Test&BoolItem=True"
|
||||
}
|
||||
#TODO:: Figure out multi-item tests
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$file = Get-ChildItem "$filePath\$fileName"
|
||||
. $file.FullName
|
||||
|
||||
Describe $file.BaseName -Tag Unit {
|
||||
it "file should exist" {
|
||||
$file.FullName | should exist
|
||||
}
|
||||
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file.FullName -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,76 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
It "Is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
|
||||
it "Has a mandatory string parameter for the target host" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter TargetHost -Mandatory -Type String
|
||||
}
|
||||
|
||||
it "Will not take a non-ip address as a 'TargetHost'" {
|
||||
{Add-ZertoPeerSite -targetHost 'MyZVMHost' -targetPort '9081'} | should -Throw
|
||||
{Add-ZertoPeerSite -targetHost '192.168.1.266' -targetPort '9081'} | should -Throw
|
||||
{Add-ZertoPeerSite -targetHost '192.168.1' -targetPort '9081'} | should -Throw
|
||||
{Add-ZertoPeerSite -targetHost $null -targetPort '9081'} | should -Throw
|
||||
}
|
||||
|
||||
it "Has a non-mandatory string parameter for the target port with default value of 9081" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter TargetPort -Not -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter TargetPort -Type Int32
|
||||
Get-Command $file.BaseName | Should -HaveParameter TargetPort -DefaultValue 9081
|
||||
}
|
||||
|
||||
it "Will not take a non-int as a port" {
|
||||
{Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 'string'} | should -Throw
|
||||
{Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort $true} | should -Throw
|
||||
{Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort $null} | should -Throw
|
||||
}
|
||||
|
||||
It "Will fail if the specified port is outside of the range 1024 - 65535" {
|
||||
{Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 1023} | Should -Throw
|
||||
{Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 65536} | Should -Throw
|
||||
{Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 0} | Should -Throw
|
||||
{Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort -1} | Should -Throw
|
||||
}
|
||||
|
||||
it "Supports 'SupportsShouldProcess'" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter WhatIf
|
||||
Get-Command $file.BaseName | Should -HaveParameter Confirm
|
||||
$file | Should -FileContentMatch 'SupportsShouldProcess'
|
||||
$file | Should -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Function Unit Tests" {
|
||||
|
||||
Mock -ModuleName ZertoApiWrapper Invoke-ZertoRestRequest {
|
||||
return "9a49f42e-2bbd-4bf8-b571-77908a2e5e98.928a122b-1763-4664-ad37-cc00bb883f2f"
|
||||
}
|
||||
|
||||
it "Returns a string value" {
|
||||
$results = Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort '9081'
|
||||
$results | should -Not -BeNullOrEmpty
|
||||
$results | should -BeOfType "String"
|
||||
$results | Should -BeExactly "9a49f42e-2bbd-4bf8-b571-77908a2e5e98.928a122b-1763-4664-ad37-cc00bb883f2f"
|
||||
}
|
||||
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,66 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest {
|
||||
return "3b687246-ac63-40da-9a59-b99863769eb0.928a122b-1763-4664-ad37-cc00bb883f2f"
|
||||
}
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName get-zertovpg {
|
||||
return @{vpgIdentifier = "dddf2fa8-79e2-4e4f-a83b-f66676afea64"}
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
it "Has a parameter for the VpgName that is Mandatory" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter vpgName -Mandatory -Type String
|
||||
}
|
||||
|
||||
it "Has a parameter for the CheckpointName that is Mandatory" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter CheckpointName -Mandatory -Type String
|
||||
}
|
||||
|
||||
it "Throws and error when an empty or null checkpointName is specified" {
|
||||
{Checkpoint-ZertoVpg -vpgName "MyVpg" -checkpointName ""} | Should -Throw
|
||||
{Checkpoint-ZertoVpg -vpgName "MyVpg" -checkpointName $null} | Should -Throw
|
||||
}
|
||||
|
||||
it "Throws an error when an empty or null vpgName is specified" {
|
||||
{Checkpoint-ZertoVpg -vpgName "" -checkpointName "MyCheckPoint"} | Should -Throw
|
||||
{Checkpoint-ZertoVpg -vpgName $null -checkpointName "MyCheckPoint"} | Should -Throw
|
||||
}
|
||||
|
||||
it "Does not support 'SupportsShouldProcess'" {
|
||||
Get-Command $file.BaseName | Should -Not -HaveParameter WhatIf
|
||||
Get-Command $file.BaseName | Should -Not -HaveParameter Confirm
|
||||
$file | Should -Not -FileContentMatch 'SupportsShouldProcess'
|
||||
$file | Should -Not -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)'
|
||||
}
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Function Unit Tests" {
|
||||
|
||||
it "should return a not null or empty string" {
|
||||
$results = Checkpoint-ZertoVpg -vpgName "MyVpg" -checkpointName "My Checkpoint Name"
|
||||
$results | should -not -BeNullOrEmpty
|
||||
$results | should -BeOfType "String"
|
||||
$results | should -BeExactly "3b687246-ac63-40da-9a59-b99863769eb0.928a122b-1763-4664-ad37-cc00bb883f2f"
|
||||
}
|
||||
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpg
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,188 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "172.16.219.128"
|
||||
$Server = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "Connect-ZertoServer" {
|
||||
Describe $file.BaseName -Tag Unit {
|
||||
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
|
||||
it "server vairable has a mandatory String parameter" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter zertoserver -Mandatory -Type String
|
||||
}
|
||||
|
||||
it "server variable does not accecpt an empty or null input" {
|
||||
{Connect-ZertoServer -zertoServer $null -credential $credential} | Should -Throw
|
||||
{Connect-ZertoServer -zertoServer "" -credential $credential} | Should -Throw
|
||||
}
|
||||
|
||||
it "port variable has a non-mandatory String parameter" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter zertoPort -Not -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter zertoPort -Type String
|
||||
Get-Command $file.BaseName | Should -HaveParameter zertoPort -DefaultValue "9669"
|
||||
}
|
||||
|
||||
it "port variable does not accecpt an empty or null input" {
|
||||
{Connect-ZertoServer -zertoServer "192.168.1.100" -zertoPort "" -credential $credential} | Should -Throw
|
||||
{Connect-ZertoServer -zertoServer "192.168.1.100" -zertoPort $null -credential $credential} | Should -Throw
|
||||
}
|
||||
|
||||
it "port variable should fall between 1024 and 65535" {
|
||||
{Connect-ZertoServer -zertoServer $Server -zertoPort 1023 -credential $credential} | Should -Throw
|
||||
{Connect-ZertoServer -zertoServer $Server -zertoPort 65536 -credential $credential} | Should -Throw
|
||||
{Connect-ZertoServer -zertoServer $Server -zertoPort 0 -credential $credential} | Should -Throw
|
||||
{Connect-ZertoServer -zertoServer $Server -zertoPort -1 -credential $credential} | Should -Throw
|
||||
}
|
||||
|
||||
it "has a mandatory PSCredential parameter for the credential vairable" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter credential -Mandatory -Type PSCredential
|
||||
}
|
||||
|
||||
it "should require a PSCredentialObject for the credentials" {
|
||||
{Connect-ZertoServer -zertoServer -credential "MyUsername"} | Should -Throw
|
||||
{Connect-ZertoServer -zertoServer -credential 1234} | Should -Throw
|
||||
{Connect-ZertoServer -zertoServer -credential $(@{Username = "zerto\build"; Password = 'SecureString'})} | Should -Throw
|
||||
}
|
||||
}
|
||||
|
||||
InModuleScope ZertoApiWrapper {
|
||||
Context "$($file.BaseName)::InModuleScope Function Unit Tests" {
|
||||
|
||||
$server = '192.168.1.100'
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
|
||||
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest {
|
||||
$xZertoSession = @("7ecf544d-e7ed-4108-86f3-fb355c51cdfa")
|
||||
$Headers = @{'x-zerto-session' = $xZertoSession}
|
||||
$results = @{'Headers' = $Headers}
|
||||
return $results
|
||||
}
|
||||
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoLocalSite {
|
||||
$results = @{
|
||||
BandwidthThrottlingInMBs = -1
|
||||
ContactEmail = "vSphere-Site01@zerto.com"
|
||||
ContactName = "vSphere-Site01@zerto.com"
|
||||
ContactPhone = "066-6666666"
|
||||
IpAddress = "192.168.200.1"
|
||||
IsReplicationToSelfEnabled = $True
|
||||
Link = @{
|
||||
href = "https://192.168.24.1:7669/v1/localsite"
|
||||
identifier = "928a122b-1763-4664-ad37-cc00bb883f2f"
|
||||
rel = $null
|
||||
type = "LocalSiteApi"
|
||||
}
|
||||
Location = "vSphere-Site01"
|
||||
SiteName = "vSphere-Site01 at Zerto"
|
||||
SiteType = "VCenter"
|
||||
UtcOffsetInMinutes = -240
|
||||
Version = "7.0.0"
|
||||
SiteIdentifier = "928a122b-1763-4664-ad37-cc00bb883f2f"
|
||||
}
|
||||
return $results
|
||||
}
|
||||
|
||||
$now = $(Get-Date).ticks
|
||||
Connect-ZertoServer -zertoServer $server -credential $credential
|
||||
|
||||
it "Module Scope zvmServer variable tests" {
|
||||
$script:zvmServer | Should -Not -BeNullOrEmpty
|
||||
$script:zvmServer | Should -Be $server
|
||||
}
|
||||
|
||||
it "Module Scope zvmPort variable tests" {
|
||||
$script:zvmPort | Should -Not -BeNullOrEmpty
|
||||
$script:zvmPort | Should -Be '9669'
|
||||
}
|
||||
|
||||
it "Module Scope zvmLastAction variable tests" {
|
||||
$script:zvmLastAction | Should -Not -BeNullOrEmpty
|
||||
$script:zvmLastAction | Should -BeGreaterOrEqual $now
|
||||
}
|
||||
|
||||
it "Module Scope zvmHeaders variable tests" {
|
||||
$script:zvmHeaders | Should -Not -BeNullOrEmpty
|
||||
$script:zvmHeaders | Should -BeOfType Hashtable
|
||||
$script:zvmHeaders.keys.count | Should -BeExactly 2
|
||||
$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 zvmLocalInfo variable tests" {
|
||||
$script:zvmLocalInfo | Should -Not -BeNullOrEmpty
|
||||
$script:zvmLocalInfo | Should -BeOfType Hashtable
|
||||
$script:zvmLocalInfo['SiteIdentifier'] | Should -BeOfType String
|
||||
$script:zvmLocalInfo.ContainsKey('SiteIdentifier') | Should -BeTrue
|
||||
$script:zvmLocalInfo['SiteIdentifier'] | 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 2
|
||||
}
|
||||
|
||||
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 "7ecf544d-e7ed-4108-86f3-fb355c51cdfa"
|
||||
}
|
||||
|
||||
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 "should not require a port to be specified" {
|
||||
Connect-ZertoServer -zertoServer $Server -credential $credential
|
||||
}
|
||||
|
||||
it "returns null when -ReturnHeaders is not used" {
|
||||
Connect-ZertoServer -zertoServer $Server -credential $credential | Should -BeNullOrEmpty
|
||||
}
|
||||
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoLocalSite
|
||||
}
|
||||
}
|
||||
}
|
||||
<#
|
||||
Describe "Connect-ZertoServer" -Tag Integration {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "has a function called Connect-ZertoServer" {
|
||||
get-command Connect-ZertoServer | should be $true
|
||||
}
|
||||
$headers = Connect-ZertoServer -zertoServer $zertoServer -zertoPort $zertoPort -credential $credential -returnHeaders
|
||||
$headers = Connect-ZertoServer -zertoServer $Server -zertoPort $zertoPort -credential $credential -returnHeaders
|
||||
it "returns a Hashtable with 2 keys" {
|
||||
$headers.keys.count | should be 2
|
||||
}
|
||||
@@ -37,3 +200,4 @@ Describe "Connect-ZertoServer" {
|
||||
}
|
||||
Disconnect-ZertoServer
|
||||
}
|
||||
#>
|
||||
|
||||
@@ -1,23 +1,37 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest {
|
||||
$null
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName Remove-Variable {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
it "Does not take any parameters" {
|
||||
(get-command disconnect-zertoserver).parameters.count | Should -BeExactly 11
|
||||
}
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Function Unit Tests" {
|
||||
it "Does not return anything" {
|
||||
Disconnect-ZertoServer | Should -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,187 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path) -Replace "Tests", "ZertoApiWrapper"
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
Mock -ModuleName ZertoApiWrapper Invoke-ZertoRestRequest {
|
||||
return "8dcfdc8e-e5d2-4ba4-9885-f9eb57d92b14.928a122b-1763-4664-ad37-cc00bb883f2f"
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
|
||||
Mock -ModuleName ZertoApiWrapper Get-ZertoVra {
|
||||
$vraInformation = @{
|
||||
DatastoreClusterIdentifier = $null
|
||||
DatastoreClusterName = $null
|
||||
DatastoreIdentifier = "840f99fb-4689-2f8b-ea10-2a47a5bb00cc.Prod_Datastore"
|
||||
DatastoreName = "Prod_Datastore"
|
||||
HostIdentifier = "840f99fb-4689-2f8b-ea10-2a47a5bb00cc.znest82esxus-1"
|
||||
HostVersion = 6.5
|
||||
IpAddress = 192.168.1.100
|
||||
Link = @{
|
||||
href = "https://192.168.1.200:7669/v1/vras/2609816293328110468"
|
||||
identifier = "269816293328110468"
|
||||
rel = $null
|
||||
type = "VraApi"
|
||||
}
|
||||
MemoryInGB = 3
|
||||
NetworkIdentifier = "840f99fb-4689-2f8b-ea10-2a47a5bb00cc.network-1"
|
||||
NetworkName = "Test Network"
|
||||
Progress = 0
|
||||
ProtectedCounters = @{
|
||||
Vms = 0
|
||||
Volumes = 0
|
||||
Vpgs = 0
|
||||
}
|
||||
RecoveryCounters = @{
|
||||
Vms = 0
|
||||
Volumes = 0
|
||||
Vpgs = 0
|
||||
}
|
||||
SelfProtectedVpgs = 0
|
||||
Status = 0
|
||||
VraAlerts = @{
|
||||
VraAlertStatus = 0
|
||||
}
|
||||
VraGroup = "default_group"
|
||||
VraIdentifier = 269816293328110468
|
||||
VraIdentifierStr = "269816293328110468"
|
||||
VraName = "VRA-znest82esxus-1"
|
||||
VraNetworkDataApi = @{
|
||||
DefaultGateway = "192.168.1.1"
|
||||
SubnetMask = "255.255.255.0"
|
||||
VraIpAddress = "192.168.1.100"
|
||||
VraIpConfigurationTypeApi = "Dhcp"
|
||||
}
|
||||
VraVersion = 7.0
|
||||
}
|
||||
return $vraInformation
|
||||
}
|
||||
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
|
||||
Context "$($File.BaseName)::Parameter Unit Tests" {
|
||||
|
||||
It "has a mandatory String variable for the vraIdentifier" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter vraIdentifier -Mandatory -Type String
|
||||
{Edit-ZertoVra}
|
||||
}
|
||||
|
||||
It "has a non-mandatory String variable for the Bandwidth Group" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter groupName -Not -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter groupName -Type String
|
||||
}
|
||||
|
||||
it "has a non-mandatory String variable for the staticIp Address" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter vraIpAddress -Not -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter vraIpAddress -Type String
|
||||
}
|
||||
|
||||
it "has a non-mandatory String variable for the default gateway" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter defaultGateway -Not -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter defaultGateway -Type String
|
||||
}
|
||||
|
||||
it "has a non-mandatory String variable for the subnetmask" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter subnetMask -Not -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter subnetMask -Type String
|
||||
}
|
||||
|
||||
it "supports WhatIf" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter WhatIf -Not -Mandatory
|
||||
}
|
||||
|
||||
$cases = `
|
||||
@{vraIpAddress = "192.168.1.256"}, `
|
||||
@{vraIpAddress = "192.168.1"}, `
|
||||
@{vraIpAddress = "String"}, `
|
||||
@{vraIpAddress = 192.168.1}, `
|
||||
@{vraIpAddress = 192.168.1.246}, `
|
||||
@{vraIpAddress = 32}, `
|
||||
@{vraIpAddress = ""}, `
|
||||
@{vraIpAddress = $null}
|
||||
It "IpAddress field require valid IP addresses as a String" -TestCases $cases {
|
||||
param ( $vraIpAddress )
|
||||
{Edit-ZertoVra -vraIdentifier "MyVraIdentifier" -vraIpaddress $vraIpAddress} | Should -Throw
|
||||
}
|
||||
|
||||
$cases = `
|
||||
@{subnetMask = "192.168.1.256"}, `
|
||||
@{subnetMask = "192.168.1"}, `
|
||||
@{subnetMask = "String"}, `
|
||||
@{subnetMask = 192.168.1}, `
|
||||
@{subnetMask = 192.168.1.246}, `
|
||||
@{subnetMask = 32}, `
|
||||
@{subnetMask = ""}, `
|
||||
@{subnetMask = $null}
|
||||
It "subnetMask field require valid IP addresses as a String" -TestCases $cases {
|
||||
param ( $vraIpAddress )
|
||||
{Edit-ZertoVra -vraIdentifier "MyVraIdentifier" -subnetMask $subnetMask} | Should -Throw
|
||||
}
|
||||
|
||||
$cases = `
|
||||
@{defaultGateway = "192.168.1.256"}, `
|
||||
@{defaultGateway = "192.168.1"}, `
|
||||
@{defaultGateway = "String"}, `
|
||||
@{defaultGateway = 192.168.1}, `
|
||||
@{defaultGateway = 192.168.1.246}, `
|
||||
@{defaultGateway = 32}, `
|
||||
@{defaultGateway = ""}, `
|
||||
@{defaultGateway = $null}
|
||||
It "defaultGateway field require valid IP addresses as a String" -TestCases $cases {
|
||||
param ( $vraIpAddress )
|
||||
{Edit-ZertoVra -vraIdentifier "MyVraIdentifier" -defaultGateway $defaultGateway} | Should -Throw
|
||||
}
|
||||
|
||||
$cases = `
|
||||
@{vraIdentifier = ""; paramName = "vraIdentifier"; paramValue = ""}, `
|
||||
@{vraIdentifier = $null; paramName = "vraIdentifier"; paramValue = ""}, `
|
||||
@{vraIdentifier = "MyVraIdentifier"; paramName = "groupName"; paramValue = ""}, `
|
||||
@{vraIdentifier = "MyVraIdentifier"; paramName = "groupName"; paramValue = $null}, `
|
||||
@{vraIdentifier = "MyVraIdentifier"; paramName = "vraIpAddress"; paramValue = ""}, `
|
||||
@{vraIdentifier = "MyVraIdentifier"; paramName = "vraIpAddress"; paramValue = $null}, `
|
||||
@{vraIdentifier = "MyVraIdentifier"; paramName = "subnetMask"; paramValue = ""}, `
|
||||
@{vraIdentifier = "MyVraIdentifier"; paramName = "subnetMask"; paramValue = $null}, `
|
||||
@{vraIdentifier = "MyVraIdentifier"; paramName = "defaultGateway"; paramValue = ""}, `
|
||||
@{vraIdentifier = "MyVraIdentifier"; paramName = "defaultGateway"; paramValue = $null}
|
||||
|
||||
It "<paramName> does not take empty or null" -TestCases $cases {
|
||||
param($vraIdentifier, $paramValue, $paramName )
|
||||
if ([String]::IsNullOrEmpty($vraIdentifier)) {
|
||||
{Edit-ZertoVra -vraIdentifier $vraIdentifier} | Should -Throw
|
||||
} else {
|
||||
{Edit-ZertoVra -vraIdentifier $vraIdentifier -$paramName $paramValue} | should -Throw
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$($File.BaseName)::Function Unit Tests" {
|
||||
|
||||
It "Returns a string" {
|
||||
$results = Edit-ZertoVra -vraIdentifier "MyVraIdentifier" -groupName "MyGroup"
|
||||
$results | should not benullorempty
|
||||
$results | should -BeOfType "String"
|
||||
$results | Should -BeExactly "8dcfdc8e-e5d2-4ba4-9885-f9eb57d92b14.928a122b-1763-4664-ad37-cc00bb883f2f"
|
||||
}
|
||||
|
||||
it "Supports 'SupportsShouldProcess'" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter WhatIf
|
||||
Get-Command $file.BaseName | Should -HaveParameter Confirm
|
||||
$file | Should -FileContentMatch 'SupportsShouldProcess'
|
||||
$file | Should -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)'
|
||||
}
|
||||
|
||||
}
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoVra
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
#Requires -Modules Pester
|
||||
#Region - Test Setup
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
#EndRegion
|
||||
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
it "has a mantatory string parameter for the output path" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter outputPath -Type String -Mandatory
|
||||
}
|
||||
|
||||
it "has a non-mandatory string array parameter for vpgName(s) to export" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter vpgName -Type String[] -Mandatory
|
||||
}
|
||||
|
||||
it "has a non-mandatory switch parameter to export all vpgs" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter allVpgs -Type Switch -Mandatory
|
||||
}
|
||||
|
||||
it "No defined vpgName or AllVpg switch should throw an error" {
|
||||
{Export-ZertoVpg -outputPath "."} | Should -Throw
|
||||
}
|
||||
|
||||
it "Output path does not take null or empty string" {
|
||||
{Export-ZertoVpg -outputPath "" -allVpgs} | Should -Throw
|
||||
{Export-ZertoVpg -outputPath $null -allVpgs} | Should -Throw
|
||||
}
|
||||
|
||||
it "Vpg Name parameter does not take null or empty string" {
|
||||
{Export-ZertoVpg -outputPath "." -vpgName = ""} | Should -Throw
|
||||
{Export-ZertoVpg -outputPath "." -vpgName = $null} | Should -Throw
|
||||
}
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Function Unit Tests" {
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpg {
|
||||
$returnObj = @{
|
||||
VpgName = "HRIS"
|
||||
VpgIdentifier = "dddf2fa8-79e2-4e4f-a83b-f66676afea64"
|
||||
}
|
||||
return $returnObj
|
||||
}
|
||||
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName New-ZertoVpgSettingsIdentifier {
|
||||
return "1024d377-afb8-4880-82f0-96eeff413ffd"
|
||||
}
|
||||
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpgSetting {
|
||||
$returnObj = @{
|
||||
Backup = $null
|
||||
Basic = @{
|
||||
JournalHistoryInHours = 4
|
||||
Name = "HRIS"
|
||||
Priority = "Medium"
|
||||
ProtectedSiteIdentifier = "928a122b-1763-4664-ad37-cc00bb883f2f"
|
||||
RecoverySiteIdentifier = "07f62976-6228-40ff-9542-4d7837114f37"
|
||||
RpoInSeconds = 300
|
||||
ServiceProfileIdentifier = $null
|
||||
TestIntervalInMinutes = 43200
|
||||
UseWanCompression = $true
|
||||
ZorgIdentifier = $null
|
||||
}
|
||||
BootGroups = @{
|
||||
BootGroups = @(
|
||||
@{
|
||||
BootDelayInSeconds = 0
|
||||
BootGroupIdentifier = "00000000-0000-0000-0000-000000000000"
|
||||
Name = "Default"
|
||||
}
|
||||
)
|
||||
}
|
||||
Journal = @{
|
||||
DatastoreIdentifier = $null
|
||||
Limitation = @{
|
||||
HardLimitInMB = 0
|
||||
HardLimitInPercent = 0
|
||||
WarningThresholdInMb = 0
|
||||
WarningThresholdInPercent = 0
|
||||
}
|
||||
}
|
||||
Networks = @{
|
||||
Failover = @{
|
||||
Hypervisor = @{
|
||||
DefaultNetworkIdentifier = "48ffb633-2548-879c-5eb1-f53081fb0c21.network-1"
|
||||
}
|
||||
VCD = $null
|
||||
}
|
||||
FailoverTest = @{
|
||||
Hypervisor = @{
|
||||
DefaultNetworkIdentifier = "48ffb633-2548-879c-5eb1-f53081fb0c21.network-1"
|
||||
}
|
||||
VCD = $null
|
||||
}
|
||||
}
|
||||
Protected = @{
|
||||
VCD = $null
|
||||
}
|
||||
Recovery = @{
|
||||
DefaultDatastoreClusterIdentifier = $null
|
||||
DefaultDatastoreIdentifier = $null
|
||||
DefaultFolderIdentifier = "48ffb633-2548-879c-5eb1-f53081fb0c21.vm"
|
||||
DefaultHostClusterIdentifier = $null
|
||||
DefaultHostIdentifier = $null
|
||||
ResourcePoolIdentifier = $null
|
||||
VCD = $null
|
||||
}
|
||||
Scripting = @{
|
||||
PostBackup = $null
|
||||
PostRecovey = @{
|
||||
Command = $null
|
||||
Parameters = $null
|
||||
TimeOutInSeconds = 300
|
||||
}
|
||||
PreRecovery = @{
|
||||
Command = $null
|
||||
Parameters = $null
|
||||
TimeOutInSeconds = 300
|
||||
}
|
||||
}
|
||||
Vms = @(
|
||||
@{
|
||||
BootGroupIdentifier = "00000000-0000-0000-0000-000000000000"
|
||||
Journal = @{
|
||||
DatastoreIdentifier = "48ffb633-2548-879c-5eb1-f53081fb0c21.DS_vSphere-Site02"
|
||||
Limitation = @{
|
||||
HardLimitInMB = 0
|
||||
HardLimitInPercent = 0
|
||||
WarningThresholdInMb = 0
|
||||
WarningThresholdInPercent = 0
|
||||
}
|
||||
}
|
||||
Nics = @(
|
||||
@{
|
||||
Failover = @{
|
||||
Hypervisor = @{
|
||||
DnsSuffix = $null
|
||||
IpConfig = $null
|
||||
NetworkIdentifier = "48ffb633-2548-879c-5eb1-f53081fb0c21.network-1"
|
||||
ShouldReplaceMacAddress = $false
|
||||
}
|
||||
VCD = $null
|
||||
}
|
||||
FailoverTest = @{
|
||||
Hypervisor = @{
|
||||
DnsSuffix = $null
|
||||
IpConfig = $null
|
||||
NetworkIdentifier = "48ffb633-2548-879c-5eb1-f53081fb0c21.network-1"
|
||||
ShouldReplaceMacAddress = $false
|
||||
}
|
||||
VCD = $null
|
||||
}
|
||||
NicIdentifier = "HRIS01-nic0"
|
||||
}
|
||||
)
|
||||
Recovery = @{
|
||||
DatastoreClusterIdentifier = $null
|
||||
DatastoreIdentifier = "48ffb633-2548-879c-5eb1-f53081fb0c21.DS_vSphere-Site02"
|
||||
FolderIdentifier = "48ffb633-2548-879c-5eb1-f53081fb0c21.vm"
|
||||
HostClusterIdentifier = $null
|
||||
HostIdentifier = "48ffb633-2548-879c-5eb1-f53081fb0c21.znest83esxus-0"
|
||||
ResourcePoolIdentifier = $null
|
||||
VCD = $null
|
||||
}
|
||||
VmIdentifier = "840f99fb-4689-2f8b-ea10-2a47a5bb00cc.vm-28"
|
||||
Volumes = @(
|
||||
@{
|
||||
Datastore = @{
|
||||
DatastoreClusterIdentifier = $null
|
||||
DatastoreIdentifier = "48ffb633-2548-879c-5eb1-f53081fb0c21.DS_vSphere-Site02"
|
||||
IsThin = $true
|
||||
}
|
||||
IsSwap = $false
|
||||
Preseed = $null
|
||||
RDM = $null
|
||||
VCD = $null
|
||||
VolumeIdentifier = "scsi:0:0"
|
||||
},
|
||||
@{
|
||||
Datastore = @{
|
||||
DatastoreClusterIdentifier = $null
|
||||
DatastoreIdentifier = "48ffb633-2548-879c-5eb1-f53081fb0c21.DS_vSphere-Site02"
|
||||
IsThin = $true
|
||||
}
|
||||
IsSwap = $false
|
||||
Preseed = $null
|
||||
RDM = $null
|
||||
VCD = $null
|
||||
VolumeIdentifier = "scsi:0:1"
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
VpgIdentifier = "dddf2fa8-79e2-4e4f-a83b-f66676afea64"
|
||||
VpgSettingsIdentifier = "1024d377-afb8-4880-82f0-96eeff413ffd"
|
||||
}
|
||||
return $returnObj
|
||||
}
|
||||
|
||||
$outputPath = "TestDrive:"
|
||||
|
||||
it "Output path should exist" {
|
||||
$outputPath | Should -Exist
|
||||
}
|
||||
|
||||
it "Exported JSON file should exist after function called" {
|
||||
$vpgName = "HRIS"
|
||||
Export-ZertoVpg -outputPath $outputPath -vpgName $vpgName
|
||||
$outputFile = "{0}\{1}.json" -f $outputPath, $vpgName
|
||||
$outputFile | Should -Exist
|
||||
$outputFile | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
it "Only one file should be present in the TestDrive" {
|
||||
(Get-ChildItem $outputPath).Count | Should -BeExactly 1
|
||||
}
|
||||
|
||||
it "Should be valid JSON" {
|
||||
$vpgName = "HRIS"
|
||||
Export-ZertoVpg -outputPath $outputPath -vpgName $vpgName
|
||||
$outputFile = "{0}\{1}.json" -f $outputPath, $vpgName
|
||||
Get-Content -Path $outputFile -Raw | ConvertFrom-Json
|
||||
}
|
||||
|
||||
It "Should be able to export more than one VPG" {
|
||||
$vpgName = @("HRIS", "HRIS2")
|
||||
Export-ZertoVpg -outputPath $outputPath -vpgName $vpgName
|
||||
(Get-ChildItem $outputPath).Count | Should -BeExactly 2
|
||||
}
|
||||
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpg
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName New-ZertoVpgSettingsIdentifier
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpgSetting
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,29 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
|
||||
it "Has a mandatory string parameter for the Alert identifier" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter alertId -Mandatory -Type String[]
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
|
||||
It "Has a mandatory string array parameter for the settings file to import" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter settingsFile
|
||||
Get-Command $file.BaseName | Should -HaveParameter settingsFile -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter settingsFile -Type String[]
|
||||
}
|
||||
|
||||
It "Will not accecpt a Null or Empty string for the settings file" {
|
||||
{Import-ZertoVpg -settingsFile $null} | Should -Throw
|
||||
{Import-ZertoVpg -settingsFile ""} | Should -Throw
|
||||
{Import-ZertoVpg -settingsFile @()} | Should -Throw
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Function Unit Tests" {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,108 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
|
||||
It "Has a mandatory string host name parameter" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter hostName
|
||||
Get-Command $file.BaseName | Should -HaveParameter hostName -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter hostName -Type String
|
||||
}
|
||||
|
||||
It "Will not accecpt a Null or Empty string for the host name" {
|
||||
{Install-ZertoVra -hostName $null -datastoreName "DS01" -networkName "MyNetwork" -Dhcp } | Should -Throw "The argument is null or empty"
|
||||
{Install-ZertoVra -hostName "" -datastoreName "DS01" -networkName "MyNetwork" -Dhcp } | Should -Throw "The argument is null or empty"
|
||||
}
|
||||
|
||||
It "Has a mandatory string datastore parameter" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter datastoreName
|
||||
Get-Command $file.BaseName | Should -HaveParameter datastoreName -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter datastoreName -Type String
|
||||
}
|
||||
|
||||
It "Will not accecpt a Null or Empty string for the datastore" {
|
||||
{Install-ZertoVra -hostName "MyfirstHost" -datastoreName $null -networkName "MyNetwork" -Dhcp } | Should -Throw "The argument is null or empty"
|
||||
{Install-ZertoVra -hostName "MyfirstHost" -datastoreName "" -networkName "MyNetwork" -Dhcp } | Should -Throw "The argument is null or empty"
|
||||
}
|
||||
|
||||
It "Has a mandatory string network parameter" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter networkName
|
||||
Get-Command $file.BaseName | Should -HaveParameter networkName -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter networkName -Type String
|
||||
}
|
||||
|
||||
It "Will not accecpt a Null or Empty string for the datastore" {
|
||||
{Install-ZertoVra -hostName "MyfirstHost" -datastoreName "DS01" -networkName $null -Dhcp } | Should -Throw "The argument is null or empty"
|
||||
{Install-ZertoVra -hostName "MyfirstHost" -datastoreName "DS01" -networkName "" -Dhcp } | Should -Throw "The argument is null or empty"
|
||||
}
|
||||
|
||||
it "Has a switch parameter for setting DHCP" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter Dhcp
|
||||
Get-Command $file.BaseName | Should -HaveParameter Dhcp -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter Dhcp -Type 'Switch'
|
||||
|
||||
}
|
||||
|
||||
it "Has a mandatory string parameter for the static IP address" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter vraIpAddress
|
||||
Get-Command $file.BaseName | Should -HaveParameter vraIpAddress -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter vraIpAddress -Type String
|
||||
}
|
||||
|
||||
it "Has a mandatory string parameter for the subnet mask" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter subnetMask
|
||||
Get-Command $file.BaseName | Should -HaveParameter subnetMask -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter subnetMask -Type String
|
||||
}
|
||||
|
||||
it "Has a mandatory string parameter for the default gateway" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter defaultGateway
|
||||
Get-Command $file.BaseName | Should -HaveParameter defaultGateway -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter defaultGateway -Type String
|
||||
}
|
||||
|
||||
$cases = `
|
||||
@{invalidIpAddress = "192.168.1.256"}, `
|
||||
@{invalidIpAddress = "192.168.1"}, `
|
||||
@{invalidIpAddress = "String"}, `
|
||||
@{invalidIpAddress = 192.168.1.246}, `
|
||||
@{invalidIpAddress = 32}, `
|
||||
@{invalidIpAddress = ""}, `
|
||||
@{invalidIpAddress = $null}
|
||||
It "IpAddress field require valid IP addresses as a String: <invalidIpAddress>" -TestCases $cases {
|
||||
param ( $invalidIpAddress )
|
||||
{Install-ZertoVra -hostName "MyFirstHost" -datastoreName "DS01" -networkName "MyNetwork" -vraIpAddress $invalidIpAddress -subnetMask "255.255.255.0" -defaultGateway "192.168.1.254"} | Should -Throw
|
||||
}
|
||||
|
||||
It "Default Gateway field require valid IP addresses as a String: <invalidIpAddress>" -TestCases $cases {
|
||||
param ( $invalidIpAddress )
|
||||
{Install-ZertoVra -hostName "MyFirstHost" -datastoreName "DS01" -networkName "MyNetwork" -vraIpAddress '192.168.1.100' -subnetMask "255.255.255.0" -defaultGateway $invalidIpAddress} | Should -Throw
|
||||
}
|
||||
|
||||
It "Subnet Mask field require valid IP addresses as a String: <invalidIpAddress>" -TestCases $cases {
|
||||
param ( $invalidIpAddress )
|
||||
{Install-ZertoVra -hostName "MyFirstHost" -datastoreName "DS01" -networkName "MyNetwork" -vraIpAddress '192.168.1.100' -subnetMask $invalidIpAddress -defaultGateway "192.168.1.254"} | Should -Throw
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Function Unit Tests" {
|
||||
#TODO
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,77 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
it "has a mandatory string parameter for the vpgName" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter vpgName
|
||||
Get-Command $file.BaseName | Should -HaveParameter vpgName -Type string
|
||||
Get-Command $file.BaseName | Should -HaveParameter vpgName -Mandatory
|
||||
}
|
||||
|
||||
it "has a non-mandatory string parameter for the checkpoint" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter checkpointIdentifier
|
||||
Get-Command $file.BaseName | Should -HaveParameter checkpointIdentifier -Type string
|
||||
Get-Command $file.BaseName | Should -HaveParameter checkpointIdentifier -Not -Mandatory
|
||||
}
|
||||
|
||||
it "has a non-mandatory string parameter for the commit policy" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter commitPolicy
|
||||
Get-Command $file.BaseName | Should -HaveParameter commitPolicy -Type string
|
||||
Get-Command $file.BaseName | Should -HaveParameter commitPolicy -Not -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter commitPolicy -DefaultValue "Rollback"
|
||||
}
|
||||
|
||||
it "has a non-mandatory int parameter for the shutdown policy" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy
|
||||
Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy -Type int
|
||||
Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy -Not -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy -DefaultValue 0
|
||||
}
|
||||
|
||||
it "has a non-mandatory int parameter for the time to wait before force shutdown" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec
|
||||
Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec -Type int
|
||||
Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec -Not -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec -DefaultValue 3600
|
||||
}
|
||||
|
||||
it "has a non-mandatory bool parameter for the reverse protection policy" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter reverseProtection
|
||||
Get-Command $file.BaseName | Should -HaveParameter reverseProtection -Type bool
|
||||
Get-Command $file.BaseName | Should -HaveParameter reverseProtection -Not -Mandatory
|
||||
}
|
||||
|
||||
it "has a non-mandatory array string parameter for the named VMs to be failed over" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter vmName
|
||||
Get-Command $file.BaseName | Should -HaveParameter vmName -Type string[]
|
||||
Get-Command $file.BaseName | Should -HaveParameter vmName -Not -Mandatory
|
||||
}
|
||||
|
||||
it "Supports 'SupportsShouldProcess'" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter WhatIf
|
||||
Get-Command $file.BaseName | Should -HaveParameter Confirm
|
||||
$file | Should -FileContentMatch 'SupportsShouldProcess'
|
||||
$file | Should -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Function Unit Tests" {
|
||||
#TODO
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,44 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
|
||||
it "Supports 'ShouldProcess'" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter WhatIf
|
||||
Get-Command $file.BaseName | Should -HaveParameter Confirm
|
||||
$file | Should -FileContentMatch 'SupportsShouldProcess'
|
||||
$file | Should -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)'
|
||||
}
|
||||
|
||||
it "has a mandatory string parameter for the vpgName" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter vpgName
|
||||
Get-Command $file.BaseName | Should -HaveParameter vpgName -Type string[]
|
||||
Get-Command $file.BaseName | Should -HaveParameter vpgName -Mandatory
|
||||
}
|
||||
|
||||
it "has a switch parameter for reverse protection" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter reverseProtection
|
||||
Get-Command $file.BaseName | Should -HaveParameter reverseProtection -Type switch
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Function Unit Tests" {
|
||||
#TODO
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,19 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$commandName = $fileName -replace '.ps1', ''
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
#Requires -Modules Pester
|
||||
$moduleFileName = "ZertoApiWrapper.psd1"
|
||||
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
|
||||
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
$file = Get-ChildItem "$here\$sut"
|
||||
$modulePath = $here -replace "Public", ""
|
||||
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module $moduleFile -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
Describe $file.BaseName -Tag 'Unit' {
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "$commandName" {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "module should have a function called $commandName" {
|
||||
get-command $commandName | should be $true
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
$moduleFileName = "ZertoApiWrapper.psm1"
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$modulePath = $filePath -replace "Public", ""
|
||||
Import-Module $modulePath\$moduleFileName -Force
|
||||
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
|
||||
# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml
|
||||
$zertoServer = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
|
||||
Describe "File Tests" {
|
||||
$commands = Get-Command -Module ZertoApiWrapper | Select-Object -ExpandProperty Name
|
||||
foreach ($command in $commands) {
|
||||
$path = "{0}/{1}.ps1" -f $filePath, $command
|
||||
it "$command is backed by a file with the same name" {
|
||||
$path | should exist
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
#Requires -Modules Pester
|
||||
$testPath = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$docsPath = $testPath -replace 'Tests', 'docs'
|
||||
$modulePath = $testPath -replace 'Tests', 'ZertoApiWrapper'
|
||||
$module = Split-Path -Leaf $modulePath
|
||||
|
||||
Describe "Module: $module" -Tags 'Unit' {
|
||||
|
||||
Context "Module Configuration" {
|
||||
|
||||
It "Has a root module file ($module.psm1)" {
|
||||
"$modulePath\$module.psm1" | should -Exist
|
||||
}
|
||||
|
||||
It "Is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path "$modulePath\$module.psm1" -ErrorAction SilentlyContinue
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
|
||||
It "Has a manifest file ($module.psd1)" {
|
||||
|
||||
"$modulePath\$module.psd1" | Should -Exist
|
||||
}
|
||||
|
||||
It "Contains a root module path in the manifest (RootModule = '.\$module.psm1')" {
|
||||
|
||||
"$modulePath\$module.psd1" | Should -Exist
|
||||
"$modulePath\$module.psd1" | Should -FileContentMatch "\.\\$module.psm1"
|
||||
}
|
||||
|
||||
It "Has a public functions folder" {
|
||||
|
||||
"$modulePath\Public" | Should -Exist
|
||||
}
|
||||
|
||||
It "Has functions in the public functions folder" {
|
||||
|
||||
"$modulePath\Public\*.ps1" | Should -Exist
|
||||
}
|
||||
|
||||
It "Has a private functions folder" {
|
||||
|
||||
"$modulePath\Private" | Should -Exist
|
||||
}
|
||||
|
||||
It "Has functions in the private functions folder" {
|
||||
|
||||
"$modulePath\Private\*.ps1" | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
$Functions = Get-ChildItem $modulePath -Recurse -Include '*.ps1' -ErrorAction SilentlyContinue
|
||||
|
||||
foreach ($function in $functions) {
|
||||
$contents = Get-Content -Path $function.FullName -ErrorAction Stop
|
||||
$externalHelpFile = "{0}\{1}.md" -f $docsPath, $function.BaseName
|
||||
Context "Function $module::$($Function.BaseName)" {
|
||||
|
||||
It "Has a Pester Test" {
|
||||
$testFunction = ($Function.Name) -Replace '.ps1', '.Tests.ps1'
|
||||
$functionFolder = (Split-Path -leaf $(Split-Path -Parent $function.FullName))
|
||||
$testFunctionPath = "{0}\{1}\{2}" -f $testPath, $functionFolder, $testFunction
|
||||
$testFunctionPath | Should -Exist
|
||||
}
|
||||
|
||||
if ( -not ($function.directoryname.contains('Private'))) {
|
||||
|
||||
It "Has an external help file defined" {
|
||||
$contents | Select-Object -First 1 | Should -Be "<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>"
|
||||
}
|
||||
|
||||
It "Has an external help markdown file" {
|
||||
$externalHelpFile | Should -Exist
|
||||
}
|
||||
|
||||
it "External Help file does not contain place holder values" {
|
||||
$stubExist = Get-Content -Path $externalHelpFile | Where-Object {$_.Trim() -like '*{{*}}*'}
|
||||
if ($stubExist) {
|
||||
Write-Warning "Found a stub in the Markdown File $externalHelpFile"
|
||||
Write-Warning "$stubExist"
|
||||
}
|
||||
$stubExist | should benullorempty
|
||||
}
|
||||
}
|
||||
|
||||
It "Is an advanced function" {
|
||||
$Function.FullName | should -FileContentMatch 'function'
|
||||
$Function.FullName | should -FileContentMatch 'cmdletbinding'
|
||||
$Function.FullName | should -FileContentMatch 'param'
|
||||
}
|
||||
|
||||
It "Is valid Powershell (Has no script errors)" {
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
}
|
||||
|
||||
it "Has openbraces on the same line as the statement" {
|
||||
$openingBracesExist = $contents | Where-Object {$_.Trim() -eq '{'}
|
||||
if ($openingBracesExist) {
|
||||
Write-Warning "Found the following opening brances on their own line:"
|
||||
foreach ($openingBrace in $openingBracesExist) {
|
||||
Write-Warning "Opening Brace on it's own line - $openingBrace"
|
||||
}
|
||||
}
|
||||
$openingBracesExist | should -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
@{
|
||||
InvokeBuild = @{
|
||||
Name = 'InvokeBuild'
|
||||
DependencyType = 'PSGalleryModule'
|
||||
Parameters = @{
|
||||
Repository = 'PSGallery'
|
||||
SkipPublisherCheck = $true
|
||||
}
|
||||
Target = 'CurrentUser'
|
||||
Version = '5.5.1'
|
||||
Tags = 'Bootstrap'
|
||||
}
|
||||
|
||||
Pester = @{
|
||||
Name = 'Pester'
|
||||
DependencyType = 'PSGalleryModule'
|
||||
Parameters = @{
|
||||
Repository = 'PSGallery'
|
||||
SkipPublisherCheck = $true
|
||||
}
|
||||
Target = 'CurrentUser'
|
||||
Version = '4.7.3'
|
||||
Tags = 'Bootstrap'
|
||||
}
|
||||
|
||||
PSScriptAnalyzer = @{
|
||||
Name = 'PSScriptAnalyzer'
|
||||
DependencyType = 'PSGalleryModule'
|
||||
Parameters = @{
|
||||
Repository = 'PSGallery'
|
||||
SkipPublisherCheck = $true
|
||||
}
|
||||
Target = 'CurrentUser'
|
||||
Version = '1.18.0'
|
||||
Tags = 'Bootstrap'
|
||||
}
|
||||
|
||||
Platyps = @{
|
||||
Name = 'Platyps'
|
||||
DependencyType = 'PSGalleryModule'
|
||||
Parameters = @{
|
||||
Repository = 'PSGallery'
|
||||
SkipPublisherCheck = $true
|
||||
}
|
||||
Target = 'CurrentUser'
|
||||
Version = '0.14.0'
|
||||
Tags = 'Bootstrap'
|
||||
}
|
||||
}
|
||||
+164
-6
@@ -1,17 +1,60 @@
|
||||
task . InstallDependencies, Analyze
|
||||
#Requires -Modules 'InvokeBuild'
|
||||
|
||||
task InstallDependencies {
|
||||
Install-Module Pester -Force
|
||||
Install-Module PSScriptAnalyzer -Force
|
||||
. '.\ZertoApiWrapper.settings.ps1'
|
||||
# import-module "$BuildRoot\ZertoApiWrapper\ZertoApiWrapper.psd1" -Verbose -Force
|
||||
|
||||
<# [CmdletBinding()]
|
||||
param([switch]$Install,
|
||||
[string]$Configuration = (property Configuration Release))
|
||||
$targetDir = "temp/$Configuration/ZertoApiWrapper" #>
|
||||
$version = "{0}.{1}" -f $(Get-Content .\version.txt), $(get-date -format 'yyyyMMdd')
|
||||
|
||||
task . CreateArtifacts
|
||||
|
||||
<# Synopsis: Ensure platyPS is installed #>
|
||||
task CheckPlatyPSInstalled {
|
||||
if ($null -eq (Get-Module -List platyPS)) {
|
||||
Install-Module -Scope CurrentUser -Repository PSGallery -Name platyPS
|
||||
}
|
||||
}
|
||||
|
||||
task Analyze {
|
||||
<# Synopsis: Ensure Pester is installed #>
|
||||
task CheckPesterInstalled {
|
||||
if ($null -eq (Get-Module -List Pester)) {
|
||||
Install-Module -Scope CurrentUser -Repository PSGallery -Name Pester
|
||||
}
|
||||
}
|
||||
|
||||
<# Synopsis: Ensure PSScriptAnalyzer is installed #>
|
||||
task CheckPSScriptAnalyzerInstalled {
|
||||
if ($null -eq (Get-Module -List PSScriptAnalyzer)) {
|
||||
Install-Module -Scope CurrentUser -Repository PSGallery -Name PSScriptAnalyzer
|
||||
}
|
||||
}
|
||||
|
||||
<# Synopsis: Analyze ZertoApiWrapper functions for Code Violations #>
|
||||
task AnalyzeSourceFiles CheckPSScriptAnalyzerInstalled, {
|
||||
$scriptAnalyzerParams = @{
|
||||
Path = "$BuildRoot\ZertoApiWrapper\"
|
||||
Severity = @('Error', 'Warning')
|
||||
Recurse = $true
|
||||
Verbose = $false
|
||||
ExcludeRule = 'PSUseDeclaredVarsMoreThanAssignments'
|
||||
ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments', 'PSUseShouldProcessForStateChangingFunctions', 'PSUseToExportFieldsInManifest')
|
||||
}
|
||||
$saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams
|
||||
if ($saResults) {
|
||||
$saResults | Format-Table
|
||||
throw "One or more PSScriptAnalyzer errors/warnings were found"
|
||||
}
|
||||
}
|
||||
|
||||
task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, CreatePsm1ForRelease, {
|
||||
$scriptAnalyzerParams = @{
|
||||
Path = "$BuildRoot\temp\"
|
||||
Severity = @('Error', 'Warning')
|
||||
Recurse = $true
|
||||
Verbose = $false
|
||||
ExcludeRule = @()
|
||||
}
|
||||
$saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams
|
||||
|
||||
@@ -21,3 +64,118 @@ task Analyze {
|
||||
}
|
||||
}
|
||||
|
||||
task FileTests CheckPesterInstalled, {
|
||||
$testResultsFile = "$BuildRoot\Tests\TestResults.xml"
|
||||
$script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru
|
||||
$FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount
|
||||
assert ($results.FailedCount -eq 0) $FailureMessage
|
||||
}
|
||||
|
||||
$buildMamlParams = @{
|
||||
Inputs = { Get-ChildItem docs\*.md }
|
||||
Outputs = "$BuildRoot\temp\en-us\ZertoApiWrapper-help.xml"
|
||||
}
|
||||
|
||||
task BuildMamlHelp CheckPlatyPSInstalled, {
|
||||
if (Test-Path $buildMamlParams.Outputs) {
|
||||
Remove-Item $buildMamlParams.Outputs
|
||||
}
|
||||
platyPS\New-ExternalHelp .\docs -Force -OutputPath $buildMamlParams.Outputs
|
||||
}
|
||||
|
||||
task UpdateMarkdownHelp CheckPlatyPSInstalled, {
|
||||
remove-module ZertoApiWrapper -force -ErrorAction SilentlyContinue
|
||||
Import-Module .\ZertoApiWrapper\ZertoApiWrapper.psm1 -Force
|
||||
Update-MarkDownHelp -Path docs -AlphabeticParamsOrder
|
||||
}
|
||||
|
||||
task CreatePsd1ForRelease CleanTemp, {
|
||||
$functionsToExport = Get-ChildItem -Path 'ZertoApiWrapper\Public\*.ps1' | ForEach-Object { $_.BaseName }
|
||||
$releaseNotes = "# {0}{1}" -f $version, $(Get-Content .\RELEASENOTES.md -Raw)
|
||||
|
||||
$ManifestParams = @{
|
||||
Path = "$BuildRoot\temp\ZertoApiWrapper.psd1"
|
||||
RootModule = 'ZertoApiWrapper.psm1'
|
||||
ModuleVersion = $version
|
||||
GUID = '4c0b9e17-141b-4dd5-8549-fb21cccaa325'
|
||||
Author = 'Wes Carroll'
|
||||
CompanyName = 'Zerto'
|
||||
Copyright = '(c) {0} Wes Carroll. All rights reserved.' -f $(Get-Date -format 'yyyy')
|
||||
Description = 'PowerShell Core Wrapper Module for Zerto Virtual Manager API'
|
||||
PowerShellVersion = '6.0.0'
|
||||
ProjectUri = 'https://github.com/wcarroll/ZertoApiWrapper'
|
||||
LicenseUri = 'https://github.com/wcarroll/ZertoApiWrapper/blob/master/LICENSE'
|
||||
Tags = @("Zerto", "Automation")
|
||||
FunctionsToExport = $functionsToExport
|
||||
CmdletsToExport = @()
|
||||
VariablesToExport = @()
|
||||
AliasesToExport = @()
|
||||
ReleaseNotes = $releaseNotes
|
||||
}
|
||||
New-ModuleManifest @ManifestParams
|
||||
}
|
||||
|
||||
task CleanTemp {
|
||||
if (-not $(Test-Path "$BuildRoot\temp")) {
|
||||
New-Item -Path $BuildRoot -Name "temp" -ItemType "Directory"
|
||||
}
|
||||
Remove-Item -Recurse -Path "$BuildRoot\temp\*"
|
||||
}
|
||||
|
||||
task CreatePsm1ForRelease CreatePsd1ForRelease, {
|
||||
$emptyLine = ""
|
||||
$psm1Path = "$BuildRoot\temp\ZertoApiWrapper.psm1"
|
||||
$lines = '#------------------------------------------------------------#'
|
||||
$Public = @( Get-ChildItem -Path $BuildRoot\ZertoApiWrapper\Public\*.ps1 -ErrorAction SilentlyContinue )
|
||||
$functionCount = 0
|
||||
$exportString = ""
|
||||
foreach ($file in $Public) {
|
||||
if ($functionCount -eq 0) {
|
||||
$functionCount++
|
||||
$exportString = "{0}" -f $file.BaseName
|
||||
} else {
|
||||
$functionCount++
|
||||
$exportString = "{0}, {1}" -f $exportString, $file.BaseName
|
||||
}
|
||||
}
|
||||
$Private = @( Get-ChildItem -Path $BuildRoot\ZertoApiWrapper\Private\*.ps1 -ErrorAction SilentlyContinue )
|
||||
Add-Content -Path $psm1Path -Value $lines
|
||||
Add-Content -Path $psm1Path -Value "#---------------------Private Functions----------------------#"
|
||||
Add-Content -Path $psm1Path -Value $lines
|
||||
Add-Content -Path $psm1Path -Value $emptyLine
|
||||
foreach ($file in $private) {
|
||||
Add-Content -Path $psm1Path -Value $(Get-Content -Path $file.Fullname -Raw)
|
||||
Add-Content -Path $psm1Path -Value $emptyLine
|
||||
}
|
||||
Add-Content -Path $psm1Path -Value $lines
|
||||
Add-Content -Path $psm1Path -Value "#----------------------Public Functions----------------------#"
|
||||
Add-Content -Path $psm1Path -Value $lines
|
||||
Add-Content -Path $psm1Path -Value $emptyLine
|
||||
foreach ($file in $public) {
|
||||
Add-Content -Path $psm1Path -Value $(Get-Content -Path $file.Fullname -Raw)
|
||||
Add-Content -Path $psm1Path -Value $emptyLine
|
||||
}
|
||||
Add-Content -Path $psm1Path -Value $emptyLine
|
||||
Add-Content -Path $psm1Path -Value "Export-ModuleMember -Function $exportString"
|
||||
}
|
||||
|
||||
task CreateArtifacts CleanPublish, CreateModule, {
|
||||
if (-not $(Test-Path "$BuildRoot\publish")) {
|
||||
New-Item -Path $BuildRoot -Name "publish" -ItemType Directory
|
||||
}
|
||||
Compress-Archive -Path .\temp\* -DestinationPath .\publish\ZertoApiWrapper.zip
|
||||
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
|
||||
Import-Module .\temp\ZertoApiWrapper.psd1 -Force
|
||||
(Get-Module ZertoApiWrapper).ReleaseNotes | Add-Content .\publish\release-notes.txt
|
||||
(Get-Module ZertoApiWrapper).Version.ToString() | Add-Content .\publish\release-version.txt
|
||||
}
|
||||
|
||||
task CleanPublish {
|
||||
if ($(Test-Path "$BuildRoot\publish")) {
|
||||
Remove-Item -Recurse -Path "$BuildRoot\publish\*"
|
||||
}
|
||||
}
|
||||
|
||||
task CreateModule CleanTemp, FileTests, AnalyzeBuiltFiles, BuildMamlHelp, {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
# This file stores variables which are used by the build script
|
||||
|
||||
# Storing all values in a single $Settings variable to make it obvious that the values are coming from this BuildSettings file when accessing them.
|
||||
$Settings = @{
|
||||
|
||||
BuildOutput = "$PSScriptRoot\BuildOutput"
|
||||
Dependency = @('Pester', 'PsScriptAnalyzer', 'platyPS')
|
||||
SourceFolder = "$PSScriptRoot\ZertoApiWrapper"
|
||||
#SourceFolder = "$PSScriptRoot\$($env:APPVEYOR_PROJECT_NAME)"
|
||||
#TestUploadUrl = "https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)"
|
||||
#CoverallsKey = $env:Coveralls_Key
|
||||
#Branch = $env:APPVEYOR_REPO_BRANCH
|
||||
|
||||
UnitTestParams = @{
|
||||
Script = '.\Tests\Unit'
|
||||
#CodeCoverage = (Get-ChildItem -Path '.\PSCodeHealth\' -File -Filter "*.ps1" -Recurse).FullName | Where-Object { $_ -Match "Public|Private" }
|
||||
OutputFile = "$PSScriptRoot\BuildOutput\UnitTestsResult.xml"
|
||||
PassThru = $True
|
||||
}
|
||||
|
||||
IntegrationTestParams = @{
|
||||
Script = '.\Tests\Integration'
|
||||
OutputFile = "$PSScriptRoot\BuildOutput\IntegrationTestsResult.xml"
|
||||
PassThru = $True
|
||||
}
|
||||
|
||||
AnalyzeParams = @{
|
||||
Path = "$PSScriptRoot\$($env:APPVEYOR_PROJECT_NAME)"
|
||||
Severity = 'Error'
|
||||
Recurse = $True
|
||||
}
|
||||
|
||||
IsPullRequest = ($env:APPVEYOR_PULL_REQUEST_NUMBER -gt 0)
|
||||
Version = $env:APPVEYOR_BUILD_VERSION
|
||||
ManifestPath = '{0}\{1}\{1}.psd1' -f $PSScriptRoot, $env:APPVEYOR_PROJECT_NAME
|
||||
VersionRegex = "ModuleVersion\s=\s'(?<ModuleVersion>\S+)'" -as [regex]
|
||||
|
||||
ModuleName = $env:APPVEYOR_PROJECT_NAME
|
||||
HeaderPath = "$PSScriptRoot\header-mkdocs.yml"
|
||||
MkdocsPath = "$PSScriptRoot\mkdocs.yml"
|
||||
PublicFunctionDocsPath = "$PSScriptRoot\docs\PublicFunctions"
|
||||
PlatyPSParams = @{
|
||||
Module = $env:APPVEYOR_PROJECT_NAME
|
||||
OutputFolder = "$PSScriptRoot\docs\PublicFunctions"
|
||||
NoMetadata = $True
|
||||
Force = $True
|
||||
}
|
||||
PrivateFunctionDocsPath = "$PSScriptRoot\docs\InternalFunctions"
|
||||
InternalDocsPlatyPSParams = @{
|
||||
OutputFolder = "$PSScriptRoot\docs\InternalFunctions"
|
||||
WarningAction = 'SilentlyContinue'
|
||||
NoMetadata = $True
|
||||
Force = $True
|
||||
}
|
||||
FunctionsToExclude = @('Write-VerboseOutput', 'Get-SwitchCombination')
|
||||
|
||||
GitHubKey = $env:GitHub_Key
|
||||
Email = 'MathieuBuisson@users.noreply.github.com'
|
||||
Name = 'Mathieu Buisson'
|
||||
ScreenshotPath = "$($env:TEMP)\*Screenshot.png"
|
||||
PSGalleryKey = $env:PSGallery_Key
|
||||
OutputModulePath = "$PSScriptRoot\BuildOutput\$($env:APPVEYOR_PROJECT_NAME)"
|
||||
}
|
||||
|
||||
$ModuleManifestParams = @{
|
||||
RootModule = "ZertoApiWrapper"
|
||||
GUID = '4c0b9e17-141b-4dd5-8549-fb21cccaa325'
|
||||
Author = 'Wes Carroll'
|
||||
CompanyName = 'Zerto'
|
||||
Copyright = "(c) $(Get-Date -Format "yyyy") Wes Carroll. All rights reserved."
|
||||
Description = 'PowerShell Core Wrapper Module for Zerto Virtual Manager API'
|
||||
PowerShellVersion = '6.0.0'
|
||||
}
|
||||
|
||||
@@ -6,10 +6,12 @@ function Add-ZertoPeerSite {
|
||||
Mandatory = $true,
|
||||
HelpMessage = "Target Hostname or IP address to pair the localsite to."
|
||||
)]
|
||||
[ValidateScript( {$_ -match [IPAddress]$_ } )]
|
||||
[string]$targetHost,
|
||||
[Parameter(
|
||||
HelpMessage = "Target communication port. Default is 9081"
|
||||
)]
|
||||
[ValidateRange(1024, 65535)]
|
||||
[int]$targetPort = 9081
|
||||
)
|
||||
|
||||
@@ -27,4 +29,4 @@ function Add-ZertoPeerSite {
|
||||
end {
|
||||
# Nothing to do
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,13 @@ function Checkpoint-ZertoVpg {
|
||||
Mandatory = $true,
|
||||
HelpMessage = "Name of the VPG to tag."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$vpgName,
|
||||
[Parameter(
|
||||
Mandatory = $true,
|
||||
HelpMessage = "Text to tag the checkpoint with."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$checkpointName
|
||||
)
|
||||
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||
function Connect-ZertoServer {
|
||||
[cmdletbinding()]
|
||||
[OutputType([hashtable])]
|
||||
param(
|
||||
[Parameter(
|
||||
Mandatory = $true,
|
||||
HelpMessage = "IP address or FQDN of your Zerto Management Server"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("server", "zvm")]
|
||||
[string]$zertoServer,
|
||||
[Parameter(
|
||||
HelpMessage = "Zerto Virtual Manager management port. Default value is 9669."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[ValidateRange(1024, 65535)]
|
||||
[Alias("port")]
|
||||
[string]$zertoPort = "9669",
|
||||
[Parameter(
|
||||
Mandatory = $true,
|
||||
HelpMessage = "Valid credentials to connect to the Zerto Management Server"
|
||||
)]
|
||||
[System.Management.Automation.PSCredential]
|
||||
$credential,
|
||||
[System.Management.Automation.PSCredential]$credential,
|
||||
[switch]$returnHeaders
|
||||
)
|
||||
|
||||
@@ -35,7 +39,7 @@ function Connect-ZertoServer {
|
||||
|
||||
process {
|
||||
# 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
|
||||
$results = Invoke-ZertoRestRequest -uri $uri -credential $credential -returnHeaders -body $body -method POST -ErrorAction Stop
|
||||
}
|
||||
|
||||
end {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||
function Disconnect-ZertoServer {
|
||||
[cmdletbinding()]
|
||||
param()
|
||||
$uri = "session"
|
||||
|
||||
# Delete API Authorization
|
||||
|
||||
@@ -6,10 +6,13 @@ function Edit-ZertoVra {
|
||||
Mandatory = $true,
|
||||
HelpMessage = "Identifier of the VRA to be updated."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("vraId")]
|
||||
[string]$vraIdentifier,
|
||||
[Parameter(
|
||||
HelpMessage = "Bandwidth group to assign to the VRA. If unspecified will not modify current assignment"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$groupName,
|
||||
[Parameter(
|
||||
ParameterSetName = "StaticIp",
|
||||
@@ -35,6 +38,9 @@ function Edit-ZertoVra {
|
||||
$baseUri = "vras/{0}" -f $vraIdentifier
|
||||
# Get the current VRA information for use if an updated parameter is not supplied
|
||||
$vra = Get-ZertoVra -vraIdentifier $vraIdentifier
|
||||
if ( -not $vra ) {
|
||||
Write-Error "VRA with Identifier: $vraIdentifier could not be found. Please check the ID and try again."
|
||||
}
|
||||
}
|
||||
|
||||
process {
|
||||
@@ -48,7 +54,7 @@ function Edit-ZertoVra {
|
||||
$vraUpdate['GroupName'] = $vra.VraGroup
|
||||
}
|
||||
# If ParameterSetName StaticIp is used, update the parameters submitted
|
||||
if ( $PSCmdlet.ParameterSetName -eq 'StaticIp' ) {
|
||||
if ( $PSCmdlet.ParameterSetName -eq 'StaticIp' -or $vra.VraNetworkDataApi.VraIPConfigurationTypeApi -eq "Static" ) {
|
||||
if ( $PSBoundParameters.ContainsKey('defaultGateway') ) {
|
||||
$vraNetwork['DefaultGateway'] = $defaultGateway
|
||||
} else {
|
||||
@@ -67,6 +73,9 @@ function Edit-ZertoVra {
|
||||
$vraNetwork['VraIPConfigurationTypeApi'] = "Static"
|
||||
# Add network information to update object.
|
||||
$vraUpdate['VraNetworkDataApi'] = $vraNetwork
|
||||
} else {
|
||||
$vraNetwork['VraIPConfigurationTypeApi'] = "Dhcp"
|
||||
$vraUpdate['VraNetworkDataApi'] = $vraNetwork
|
||||
}
|
||||
# -WhatIf processing and submit!
|
||||
if ($PSCmdlet.ShouldProcess( "Updating " + $vra.vraName + " with these settings: $($vraUpdate | convertTo-Json)")) {
|
||||
@@ -78,3 +87,4 @@ function Edit-ZertoVra {
|
||||
# Nothing to Do
|
||||
}
|
||||
}
|
||||
#TODO: Refactor
|
||||
@@ -1,3 +1,4 @@
|
||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||
function Export-ZertoVpg {
|
||||
[cmdletbinding()]
|
||||
param(
|
||||
@@ -5,17 +6,22 @@ function Export-ZertoVpg {
|
||||
HelpMessage = "Location where to dump the resulting JSON files containing the VPG Settings",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[string]$outputFolder,
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("outputFolder")]
|
||||
[string]$outputPath,
|
||||
[parameter(
|
||||
HelpMessage = "Name(s) of the VPG(s) to be exported",
|
||||
ParameterSetName = "namedVpgs"
|
||||
ParameterSetName = "namedVpgs",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string[]]$vpgName,
|
||||
[parameter(
|
||||
HelpMessage = "Export all VPGs at this site",
|
||||
ParameterSetName = "allVpgs",
|
||||
valuefrompipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
Mandatory = $true
|
||||
)]
|
||||
[switch]$allVpgs
|
||||
)
|
||||
@@ -30,7 +36,7 @@ function Export-ZertoVpg {
|
||||
foreach ($name in $vpgName) {
|
||||
$vpgSettingsIdentifier = New-ZertoVpgSettingsIdentifier -vpgIdentifier $(Get-ZertoVpg -name $name).vpgIdentifier
|
||||
$vpgSettings = Get-ZertoVpgSetting -vpgSettingsIdentifier $vpgSettingsIdentifier
|
||||
$filePath = "{0}\{1}.json" -f $outputFolder, $name
|
||||
$filePath = "{0}\{1}.json" -f $outputPath, $name
|
||||
$vpgSettings | Convertto-Json -depth 10 | Out-File -FilePath $filePath
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ function Get-ZertoAlert {
|
||||
ValueFromPipelineByPropertyName = $true ,
|
||||
HelpMessage = "AlertId or array of AlertIds to be queried"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string[]]$alertId,
|
||||
[Parameter(
|
||||
ParameterSetName = "entities",
|
||||
@@ -32,41 +33,53 @@ function Get-ZertoAlert {
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Returns Alerts after the Start Date. Provide the string in the format of 'yyyy-MM-ddTHH:mm:ss.fff'"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$startDate,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Returns Alerts before the End Date. Provide the string in the format of 'yyyy-MM-ddTHH:mm:ss.fff'"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$endDate,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Returns alerts for the specified vraIdentifier"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("vpgId")]
|
||||
[string]$vpgIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Returns alerts for the specified siteIdentifier"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("siteId")]
|
||||
[string]$siteIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Returns alerts for the specified zorgIdentifier"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("zorgId")]
|
||||
[string]$zorgIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Returns alerts for the specified level"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$level,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Returns alerts for the specified helpIdentifier"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("helpId")]
|
||||
[string]$helpIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Returns alerts for the specified entity"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$entity,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
function Get-ZertoDatastore {
|
||||
[cmdletbinding( DefaultParameterSetName = "main" )]
|
||||
param(
|
||||
[Alias("datastoreId")]
|
||||
[Parameter(
|
||||
ParameterSetName = "datastoreIdentifier",
|
||||
HelpMessage = "datastoreIdentifier or array of datastoreIdentifiers to be queried"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string[]]$datastoreIdentifier
|
||||
)
|
||||
|
||||
|
||||
@@ -6,72 +6,92 @@ function Get-ZertoEvent {
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The starting date for the list of events, supplied as a date with the format of the Zerto Virtual Manager where the API runs, for example, yyyy-MM-dd. You can also specify a local time with the following format: yyyy-MM-ddTHH:mm:ss.fffZ. Adding Z to the end of the time sets the time to UTC."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$startDate,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The end date for the list, supplied as a date with the format of the Zerto Virtual Manager where the API runs, for example, yyyy-MM-dd. You can also specify a local time with the following format: yyyy-MM-ddTHH:mm:ss.fffZ. Adding Z to the end of the time sets the time to UTC."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$endDate,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The name of the VPG for which you want to return events."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("vpgName")]
|
||||
[string]$vpg,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The identifier of the VPG for which you want to return events."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("vpgId")]
|
||||
[string]$vpgIdentifier,
|
||||
[Parameter( ParameterSetName = "filter",
|
||||
HelpMessage = "The type of event. For the description of events, refer to the Zerto Virtual Replication documentation about alerts and events. Please see Zerto API Documentation for possible values."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$eventType,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The name of the site for which you want to return events."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$siteName,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The internal site identifier for which you want to return events."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("siteId")]
|
||||
[string]$siteIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The identifier of the ZORG, Zerto organization, defined in the Zerto Cloud Manager for which you want to return results."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("zorgId")]
|
||||
[string]$zorgIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The type of entity for which you wish to return results. Possible Values are: '0' or 'VPG', '1' or 'VRA', '2' or 'Unknown', or '3' or 'Site'"
|
||||
HelpMessage = "The type of entity for which you wish to return results. Possible Values are: 'VPG', 'VRA', 'Unknown', or 'Site'"
|
||||
)]
|
||||
[ValidateSet("VPG", "VRA", "Unknown", "Site")]
|
||||
[string]$entityType,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The name of the user for which the event occurred. If the event occurred as a result of a task started by the Zerto Virtual Manager, for example, when moving a VPG before the commit stage, the user is System."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$userName,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The type of event to return. This filter behaves in the same way as the eventCategory filter. Possible Values are: Possible Values are: '0' or 'All', '1' or 'Events', '2' or 'Alerts'"
|
||||
HelpMessage = "The type of event to return. This filter behaves in the same way as the eventCategory filter. Possible Values are: Possible Values are: 'All', 'Events', 'Alerts'"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$category,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = " This filter behaves in the same way as the category filter. If both category and eventCategory filters are specified, only the category filter value is used and the eventCategory filter value is ignored. The type of event to return. Possible Values are: '0' or 'All', '1' or 'Events', '2' or 'Alerts'"
|
||||
HelpMessage = " This filter behaves in the same way as the category filter. If both category and eventCategory filters are specified, only the category filter value is used and the eventCategory filter value is ignored. The type of event to return. Possible Values are: 'All', 'Events', 'Alerts'"
|
||||
)]
|
||||
[ValidateSet("All", "Events", "Alerts")]
|
||||
[string]$eventCategory,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The internal alert identifier for the Event"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("alertId")]
|
||||
[string]$alertIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "eventId",
|
||||
Mandatory = $true,
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
HelpMessage = "The identifier or identifiers of the event for which information is returned.")]
|
||||
HelpMessage = "The identifier or identifiers of the event for which information is returned."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string[]]$eventId,
|
||||
[Parameter(
|
||||
ParameterSetName = "categories",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||
function Get-ZertoLicense {
|
||||
[cmdletbinding()]
|
||||
param()
|
||||
$uri = "license"
|
||||
Invoke-ZertoRestRequest -uri $uri
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ function Get-ZertoPeerSite {
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
HelpMessage = "The identifier(s) of the peer site(s) for which information is to be returned."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("siteId")]
|
||||
[string[]]$siteIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
@@ -25,27 +27,30 @@ function Get-ZertoPeerSite {
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The pairing status for which information is to be returned."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$paringStatus,
|
||||
[Parameter (
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The site location, as specified in the site information, for which information is to be returned."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$location,
|
||||
[Parameter (
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The IP address of a Zerto Virtual Manager, paired with this site, for which information is to be returned."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$hostName,
|
||||
[Parameter (
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The port used to access peer sites for which information is to be returned. The default port is 9081."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$port
|
||||
)
|
||||
|
||||
begin {
|
||||
$baseUri = "peersites"
|
||||
$returnObject = [System.Collections.ArrayList]@()
|
||||
}
|
||||
|
||||
process {
|
||||
@@ -53,14 +58,14 @@ function Get-ZertoPeerSite {
|
||||
"main" {
|
||||
$uri = "{0}" -f $baseUri
|
||||
$results = Invoke-ZertoRestRequest -uri $uri
|
||||
$returnObject.Add($results) | Out-Null
|
||||
return $results
|
||||
}
|
||||
|
||||
"siteIdentifier" {
|
||||
foreach ( $id in $siteIdentifier ) {
|
||||
$uri = "{0}/{1}" -f $baseUri, $id
|
||||
$results = Invoke-ZertoRestRequest -uri $uri
|
||||
$returnObject.Add($results) | Out-Null
|
||||
return $results
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,18 +73,18 @@ function Get-ZertoPeerSite {
|
||||
$filter = Get-ZertoApiFilter -filterTable $PSBoundParameters
|
||||
$uri = "{0}{1}" -f $baseUri, $filter
|
||||
$results = Invoke-ZertoRestRequest -uri $uri
|
||||
$returnObject.Add($results) | Out-Null
|
||||
return $results
|
||||
}
|
||||
|
||||
default {
|
||||
$uri = "{0}/{1}" -f $baseUri, $PSCmdlet.ParameterSetName.ToLower()
|
||||
$results = Invoke-ZertoRestRequest -uri $uri
|
||||
$returnObject.Add($results) | Out-Null
|
||||
return $results
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
return $returnObject
|
||||
#Nothing to do!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,56 +9,70 @@ function Get-ZertoProtectedVm {
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
HelpMessage = "vmIdentifier(s) for which to return information"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("vmId")]
|
||||
[string[]]$vmIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The name of the VPG which protects the virtual machine."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$vpgName,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The name of the virtual machine."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$vmName,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The status of the VPG. Please see Zerto API documentation for possible values."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$status,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The substatus of the VPG, for example the VPG is in a bitmap sync. For the description of substatuses, refer to the Zerto Virtual Manager Administration Guide. Please see Zerto API documentation for possible values."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$substatus,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The ZORG for this VPG."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$organizationName,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The priority specified for the VPG. Possible values are: '0' or 'Low', '1' or 'Medium', '2' or 'High'"
|
||||
HelpMessage = "The priority specified for the VPG. Possible values are: 'Low', 'Medium', or 'High'"
|
||||
)]
|
||||
[ValidateSet("Low", "Medium", "High")]
|
||||
[string]$priority,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The protected site type. Please see Zerto API documentation for possible values."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$protectedSiteType,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The recovery site type. Please see Zerto API documentation for possible values."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$recoverySiteType,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The identifier of the protected site where the VPG virtual machines are protected."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("protectedSiteId")]
|
||||
[string]$protectedSiteIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The identifier of the recovery site where the VPG virtual machines are recovered."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("recoverySiteId")]
|
||||
[string]$recoverySiteIdentifier
|
||||
)
|
||||
|
||||
|
||||
@@ -6,41 +6,49 @@ function Get-ZertoRecoveryReport {
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Operations performed between the specified start Time and end Time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$startTime,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Operations performed between the specified start Time and end Time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$endTime,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The page number the user wants to retrieve. Minimum value is 1."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$pageNumber,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The number of reports to display in a single page. The maximum number of reports per page is 1000."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$pageSize,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The internal identifier of the VPG. You can specify more than one VPG, separated by commas."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$vpgIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The name of the VPG. You can specify more than one VPG, separated by commas."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$vpgName,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The type of recovery operations. Possible values are: 'Failover', 'Failover Test', or 'Move'"
|
||||
)]
|
||||
[ValidateSet("Failover", "Failover Test", "Move")]
|
||||
[string]$recoveryType,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Whether the recovery operation has completed."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$state
|
||||
)
|
||||
|
||||
|
||||
@@ -6,86 +6,103 @@ function Get-ZertoResourcesReport {
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Operations performed between the specified start Time and end Time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$startTime,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Operations performed between the specified start Time and end Time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$endTime,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The page number to retrieve. Minimum value is 1"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$pageNumber,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The number of reports to display in a single page. The maximum number of reports per page is 1000."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$pageSize,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The name of the organization set up in the Zerto Cloud Manager."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$zorgName,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The name of the virtual machine."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$vmName,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The name of the VPG."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$vpgName,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The name of the protected site."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$protectedSiteName,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The name of the cluster containing the host where the virtual machine in the recovery site resides."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$protectedClusterName,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The address or DNS name of the host where the virtual machine in the recovery site resides."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$protectedHostName,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The name of the vDC organization in the protected site."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$protectedOrgVdc,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The name of the vCD organization in the protected site."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$protectedVdcOrg,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The name of the recovery site."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$recoverySiteName,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The name of the cluster containing the host where the virtual machine in the recovery site resides."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$recoveryClusterName,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The address or DNS name of the host where the virtual machine in the recovery site resides."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$recoveryHostName,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The name of the vDC organization in the recovery site."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$recoveryOrgVdc,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The name of the recovery vCD organization."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$recoveryVdcOrg
|
||||
)
|
||||
|
||||
|
||||
@@ -6,11 +6,15 @@ function Get-ZertoServiceProfile {
|
||||
ParameterSetName = "siteIdentifier",
|
||||
HelpMessage = "The identifier of the site for which service profiles should be returned."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("siteId")]
|
||||
[string]$siteIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "serviceProfileId",
|
||||
HelpMessage = "The service profile ID for which information should be returned."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("serviceProfileIdentifier")]
|
||||
[string[]]$serviceProfileId
|
||||
)
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ function Get-ZertoTask {
|
||||
ParameterSetName = "taskIdentifier",
|
||||
HelpMessage = "The identifier(s) for which task information is to be returned."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("taskId")]
|
||||
[string[]]$taskIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "types",
|
||||
@@ -16,31 +18,37 @@ function Get-ZertoTask {
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Tasks started before this time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$startedBeforeDate,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Tasks started after this time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$startedAfterDate,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Tasks completed after this time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$completedAfterDate,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Tasks completed before this time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$completedBeforeDate,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The type of task. For the description of the tasks, refer to the Zerto Virtual Replication documentation about monitoring tasks. Please see Zerto API Documentation for possible types and values."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$type,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The status of the task. Possible values are: '1' or 'InProgress', '3' or 'Paused', '4' or 'Failed', '6' or 'Completed', '7' or 'Cancelling'"
|
||||
HelpMessage = "The status of the task. Possible values are: 'InProgress', 'Paused', 'Failed', 'Completed', or 'Cancelling'"
|
||||
)]
|
||||
[ValidateSet("InProgress", "Paused", "Failed", "Completed", "Cancelling")]
|
||||
[string]$status
|
||||
)
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||
function Get-ZertoUnprotectedVm {
|
||||
[cmdletbinding()]
|
||||
param()
|
||||
$uri = "virtualizationsites/{0}/vms" -f $script:zvmLocalInfo.siteidentifier
|
||||
Invoke-ZertoRestRequest -uri $uri
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ function Get-ZertoVirtualizationSite {
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier of the Zerto Virtual Manager site."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("siteId")]
|
||||
[string]$siteIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "datastoreClusters",
|
||||
@@ -81,6 +83,8 @@ function Get-ZertoVirtualizationSite {
|
||||
Mandatory = $false,
|
||||
HelpMessage = "The identifier of the host at the selected site to return information for only one host."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("hostId")]
|
||||
[string]$hostIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "folders",
|
||||
|
||||
@@ -6,26 +6,35 @@ function Get-ZertoVolume {
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The type of volume. Please see Zerto API Documentation for possible values."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$volumeType,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The identifier of the VPG."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("vpgId")]
|
||||
[string]$vpgIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The identifier of the datastore."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("datastoreId", "dsId")]
|
||||
[string]$datastoreIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The identifier of the protected virtual machine."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("protectedVmId")]
|
||||
[string]$protectedVmIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The identifier of the owning virtual machine."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("owningVmId")]
|
||||
[string]$owningVmIdentifier
|
||||
)
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ function Get-ZertoVpg {
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier(s) of the Virtual Protection Group to return"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("vpgId", "protectionGroupId", "pgId")]
|
||||
[string[]]$protectionGroupIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "checkpoints",
|
||||
@@ -28,11 +30,13 @@ function Get-ZertoVpg {
|
||||
ParameterSetName = "checkpoints",
|
||||
HelpMessage = "Return checkpoints after the specified start date. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$startDate,
|
||||
[Parameter(
|
||||
ParameterSetName = "checkpoints",
|
||||
HelpMessage = "Return checkpoints before the specified start date. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$endDate,
|
||||
[Parameter(
|
||||
ParameterSetName = "stats", Mandatory = $true,
|
||||
@@ -85,57 +89,68 @@ function Get-ZertoVpg {
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The name of the VPG."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("vpgName")]
|
||||
[string]$name,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The status of the VPG. Please use 'Get-ZertoVpg -statuses' for valid values"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$status,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The substatus of the VPG. Please use 'Get-ZertoVpg -substatuses' for valid values"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$subStatus,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The protected site environment. This filter behaves in the same way as the sourceType filter. Please see Zerto API Documentation for vaild values and discriptions."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$protectedSiteType,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The recovery site environment. This filter behaves in the same way as the sourceType filter. Please see Zerto API Documentation for vaild values and discriptions."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$recoverySiteType,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The identifier of the protected site where the VPG virtual machines are protected."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$protectedSiteIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The identifier of the protected site where the VPG virtual machines are recovered."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$recoverySiteIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The ZORG for this VPG."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$organizationName,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The internal identifier for the ZORG."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$zorgIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The VPG priority. Possible values are: '0' or 'Low', '1' or 'Medium', '2' or 'High'"
|
||||
HelpMessage = "The VPG priority. Possible values are: 'Low', 'Medium', 'High'"
|
||||
)]
|
||||
[ValidateSet("Low", "Medium", "High")]
|
||||
[string]$priority,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "The identifier of the service profile to use for the VPG when a Zerto Cloud Manager is used."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$serviceProfileIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
@@ -171,9 +186,9 @@ function Get-ZertoVpg {
|
||||
if ( $PSBoundParameters.ContainsKey("startDate") -or $PSBoundParameters.ContainsKey("endDate") ) {
|
||||
$filter = $true
|
||||
$filterTable = @{}
|
||||
foreach ( $key in $PSBoundParameters.Keys ) {
|
||||
if ( $key -eq "startDate" -or $key -eq "endDate") {
|
||||
$filterTable[$key] = $PSBoundParameters[$key]
|
||||
foreach ( $param in $PSBoundParameters.GetEnumerator() ) {
|
||||
if ( $param.key -eq "startDate" -or $param.key -eq "endDate") {
|
||||
$filterTable[$param.key] = $param.value
|
||||
}
|
||||
}
|
||||
$filter = Get-ZertoApiFilter -filterTable $filterTable
|
||||
|
||||
@@ -9,6 +9,7 @@ function Get-ZertoVpgSetting {
|
||||
ParameterSetName = "vpgSettingsIdentifier",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
ValueFromRemainingArguments = $true,
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier of the VPG settings object for which information is retrieved."
|
||||
)]
|
||||
@@ -16,6 +17,7 @@ function Get-ZertoVpgSetting {
|
||||
ParameterSetName = "backup",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
ValueFromRemainingArguments = $true,
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier of the VPG settings object for which information is retrieved."
|
||||
)]
|
||||
@@ -23,6 +25,7 @@ function Get-ZertoVpgSetting {
|
||||
ParameterSetName = "dayOfWeek",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
ValueFromRemainingArguments = $true,
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier of the VPG settings object for which information is retrieved."
|
||||
)]
|
||||
@@ -30,6 +33,7 @@ function Get-ZertoVpgSetting {
|
||||
ParameterSetName = "retentionPeriod",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
ValueFromRemainingArguments = $true,
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier of the VPG settings object for which information is retrieved."
|
||||
)]
|
||||
@@ -37,6 +41,7 @@ function Get-ZertoVpgSetting {
|
||||
ParameterSetName = "schedulerPeriod",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
ValueFromRemainingArguments = $true,
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier of the VPG settings object for which information is retrieved."
|
||||
)]
|
||||
@@ -44,12 +49,14 @@ function Get-ZertoVpgSetting {
|
||||
ParameterSetName = "basic",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
ValueFromRemainingArguments = $true,
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier of the VPG settings object for which information is retrieved."
|
||||
)]
|
||||
[Parameter(
|
||||
ParameterSetName = "bootGroup",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
ValueFromRemainingArguments = $true,
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier of the VPG settings object for which information is retrieved."
|
||||
@@ -57,6 +64,7 @@ function Get-ZertoVpgSetting {
|
||||
[Parameter(
|
||||
ParameterSetName = "journal",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
ValueFromRemainingArguments = $true,
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier of the VPG settings object for which information is retrieved."
|
||||
@@ -64,6 +72,7 @@ function Get-ZertoVpgSetting {
|
||||
[Parameter(
|
||||
ParameterSetName = "networks",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
ValueFromRemainingArguments = $true,
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier of the VPG settings object for which information is retrieved."
|
||||
@@ -71,6 +80,7 @@ function Get-ZertoVpgSetting {
|
||||
[Parameter(
|
||||
ParameterSetName = "priority",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
ValueFromRemainingArguments = $true,
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier of the VPG settings object for which information is retrieved."
|
||||
@@ -78,6 +88,7 @@ function Get-ZertoVpgSetting {
|
||||
[Parameter(
|
||||
ParameterSetName = "recovery",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
ValueFromRemainingArguments = $true,
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier of the VPG settings object for which information is retrieved."
|
||||
@@ -85,6 +96,7 @@ function Get-ZertoVpgSetting {
|
||||
[Parameter(
|
||||
ParameterSetName = "scripting",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
ValueFromRemainingArguments = $true,
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier of the VPG settings object for which information is retrieved."
|
||||
@@ -92,6 +104,7 @@ function Get-ZertoVpgSetting {
|
||||
[Parameter(
|
||||
ParameterSetName = "vms",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
ValueFromRemainingArguments = $true,
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier of the VPG settings object for which information is retrieved."
|
||||
@@ -99,6 +112,7 @@ function Get-ZertoVpgSetting {
|
||||
[Parameter(
|
||||
ParameterSetName = "vmIdentifier",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
ValueFromRemainingArguments = $true,
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier of the VPG settings object for which information is retrieved."
|
||||
@@ -106,6 +120,7 @@ function Get-ZertoVpgSetting {
|
||||
[Parameter(
|
||||
ParameterSetName = "nics",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
ValueFromRemainingArguments = $true,
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier of the VPG settings object for which information is retrieved."
|
||||
@@ -113,6 +128,7 @@ function Get-ZertoVpgSetting {
|
||||
[Parameter(
|
||||
ParameterSetName = "nicIdentifier",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
ValueFromRemainingArguments = $true,
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier of the VPG settings object for which information is retrieved."
|
||||
@@ -120,6 +136,7 @@ function Get-ZertoVpgSetting {
|
||||
[Parameter(
|
||||
ParameterSetName = "volumes",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
ValueFromRemainingArguments = $true,
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier of the VPG settings object for which information is retrieved."
|
||||
@@ -127,11 +144,14 @@ function Get-ZertoVpgSetting {
|
||||
[Parameter(
|
||||
ParameterSetName = "volumeIdentifier",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
ValueFromRemainingArguments = $true,
|
||||
Mandatory = $true,
|
||||
HelpMessage = "The identifier of the VPG settings object for which information is retrieved."
|
||||
)]
|
||||
[string]$vpgSettingsIdentifier,
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("vpgSettingsId", "settingsId")]
|
||||
[string[]]$vpgSettingsIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "backup",
|
||||
Mandatory = $true,
|
||||
@@ -229,6 +249,8 @@ function Get-ZertoVpgSetting {
|
||||
Mandatory = $true,
|
||||
HelpMessage = "VM Identifier"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("vmId")]
|
||||
[string]$vmIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "nics",
|
||||
@@ -241,6 +263,8 @@ function Get-ZertoVpgSetting {
|
||||
Mandatory = $true,
|
||||
HelpMessage = "Return NIC information for specified NIC of the specified VM"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("nicId")]
|
||||
[string]$nicIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "volumes",
|
||||
@@ -253,43 +277,105 @@ function Get-ZertoVpgSetting {
|
||||
Mandatory = $true,
|
||||
HelpMessage = "Return volume information for the specified volume of the specified VM"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("volumeId")]
|
||||
[string]$volumeIdentifier
|
||||
)
|
||||
|
||||
begin {
|
||||
$baseUri = "vpgSettings"
|
||||
$returnObject = @()
|
||||
}
|
||||
|
||||
#TODO - Update to Switch Logic
|
||||
process {
|
||||
if ( $PSCmdlet.ParameterSetName -eq "main" ) {
|
||||
$returnObject = Invoke-ZertoRestRequest -uri $baseUri
|
||||
} elseif ($PSCmdlet.ParameterSetName -eq "vpgSettingsIdentifier") {
|
||||
$uri = "{0}/{1}" -f $baseUri, $vpgSettingsIdentifier
|
||||
$returnObject = Invoke-ZertoRestRequest -uri $uri
|
||||
} elseif ( $PSCmdlet.ParameterSetName -eq "dayOfWeek" -or $PSCmdlet.ParameterSetName -eq "retentionPeriod" -or $PSCmdlet.ParameterSetName -eq "schedulerPeriod" ) {
|
||||
$uri = "{0}/{1}/backup/{2}" -f $baseUri, $vpgSettingsIdentifier, $PSCmdlet.ParameterSetName.ToLower()
|
||||
$returnObject = Invoke-ZertoRestRequest -uri $uri
|
||||
} elseif ( $PSCmdlet.ParameterSetName -eq "nics" -or $PSCmdlet.ParameterSetName -eq "volumes" ) {
|
||||
$uri = "{0}/{1}/vms/{2}/{3}" -f $baseUri, $vpgSettingsIdentifier, $vmIdentifier, $PSCmdlet.ParameterSetName.ToLower()
|
||||
$returnObject = Invoke-ZertoRestRequest -uri $uri
|
||||
} elseif ( $PSCmdlet.ParameterSetName -eq "vmIdentifier" ) {
|
||||
$uri = "{0}/{1}/vms/{2}" -f $baseUri, $vpgSettingsIdentifier, $vmIdentifier
|
||||
$returnObject = Invoke-ZertoRestRequest -uri $uri
|
||||
} elseif ( $PSCmdlet.ParameterSetName -eq "nicIdentifier" ) {
|
||||
$uri = "{0}/{1}/vms/{2}/nics/{3}" -f $baseUri, $vpgSettingsIdentifier, $vmIdentifier, $nicIdentifier
|
||||
$returnObject = Invoke-ZertoRestRequest -uri $uri
|
||||
} elseif ( $PSCmdlet.ParameterSetName -eq "volumeIdentifier" ) {
|
||||
$uri = "{0}/{1}/vms/{2}/volumes/{3}" -f $baseUri, $vpgSettingsIdentifier, $vmIdentifier, $volumeIdentifier
|
||||
$returnObject = Invoke-ZertoRestRequest -uri $uri
|
||||
} else {
|
||||
$uri = "{0}/{1}/{2}" -f $baseUri, $vpgSettingsIdentifier, $PSCmdlet.ParameterSetName.ToLower()
|
||||
$returnObject = Invoke-ZertoRestRequest -uri $uri
|
||||
switch ( $PSCmdlet.ParameterSetName ) {
|
||||
"main" {
|
||||
Invoke-ZertoRestRequest -uri $baseUri
|
||||
break
|
||||
}
|
||||
|
||||
"vpgSettingsIdentifier" {
|
||||
foreach ($id in $vpgSettingsIdentifier) {
|
||||
$uri = "{0}/{1}" -f $baseUri, $id
|
||||
Invoke-ZertoRestRequest -uri $uri
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
"dayOfWeek" {
|
||||
foreach ($id in $vpgSettingsIdentifier) {
|
||||
$uri = "{0}/{1}/backup/{2}" -f $baseUri, $id, $PSCmdlet.ParameterSetName.ToLower()
|
||||
Invoke-ZertoRestRequest -uri $uri
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
"retentionPeriod" {
|
||||
foreach ($id in $vpgSettingsIdentifier) {
|
||||
$uri = "{0}/{1}/backup/{2}" -f $baseUri, $id, $PSCmdlet.ParameterSetName.ToLower()
|
||||
Invoke-ZertoRestRequest -uri $uri
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
"schedulerPeriod" {
|
||||
foreach ($id in $vpgSettingsIdentifier) {
|
||||
$uri = "{0}/{1}/backup/{2}" -f $baseUri, $id, $PSCmdlet.ParameterSetName.ToLower()
|
||||
Invoke-ZertoRestRequest -uri $uri
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
"nics" {
|
||||
foreach ($id in $vpgSettingsIdentifier) {
|
||||
$uri = "{0}/{1}/vms/{2}/{3}" -f $baseUri, $id, $vmIdentifier, $PSCmdlet.ParameterSetName.ToLower()
|
||||
Invoke-ZertoRestRequest -uri $uri
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
"volumes" {
|
||||
foreach ($id in $vpgSettingsIdentifier) {
|
||||
$uri = "{0}/{1}/vms/{2}/{3}" -f $baseUri, $id, $vmIdentifier, $PSCmdlet.ParameterSetName.ToLower()
|
||||
Invoke-ZertoRestRequest -uri $uri
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
"vmIdentifier" {
|
||||
foreach ($id in $vpgSettingsIdentifier) {
|
||||
$uri = "{0}/{1}/vms/{2}" -f $baseUri, $id, $vmIdentifier
|
||||
Invoke-ZertoRestRequest -uri $uri
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
"nicIdentifier" {
|
||||
foreach ($id in $vpgSettingsIdentifier) {
|
||||
$uri = "{0}/{1}/vms/{2}/nics/{3}" -f $baseUri, $id, $vmIdentifier, $nicIdentifier
|
||||
Invoke-ZertoRestRequest -uri $uri
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
"volumeIdentifier" {
|
||||
foreach ($id in $vpgSettingsIdentifier) {
|
||||
$uri = "{0}/{1}/vms/{2}/volumes/{3}" -f $baseUri, $id, $vmIdentifier, $volumeIdentifier
|
||||
Invoke-ZertoRestRequest -uri $uri
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
default {
|
||||
foreach ($id in $vpgSettingsIdentifier) {
|
||||
$uri = "{0}/{1}/{2}" -f $baseUri, $id, $PSCmdlet.ParameterSetName.ToLower()
|
||||
Invoke-ZertoRestRequest -uri $uri
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
return $returnObject
|
||||
#Nothing to do!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,51 +18,62 @@ function Get-ZertoVra {
|
||||
ParameterSetName = "vraIdentifier",
|
||||
HelpMessage = "Returns information for provided VRA identifier(s)"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("vraId")]
|
||||
[string[]]$vraIdentifier,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "VRA Name to return information for."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$vraName,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Search for VRAs in a specific status"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$status,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Search for VRAs of a specific version"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$vraVersion,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Search for VRAs paired to a specific host version"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$hostVersion,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Search for a VRA with the specified IP address"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$ipAddress,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Search for VRAs belonging to a specific group"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$vraGroup,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Search for VRAs on a specific datastore"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$datastoreName,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Search for VRAs on a specific datastore cluster"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$datastoreClusterName,
|
||||
[Parameter(
|
||||
ParameterSetName = "filter",
|
||||
HelpMessage = "Search for VRAs on a specific network"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$networkName
|
||||
)
|
||||
|
||||
@@ -83,7 +94,7 @@ function Get-ZertoVra {
|
||||
}
|
||||
|
||||
# When vra ids are provided, return for each id provided
|
||||
"vraIdentifierifierifier" {
|
||||
"vraIdentifier" {
|
||||
$returnObject = foreach ( $vraId in $vraIdentifier ) {
|
||||
$uri = "{0}/{1}" -f $baseUri, $vraId
|
||||
Invoke-ZertoRestRequest -uri $uri
|
||||
|
||||
@@ -6,6 +6,8 @@ function Get-ZertoZorg {
|
||||
ParameterSetName = "zorgIdentifier",
|
||||
HelpMessage = "Identifier(s) of the ZORG."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("zorgId")]
|
||||
[string[]]$zorgIdentifier
|
||||
)
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ function Get-ZertoZsspSession {
|
||||
ParameterSetName = "zsspSessionIdentifier",
|
||||
HelpMessage = "ZSSP Session Id(s) to get information."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("zsspSessionId")]
|
||||
[string[]]$zsspSessionIdentifier
|
||||
)
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||
function Import-ZertoVpg {
|
||||
[cmdletbinding()]
|
||||
param(
|
||||
@@ -7,6 +8,7 @@ function Import-ZertoVpg {
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("FullName")]
|
||||
[string[]]$settingsFile
|
||||
)
|
||||
@@ -23,7 +25,7 @@ function Import-ZertoVpg {
|
||||
$importedSettings.VpgSettingsIdentifier = $vpgSettingsIdentifier
|
||||
$uri = "{0}/{1}" -f $baseUri, $vpgSettingsIdentifier
|
||||
Invoke-ZertoRestRequest -uri $uri -method "PUT" -body $($importedSettings | convertto-json -Depth 10)
|
||||
$vpgSettingsIdentifier | Save-ZertoVpgSettings
|
||||
$vpgSettingsIdentifier | Save-ZertoVpgSetting
|
||||
if ($settingsFile.Count -gt 1) {
|
||||
Start-Sleep 5
|
||||
}
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
#TODO - Add ability to installed with root password.
|
||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||
#TODO - Add ability to installed with root password, Move to Begin, Process, End Format
|
||||
function Install-ZertoVra {
|
||||
[cmdletbinding( SupportsShouldProcess = $true )]
|
||||
param(
|
||||
[Parameter( Mandatory = $true, HelpMessage = "Host name where the VRA is to be installed." )]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$hostName,
|
||||
[Parameter( Mandatory = $true, HelpMessage = "Datastore name where the VRA is to be installed." )]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$datastoreName,
|
||||
[Parameter( Mandatory = $true, HelpMessage = "Network name the VRA is to be assigned." )]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$networkName,
|
||||
[Parameter( HelpMessage = "Initial amount of memory to assign to the VRA in GB. Default is 3, Minimum is 1, Maximum is 16" )]
|
||||
[ValidateRange(1, 16)]
|
||||
[int]$memoryInGB = 3,
|
||||
[Parameter( HelpMessage = "Bandwidth group to assign to the VRA. If unspecified will assign to the 'default_group'" )]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$groupName,
|
||||
[Parameter( ParameterSetName = "Dhcp", Mandatory = $true, HelpMessage = "Assign a DHCP address to the VRA." )]
|
||||
[switch]$Dhcp,
|
||||
|
||||
@@ -1,68 +1,99 @@
|
||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||
function Invoke-ZertoFailover {
|
||||
[cmdletbinding()]
|
||||
[cmdletbinding( SupportsShouldProcess = $true )]
|
||||
param(
|
||||
#TODO - Refactor?
|
||||
[Parameter(
|
||||
Mandatory = $true,
|
||||
HelpMessage = "Name of the VPG to Failover"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$vpgName,
|
||||
[Parameter(
|
||||
HelpMessage = "Checkpoint Identifier to use as the Point-In-Time to rollback to."
|
||||
)]
|
||||
[Alias("checkpointId")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$checkpointIdentifier,
|
||||
[Parameter(
|
||||
HelpMessage = "0: After the seconds specified in the commitValue setting have elapsed, the failover is rolled back.
|
||||
1: After the seconds specified in the commitValue setting have elapsed, the failover continues, committing the virtual machines in the recovery site.
|
||||
2: 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.
|
||||
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."
|
||||
)]
|
||||
[string]$commitPolicy,
|
||||
[ValidateSet("Rollback", "Commit", "None")]
|
||||
[string]$commitPolicy = "Rollback",
|
||||
[Parameter(
|
||||
HelpMessage = "The amount of time in seconds the failover waits in a Before Commit state to enable checking that the failover is as required before performing the commitPolicy setting. Default is the Site Setting"
|
||||
)]
|
||||
[string]$commitValue,
|
||||
[Parameter(
|
||||
HelpMessage = "0: The protected virtual machines are not touched before starting the failover. This assumes that you do not have access to the protected virtual machines. -- DEFAULT
|
||||
1: If the protected virtual machines have VMware Tools or Microsoft Integration Services available, the virtual machines are gracefully shut down, otherwise the failover operation fails. This is similar to performing a Move operation to a specified checkpoint.
|
||||
2: The protected virtual machines are forcibly shut down before starting the failover. If the protected virtual machines have VMware Tools or Microsoft Integration Services available, the procedure waits five minutes for the virtual machines to be gracefully shut down before forcibly powering them off. This is similar to performing a Move operation to a specified checkpoint."
|
||||
HelpMessage = "0: The protected virtual machines are not touched before starting the failover. -- DEFAULT
|
||||
1: If the protected virtual machines have VMware Tools or Microsoft Integration Services available, the virtual machines are gracefully shut down, otherwise the failover operation fails. This is similar to performing a Move operation to a specified checkpoint. This assumes that you do not have access to the protected virtual machines.
|
||||
2: The protected virtual machines are forcibly shut down before starting the failover. If the protected virtual machines have VMware Tools or Microsoft Integration Services available, the procedure waits five minutes for the virtual machines to be gracefully shut down before forcibly powering them off. This is similar to performing a Move operation to a specified checkpoint. This assumes that you do not have access to the protected virtual machines"
|
||||
)]
|
||||
[ValidateSet(0, 1, 2)]
|
||||
[int]$shutdownPolicy = 0,
|
||||
[Parameter(
|
||||
HelpMessage = "Time, in seconds, before VMs are forcibly turned off if the Force Shutdown option is seclected after attempting to gracefully shut down the VMs"
|
||||
HelpMessage = "The amount of time in seconds the failover waits in a Before Commit state to enable checking that the failover is as required before performing the commitPolicy setting. Default is 60 Minutes (3600 Seconds)"
|
||||
)]
|
||||
[long]$timeToWaitBeforeShutdownInSec = 300,
|
||||
# Min 5 Minutes, Max 24 Hours, Default 1 Hour.
|
||||
[ValidateRange(300, 86400)]
|
||||
[int]$timeToWaitBeforeShutdownInSec = 3600,
|
||||
[Parameter(
|
||||
HelpMessage = "True: Enable reverse protection. The virtual machines are recovered on the recovery site and then protected using the default reverse protection settings.
|
||||
False: 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."
|
||||
)]
|
||||
[bool]$reverseProtection,
|
||||
[Parameter(
|
||||
HelpMessage = "Name(s) of VMs in the "
|
||||
HelpMessage = "Name(s) of VMs in the VPG to failover"
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string[]]$vmName
|
||||
)
|
||||
|
||||
begin {
|
||||
$vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier
|
||||
$baseUri = "vpgSettings/{0}/failover" -f $vpgId
|
||||
$body = [ordered]@{}
|
||||
foreach ($key in $PSBoundParameters.Keys) {
|
||||
if ($key -notlike 'vpgGroup' -or $key -notlike 'vmName') {
|
||||
$body[$key] = $PSBoundParameters['key']
|
||||
}
|
||||
$vpgId = $(Get-ZertoVpg -name $vpgName).vpgIdentifier
|
||||
if ( -not $vpgId) {
|
||||
Write-Error "VPG: $vpgName Not Found. Please check the name and try again!" -ErrorAction Stop
|
||||
}
|
||||
if ($PSBoundParameters.ContainsKey('vmName')) {
|
||||
$vmIdentifiers = @()
|
||||
$vmIdentifiers = foreach ( $name in $vmName ) {
|
||||
$(Get-ZertoProtectedVm -vmName $name).vmIdentifier
|
||||
$baseUri = "vpgs/{0}/failover" -f $vpgId
|
||||
$body = @{}
|
||||
# Setup Required Defaults
|
||||
$body['commitpolicy'] = $commitPolicy
|
||||
$body['TimeToWaitBeforeShutdownInSec'] = $timeToWaitBeforeShutdownInSec
|
||||
|
||||
Switch ($PSBoundParameters.Keys) {
|
||||
"checkpointIdentifier" {
|
||||
$body['checkpointIdentifier'] = $checkpointIdentifier
|
||||
}
|
||||
|
||||
"shutdownPolicy" {
|
||||
$body['shutdownPolicy'] = $shutdownPolicy
|
||||
}
|
||||
|
||||
"reverseProtection" {
|
||||
$body['reverseProtection'] = $reverseProtection
|
||||
}
|
||||
|
||||
"vmName" {
|
||||
$vpgVmInformation = Get-ZertoProtectedVm -vpgName $vpgName
|
||||
[System.Collections.ArrayList]$vmIdentifiers = @()
|
||||
foreach ( $name in $vmName ) {
|
||||
$selectedVm = $vpgVmInformation | Where-Object {$_.VmName.toLower() -eq $name.toLower()}
|
||||
if ($null -eq $selectedVm) {
|
||||
Write-Error "VM: $name NOT found in VPG $vpgName. Check the name and try again." -ErrorAction Stop
|
||||
} elseif ($vmIdentifiers.Contains($selectedVm.vmIdentifier.toString())) {
|
||||
Write-Error "VM: $($selectedVm.VmName) specified more than once. Please check parameters and try again." -ErrorAction Stop
|
||||
} else {
|
||||
$vmIdentifiers.Add($selectedVm.vmIdentifier.toString()) | Out-Null
|
||||
}
|
||||
}
|
||||
$body['VmIdentifiers'] = $vmIdentifiers
|
||||
}
|
||||
$body['VmIdentifiers'] = $vmIdentifiers
|
||||
}
|
||||
}
|
||||
|
||||
process {
|
||||
Invoke-ZertoRestRequest -uri $baseUri -body $($body | ConvertTo-Json) -method "POST"
|
||||
if ($PSCmdlet.ShouldProcess("$vpgName with identifier $vpgId and these options $($body | convertto-json)")) {
|
||||
Invoke-ZertoRestRequest -uri $baseUri -body $($body | ConvertTo-Json) -method "POST"
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
|
||||
@@ -1,36 +1,43 @@
|
||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||
function Invoke-ZertoFailoverCommit {
|
||||
[cmdletbinding()]
|
||||
[cmdletbinding( SupportsShouldProcess = $true )]
|
||||
param(
|
||||
[Parameter(
|
||||
HelpMessage = "Name(s) of the VPG(s) to commit.",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string[]]$vpgName,
|
||||
[Parameter(
|
||||
HelpMessage = "Use this switch to reverse protect the VPG(s) to the source site."
|
||||
)]
|
||||
[switch]$reverseProtect
|
||||
[switch]$reverseProtection
|
||||
)
|
||||
|
||||
begin {
|
||||
$baseUri = "vpgs"
|
||||
if ( $reverseProtect ) {
|
||||
$body = @{"IsReverseProtect" = $true}
|
||||
} else {
|
||||
$body = @{"IsReverseProtect" = $false}
|
||||
}
|
||||
}
|
||||
|
||||
process {
|
||||
if ( $reverseProtection.IsPresent ) {
|
||||
$body = @{"IsReverseProtection" = $true }
|
||||
} else {
|
||||
$body = @{"IsReverseProtection" = $false }
|
||||
}
|
||||
foreach ($name in $vpgName) {
|
||||
$vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier
|
||||
$uri = "{0}/{1}/FailoverCommit" -f $baseUri, $vpgId
|
||||
Invoke-ZertoRestRequest -uri $uri -body $($body | convertto-json) -method "POST"
|
||||
if ( -not $vpgId ) {
|
||||
Write-Error "VPG: $name could not be found. Please check the name and try again. Skipping."
|
||||
} else {
|
||||
$uri = "{0}/{1}/FailoverCommit" -f $baseUri, $vpgId
|
||||
if ($PSCmdlet.ShouldProcess($body, $uri)) {
|
||||
Invoke-ZertoRestRequest -uri $uri -body $($body | convertto-json) -method "POST"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
# Nothing to do
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ function Invoke-ZertoFailoverRollback {
|
||||
HelpMessage = "Name(s) of VPG(s) to roll back from failing over",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string[]]$vpgName
|
||||
)
|
||||
|
||||
@@ -16,8 +17,12 @@ function Invoke-ZertoFailoverRollback {
|
||||
process {
|
||||
foreach ($name in $vpgName) {
|
||||
$vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier
|
||||
$uri = "{0}/{1}/FailoverRollback" -f $baseUri, $vpgId
|
||||
Invoke-ZertoRestRequest -uri $uri -method "POST"
|
||||
if ( -not $vpgId ) {
|
||||
Write-Error "VPG: $name not found. Please check the name and try again. Skipping"
|
||||
} else {
|
||||
$uri = "{0}/{1}/FailoverRollback" -f $baseUri, $vpgId
|
||||
Invoke-ZertoRestRequest -uri $uri -method "POST"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ function Invoke-ZertoForceSync {
|
||||
HelpMessage = "Name(s) of VPG(s) to force sync",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string[]]$vpgName
|
||||
)
|
||||
|
||||
@@ -16,8 +17,12 @@ function Invoke-ZertoForceSync {
|
||||
process {
|
||||
foreach ($name in $vpgName) {
|
||||
$id = $(Get-ZertoVpg -name $name).vpgIdentifier
|
||||
$uri = "{0}/{1}/forcesync" -f $baseUri, $id
|
||||
Invoke-ZertoRestRequest -uri $uri -method "POST"
|
||||
if ( -not $id ) {
|
||||
Write-Error "VPG: $name not found. Please check the name and try again. Skipping"
|
||||
} else {
|
||||
$uri = "{0}/{1}/forcesync" -f $baseUri, $id
|
||||
Invoke-ZertoRestRequest -uri $uri -method "POST"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,50 +1,53 @@
|
||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||
function Invoke-ZertoMove {
|
||||
[CmdletBinding()]
|
||||
[CmdletBinding( DefaultParameterSetName = "main", SupportsShouldProcess = $true )]
|
||||
param(
|
||||
[Parameter(
|
||||
HelpMessage = "Name(s) of the VPG(s) you want to move.",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string[]]$vpgName,
|
||||
[Parameter(
|
||||
HelpMessage = "The policy to use after the move enters a 'Before Commit' state. If omitted, the site settings default will be applied. Valid values are: '0' or 'Rollback', '1' or 'Commit', '2' or 'None'. Please see Zerto API Documentation for additional information."
|
||||
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."
|
||||
)]
|
||||
[ValidateSet("Rollback", "Commit", "None")]
|
||||
[string]$commitPolicy,
|
||||
[Parameter(
|
||||
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."
|
||||
)]
|
||||
[Int32]$commitPolicyTimeout,
|
||||
# Min 5 Minutes, Max 24 Hours, Default 1 Hour.
|
||||
[ValidateRange(300, 86400)]
|
||||
[Int]$commitPolicyTimeout,
|
||||
[Parameter(
|
||||
HelpMessage = "False: If a utility (VMware Tools) is installed on the protected virtual machines, the procedure waits five minutes for the virtual machines to be gracefully shut down before forcibly powering them off.
|
||||
True: To force a shutdown of the virtual machines.
|
||||
Default: True"
|
||||
HelpMessage = "If this switch is specified, Zerto will attempt to gracefully shut down the Virtual Machines. If the machines do not poweroff within 5 minutes, they will be forcibly powering them off."
|
||||
)]
|
||||
[bool]$forceShutdown,
|
||||
[switch]$forceShutdown,
|
||||
[Parameter(
|
||||
HelpMessage = "False: 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.
|
||||
True: Enable reverse protection. The virtual machines are recovered on the recovery site and then protected using the default reverse protection settings.
|
||||
Default Value: True
|
||||
Note: If ReverseProtection is set to True, the KeepSourceVMs should be ignored because the virtual disks of the VMs are used for replication and cannot have VMs attached."
|
||||
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.",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[bool]$reverseProtection = $false,
|
||||
[switch]$disableReverseProtection,
|
||||
[Parameter(
|
||||
HelpMessage = "False: Remove the protected virtual machines from the protected site.
|
||||
True: Prevent the protected virtual machines from being deleted in the protected site.
|
||||
Default: False"
|
||||
ParameterSetName = "keepSourceVms",
|
||||
HelpMessage = "Prevent the protected virtual machines from being deleted in the protected site. Using this setting disables reverse protection.",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[bool]$keepSourceVms = $false,
|
||||
[switch]$keepSourceVms,
|
||||
[Parameter(
|
||||
HelpMessage = "False: Do not continue the Move operation in case of failure of script executing prior the operation.
|
||||
True: Continue the Move operation in case of failure of script executing prior the operation.
|
||||
Default: False"
|
||||
HelpMessage = "Continue the Move operation in case of failure of script executing prior the operation. If this switch is not set a failure of the script executing prior to the operation will cause the operation to fail."
|
||||
)]
|
||||
[bool]$continueOnPreScriptFailure
|
||||
[switch]$ContinueOnPreScriptFailure
|
||||
)
|
||||
|
||||
begin {
|
||||
$baseUri = "vpgs"
|
||||
$body = [ordered]@{}
|
||||
#TODO - use a foreach loop to populate the body without all the if statments
|
||||
if ($PSBoundParameters.ContainsKey('commitPolicy')) {
|
||||
$body['commitPolicy'] = $commitPolicy
|
||||
}
|
||||
@@ -52,28 +55,48 @@ function Invoke-ZertoMove {
|
||||
$body['commitPolicyTimeout'] = $commitPolicyTimeout
|
||||
}
|
||||
if ($PSBoundParameters.ContainsKey('forceShutdown')) {
|
||||
$body['forceShutdown'] = $forceShutdown
|
||||
$body['forceShutdown'] = $true
|
||||
} else {
|
||||
$body['forceShutdown'] = $false
|
||||
}
|
||||
if ($PSBoundParameters.ContainsKey('reverseProtection')) {
|
||||
$body['reverseProtection'] = $reverseProtection
|
||||
if ($PSBoundParameters.ContainsKey('ContinueOnPreScriptFailure')) {
|
||||
$body['ContinueOnPreScriptFailure'] = $true
|
||||
} else {
|
||||
$body['ContinueOnPreScriptFailure'] = $false
|
||||
}
|
||||
if ($PSBoundParameters.ContainsKey('keepSourceVms')) {
|
||||
$body['keepSourceVms'] = $keepSourceVms
|
||||
}
|
||||
if ($PSBoundParameters.ContainsKey('continueOnPreScriptFail')) {
|
||||
$body['continueOnPreScriptFail'] = $continueOnPreScriptFailure
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
"disableReverseProtection" {
|
||||
$body['reverseProtection'] = $false
|
||||
$body['keepSourceVms'] = $false
|
||||
}
|
||||
|
||||
"keepSourceVms" {
|
||||
$body['reverseProtection'] = $false
|
||||
$body['keepSourceVms'] = $true
|
||||
}
|
||||
|
||||
"main" {
|
||||
$body['reverseProtection'] = $true
|
||||
$body['keepSourceVms'] = $false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
process {
|
||||
foreach ($name in $vpgName) {
|
||||
$vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier
|
||||
$uri = "{0}/{1}/move" -f $baseUri, $vpgId
|
||||
Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json)
|
||||
if ( -not $vpgId ) {
|
||||
Write-Error "VPG: $name not found. Please check the name and try again. Skipping"
|
||||
} else {
|
||||
$uri = "{0}/{1}/move" -f $baseUri, $vpgId
|
||||
if ($PSCmdlet.ShouldProcess("Moving VPG: $name wiht settings: $($body | convertto-json)")) {
|
||||
Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
# Nothing to do.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||
function Invoke-ZertoMoveCommit {
|
||||
[cmdletbinding()]
|
||||
[cmdletbinding(SupportsShouldProcess = $true)]
|
||||
param(
|
||||
[Parameter(
|
||||
HelpMessage = "Name(s) of the VPG(s) to commit.",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string[]]$vpgName,
|
||||
[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"
|
||||
)]
|
||||
[bool]$reverseProtect,
|
||||
[switch]$reverseProtection,
|
||||
[Parameter(
|
||||
HelpMessage = "Use this switch to keep the source VMs. If not set, they will be destroyed."
|
||||
)]
|
||||
@@ -19,22 +20,29 @@ function Invoke-ZertoMoveCommit {
|
||||
|
||||
begin {
|
||||
$baseUri = "vpgs"
|
||||
if ($reverseProtect) {
|
||||
$body = @{"ReverseProtection" = $reverseProtect; "KeepSourceVms" = $keepSourceVms}
|
||||
} else {
|
||||
$body = @{"KeepSourceVms" = $keepSourceVms}
|
||||
$body = @{}
|
||||
if ($reverseProtection) {
|
||||
$body["ReverseProtection"] = $true
|
||||
} elseif ($keepSourceVms) {
|
||||
$body["KeepSourceVms"] = $true
|
||||
}
|
||||
}
|
||||
|
||||
process {
|
||||
foreach ($name in $vpgName) {
|
||||
$vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier
|
||||
$uri = "{0}/{1}/MoveCommit" -f $baseUri, $vpgId
|
||||
Invoke-ZertoRestRequest -uri $uri -body $($body | convertto-json) -method "POST"
|
||||
if ( -not $vpgId ) {
|
||||
Write-Error "VPG: $name not found. Please check the name and try again. Skipping."
|
||||
} else {
|
||||
$uri = "{0}/{1}/MoveCommit" -f $baseUri, $vpgId
|
||||
if ($PSCmdlet.ShouldProcess("Commiting VPG: $name with settings $($body | convertto-json)")) {
|
||||
Invoke-ZertoRestRequest -uri $uri -body $($body | convertto-json) -method "POST"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
# Nothing to do
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||
function Invoke-ZertoMoveRollback {
|
||||
[cmdletbinding()]
|
||||
[cmdletbinding(SupportsShouldProcess = $true)]
|
||||
param(
|
||||
[Parameter(
|
||||
HelpMessage = "Name(s) of VPG(s) to roll back from failing over",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string[]]$vpgName
|
||||
)
|
||||
|
||||
@@ -16,8 +17,14 @@ function Invoke-ZertoMoveRollback {
|
||||
process {
|
||||
foreach ($name in $vpgName) {
|
||||
$id = $(Get-ZertoVpg -name $name).vpgIdentifier
|
||||
$uri = "{0}/{1}/moveRollBack" -f $baseUri, $id
|
||||
Invoke-ZertoRestRequest -uri $uri -method "POST"
|
||||
if ( -not $id ) {
|
||||
Write-Error "VPG: $name not found. Please check the name and try again."
|
||||
} else {
|
||||
$uri = "{0}/{1}/moveRollBack" -f $baseUri, $id
|
||||
if ($PSCmdlet.ShouldProcess("Rolling back VPG: $name")) {
|
||||
Invoke-ZertoRestRequest -uri $uri -method "POST"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||
function New-ZertoVpg {
|
||||
[cmdletbinding()]
|
||||
[cmdletbinding(SupportsShouldProcess = $true)]
|
||||
param(
|
||||
[Parameter(
|
||||
HelpMessage = "Name of the VPG",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$vpgName,
|
||||
[Parameter(
|
||||
HelpMessage = "VPG Priority. High, Medium, or Low. Default value is Medium"
|
||||
@@ -21,11 +22,13 @@ function New-ZertoVpg {
|
||||
HelpMessage = "Name(s) of the VM(s) to be protected.",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()][string[]]$protectedVm,
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string[]]$protectedVm,
|
||||
[Parameter(
|
||||
HelpMessage = "Name of the site where the VM(s) will be recovered",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$recoverySite,
|
||||
[Parameter(
|
||||
HelpMessage = "Name of the cluster where the VM(s) will be recovered.",
|
||||
@@ -37,6 +40,7 @@ function New-ZertoVpg {
|
||||
ParameterSetName = "recoveryClusterDatastoreCluster",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$recoveryCluster,
|
||||
[Parameter(
|
||||
HelpMessage = "Name of the host where the VM(s) will be recovered.",
|
||||
@@ -48,6 +52,7 @@ function New-ZertoVpg {
|
||||
ParameterSetName = "recoveryHostDatastoreCluster",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$recoveryHost,
|
||||
[Parameter(
|
||||
HelpMessage = "Name of the resource pool where the VM(s) will be recovered.",
|
||||
@@ -59,6 +64,7 @@ function New-ZertoVpg {
|
||||
ParameterSetName = "recoveryResourcePoolDatastoreCluster",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$recoveryResourcePool,
|
||||
[Parameter(
|
||||
HelpMessage = "Name of the datastore where the VM(s), Volume(s), and Journal(s) will reside.",
|
||||
@@ -75,6 +81,7 @@ function New-ZertoVpg {
|
||||
ParameterSetName = "recoveryResourcePoolDatastore",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$datastore,
|
||||
[Parameter(
|
||||
HelpMessage = "Name of the datastore cluster where the VM(s), Volume(s), and Journal(s) will reside.",
|
||||
@@ -91,23 +98,28 @@ function New-ZertoVpg {
|
||||
ParameterSetName = "recoveryResourcePoolDatastoreCluster",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$datastoreCluster,
|
||||
[Parameter(
|
||||
HelpMessage = "Name of folder at recovery location where the recovered virtual machine(s) will be created.",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$recoveryFolder,
|
||||
[Parameter(
|
||||
HelpMessage = "RPO alert"
|
||||
)]
|
||||
[ValidateRange(60, 864200)][Int32]$rpoInSeconds = 300,
|
||||
[ValidateRange(60, 864200)]
|
||||
[Int32]$rpoInSeconds = 300,
|
||||
[Parameter(
|
||||
HelpMessage = "Minimum test interval for this VPG. Valid values are 0: Off, 43200: 1 Month, 131040: 3 Months, 262080: 6 Months, 294560: 9 Months, 252600: 12 Months"
|
||||
)]
|
||||
[ValidateSet(0, 43200, 131040, 262080, 294560, 252600)][int]$testIntervalInMinutes = 262080,
|
||||
[ValidateSet(0, 43200, 131040, 262080, 294560, 252600)]
|
||||
[int]$testIntervalInMinutes = 262080,
|
||||
[Parameter(
|
||||
HelpMessage = "Service profile name to use."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$serviceProfile,
|
||||
[Parameter(
|
||||
HelpMessage = "Turn on or off WAN and Journal Compression. Default is turned on."
|
||||
@@ -116,31 +128,37 @@ function New-ZertoVpg {
|
||||
[Parameter(
|
||||
HelpMessage = "Name of ZORG to use."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[String]$zorg,
|
||||
[Parameter(
|
||||
HelpMessage = "Name of the network to use during a Failover Live \ Move VPG operation.",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[String]$recoveryNetwork,
|
||||
[Parameter(
|
||||
HelpMessage = "Name of the network to use during a Failover Test operation",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$testNetwork,
|
||||
[Parameter(
|
||||
HelpMessage = "Name of the datastore to utilize to store Journal data. If not specified, the default datastore will be used.",
|
||||
Mandatory = $false
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]$journalDatastore,
|
||||
[Parameter(
|
||||
HelpMessage = "Default journal hard limit in megabytes. Default set to 153600 MB (150 GB). Set to 0 to set the journal to unlimited",
|
||||
Mandatory = $false
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[uint64]$journalHardLimitInMb = 153600,
|
||||
[Parameter(
|
||||
HelpMessage = "Default journal warning threshold in megabytes. If unset or greater than the hard limit, will be set to 75% of the journal hard limit.",
|
||||
Mandatory = $false
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[uint64]$journalWarningThresholdInMb = 0
|
||||
)
|
||||
|
||||
@@ -223,6 +241,23 @@ function New-ZertoVpg {
|
||||
if (($journalWarningThresholdInMb -eq 0) -or ($journalWarningThresholdInMb -gt $journalHardLimitInMb)) {
|
||||
$journalWarningThresholdInMb = $journalHardLimitInMb * .75
|
||||
}
|
||||
|
||||
#Validate all items in the hashtable are populated with valid data.
|
||||
$validSettings = $true
|
||||
foreach ($item in $identifiersTable.GetEnumerator()) {
|
||||
if ([String]::IsNullOrEmpty($item.value)) {
|
||||
$validSettings = $false
|
||||
Write-Error "$($item.key) is not associated with a valid identifier. Please check the submitted values and try again."
|
||||
}
|
||||
}
|
||||
if ($vmIdentifiers.count -eq 0) {
|
||||
$validSettings = $false
|
||||
Write-Error "No valid VM names were passed or all passed VMs are already protected and cannot be further protected."
|
||||
}
|
||||
|
||||
if ( -not $validSettings ) {
|
||||
Write-Error "One or more parameters passed do not have valid identifiers or 0 valid VMs were found. Please check your settings and try again." -ErrorAction Stop
|
||||
}
|
||||
}
|
||||
|
||||
process {
|
||||
@@ -292,7 +327,9 @@ function New-ZertoVpg {
|
||||
$baseSettings.Journal.Limitation.HardLimitInMB = $journalHardLimitInMb
|
||||
$baseSettings.Journal.Limitation.WarningThresholdInMB = $journalWarningThresholdInMb
|
||||
$settingsURI = "{0}/{1}" -f $baseUri, $vpgSettingsIdentifier
|
||||
Invoke-ZertoRestRequest -uri $settingsURI -body $($baseSettings | ConvertTo-Json -Depth 10) -method "PUT" | Out-Null
|
||||
if ($PSCmdlet.ShouldProcess($($baseSettings | ConvertTo-Json -Depth 10))) {
|
||||
$results = Invoke-ZertoRestRequest -uri $settingsURI -body $($baseSettings | ConvertTo-Json -Depth 10) -method "PUT"
|
||||
}
|
||||
}
|
||||
|
||||
end {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||
function New-ZertoVpgSettingsIdentifier {
|
||||
[cmdletbinding()]
|
||||
[cmdletbinding( SupportsShouldProcess = $true, DefaultParameterSetName = "newVpg" )]
|
||||
param(
|
||||
[Parameter(
|
||||
HelpMessage = "Identifier of the VPG to create a VPG settings identifier. If a vpgIdentifier is not provided, a new VPG settings object is created without any configured settings. This would be used for creating a new VPG from scratch.",
|
||||
@@ -8,7 +9,9 @@ function New-ZertoVpgSettingsIdentifier {
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true
|
||||
)]
|
||||
[string]$vpgIdentifier,
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("vpgId")]
|
||||
[string[]]$vpgIdentifier,
|
||||
[Parameter(
|
||||
HelpMessage = "Use this switch when creating a vpgSettingsIdentifier for a new VPG",
|
||||
ParameterSetName = "newVpg",
|
||||
@@ -19,22 +22,28 @@ function New-ZertoVpgSettingsIdentifier {
|
||||
|
||||
begin {
|
||||
$baseUri = "vpgSettings"
|
||||
}
|
||||
|
||||
process {
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
"newVpg" {
|
||||
$body = "{}"
|
||||
if ($PSCmdlet.ShouldProcess("Creating VPG Settings Object")) {
|
||||
Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST"
|
||||
}
|
||||
}
|
||||
|
||||
"existingVpg" {
|
||||
$body = "{""VpgIdentifier"":""$vpgIdentifier""}"
|
||||
foreach ($id in $vpgIdentifier) {
|
||||
$body = "{""VpgIdentifier"":""$id""}"
|
||||
if ($PSCmdlet.ShouldProcess("Creating VPG Settings Object")) {
|
||||
Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
process {
|
||||
Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST"
|
||||
}
|
||||
|
||||
end {
|
||||
|
||||
#Nothing to do
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||
function Remove-ZertoPeerSite {
|
||||
[cmdletbinding(
|
||||
SupportsShouldProcess = $true,
|
||||
DefaultParameterSetName = "siteIdentifier"
|
||||
)]
|
||||
param (
|
||||
[Parameter(
|
||||
HelpMessage = "Identifier of the site to be removed from the connected site",
|
||||
ParameterSetName = "siteIdentifier",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("siteId")]
|
||||
[string[]]$siteIdentifier,
|
||||
[Parameter(
|
||||
HelpMessage = "Name of the peer site to be removed from the connected site",
|
||||
ParameterSetName = "peerSiteName",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string[]]$peerSiteName,
|
||||
[Parameter(
|
||||
HelpMessage = "IP address of the peer site to be removed from the connected site",
|
||||
ParameterSetName = "hostName",
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateScript( {$_ -match [IPAddress]$_ })]
|
||||
[string[]]$hostName,
|
||||
[Parameter(
|
||||
HelpMessage = "Specify this switch to Keep the target replica disks for any VPGs replicating between the sites as the VPGs will be deleted by unpairing the sites. If this switch is not used, the target replica disks will be deleted"
|
||||
)]
|
||||
[switch]$keepTargetDisks
|
||||
)
|
||||
|
||||
begin {
|
||||
$baseUri = "peersites"
|
||||
$body = @{}
|
||||
if ( $keepTargetDisks ) {
|
||||
$body['IsKeepTargetDisks'] = $true
|
||||
} else {
|
||||
$body['IsKeepTargetDisks'] = $false
|
||||
}
|
||||
}
|
||||
|
||||
process {
|
||||
switch ( $PSCmdlet.ParameterSetName ) {
|
||||
"peerSiteName" {
|
||||
$siteIdentifier = @()
|
||||
$siteIdentifier = foreach ($site in $peerSiteName) {
|
||||
$(Get-ZertoPeerSite -peerName $site).siteIdentifier
|
||||
}
|
||||
}
|
||||
|
||||
"hostName" {
|
||||
$siteIdentifier = @()
|
||||
$siteIdentifier = foreach ($name in $hostName) {
|
||||
$(Get-ZertoPeerSite -hostName $name).siteIdentifier
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($id in $siteIdentifier) {
|
||||
$uri = "{0}/{1}" -f $baseUri, $id
|
||||
if ($PSCmdlet.ShouldProcess("Removing siteIdentifier $id")) {
|
||||
Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -Method "DELETE"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
end {
|
||||
# Nothing to do
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ function Remove-ZertoVpg {
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
HelpMessage = "Name(s) of the VPG(s) to delete."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string[]]$vpgName,
|
||||
[Parameter(
|
||||
Mandatory = $true,
|
||||
@@ -17,15 +18,17 @@ function Remove-ZertoVpg {
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
HelpMessage = "vpgIdentifier(s) of the VPG(s) to delete."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("vpgId")]
|
||||
[string[]]$vpgidentifier,
|
||||
[Parameter(
|
||||
HelpMessage = "Use this parameter to keep the recovery volumes at the target site, by setting it to True. If the virtual machines in the deleted VPG are reprotected, these volumes can be used as preseeded volumes to speed up the initial synchronization of the new VPG. Default is to remove Recovery Volumes"
|
||||
)]
|
||||
[switch]$keepRecoveryVolumes = $false,
|
||||
[switch]$keepRecoveryVolumes,
|
||||
[Parameter(
|
||||
HelpMessage = "Use this parameter to force delete the VPG, by setting this parameter equal to true."
|
||||
)]
|
||||
[switch]$force = $false
|
||||
[switch]$force
|
||||
)
|
||||
|
||||
begin {
|
||||
@@ -54,7 +57,7 @@ function Remove-ZertoVpg {
|
||||
Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -Method "DELETE"
|
||||
}
|
||||
} else {
|
||||
Write-Output "VPG with name $vpgName not found. Please check the name and try again"
|
||||
Write-Error "VPG with name $vpgName not found. Please check the name and try again"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ function Resume-ZertoVpg {
|
||||
HelpMessage = "Name(s) of VPG(s) to resume replication",
|
||||
Mandatory = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string[]]$vpgName
|
||||
)
|
||||
|
||||
@@ -16,8 +17,12 @@ function Resume-ZertoVpg {
|
||||
process {
|
||||
foreach ($name in $vpgName) {
|
||||
$id = $(Get-ZertoVpg -name $name).vpgIdentifier
|
||||
$uri = "{0}/{1}/resume" -f $baseUri, $id
|
||||
Invoke-ZertoRestRequest -uri $uri -method "POST"
|
||||
if ( -not $id ) {
|
||||
Write-Error "VPG: $name not found. Please check the name and try again. Skipping."
|
||||
} else {
|
||||
$uri = "{0}/{1}/resume" -f $baseUri, $id
|
||||
Invoke-ZertoRestRequest -uri $uri -method "POST"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -1,5 +1,5 @@
|
||||
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
|
||||
function Save-ZertoVpgSettings {
|
||||
function Save-ZertoVpgSetting {
|
||||
[cmdletbinding(
|
||||
SupportsShouldProcess = $true
|
||||
)]
|
||||
@@ -10,6 +10,8 @@ function Save-ZertoVpgSettings {
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("vpgSettingsId")]
|
||||
[string]$vpgSettingsIdentifier
|
||||
)
|
||||
|
||||
@@ -17,4 +19,4 @@ function Save-ZertoVpgSettings {
|
||||
if ($PSCmdlet.ShouldProcess("Commiting VPG Settings with Settigns identifier $vpgSettingsIdentifier")) {
|
||||
Invoke-ZertoRestRequest -uri $baseUri -method "POST"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,14 @@
|
||||
function Set-ZertoAlert {
|
||||
[cmdletbinding( SupportsShouldProcess = $true )]
|
||||
param (
|
||||
[Alias("identifier")]
|
||||
[Parameter(
|
||||
ValueFromPipeline = $true,
|
||||
ValueFromPipelineByPropertyName = $true,
|
||||
Mandatory = $true,
|
||||
HelpMessage = "Alert identifier(s) to be dismissed or undismissed."
|
||||
)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Alias("alertIdentifier", "identifier", "id")]
|
||||
[string[]]$alertId,
|
||||
[Parameter(
|
||||
ParameterSetName = "dismiss",
|
||||
@@ -40,4 +41,4 @@ function Set-ZertoAlert {
|
||||
end {
|
||||
# Nothing to do.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user