Merge pull request #28 from wcarroll/TestingBranch

Add and Update Tests, Update Failover and Move functions
This commit is contained in:
Wes Carroll
2019-04-20 09:58:13 -04:00
committed by GitHub
124 changed files with 3621 additions and 1369 deletions
+3
View File
@@ -2,3 +2,6 @@
*.zip
temp/*
Tests/Public/TestResults.xml
Tests/TestResults.xml
publish/*
CodeCoverage.xml
+6
View File
@@ -0,0 +1,6 @@
* New Feature 1
* New Feature 2
* New SubFeature 1
* What is happening???
+20 -13
View File
@@ -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
}
}
+72 -19
View File
@@ -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
}
}
+61 -18
View File
@@ -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
}
}
+175 -11
View File
@@ -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
}
#>
+34 -20
View File
@@ -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
}
}
}
+182 -18
View File
@@ -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
}
+249
View File
@@ -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
}
}
-10
View File
@@ -1,10 +0,0 @@
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
$publicFiles = Get-ChildItem "$filePath" -File
describe "External Help Present" {
foreach ($file in $publicFiles) {
it "External Help File Defined" {
Get-Content -Path $file.fullName -First 1 | should be "<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>"
}
}
}
+25 -19
View File
@@ -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[]
}
}
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+39
View File
@@ -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" {
}
}
+104 -19
View File
@@ -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
}
}
+73 -19
View File
@@ -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,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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
+15 -19
View File
@@ -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
}
}
-47
View File
@@ -1,47 +0,0 @@
$moduleName = "ZertoApiWrapper"
$moduleFileName = "ZertoApiWrapper.psm1"
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
$docsPath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests[\\\/]Public', 'docs'
$modulePath = $filePath -replace "Public", ""
Import-Module $modulePath\$moduleFileName
Describe "File Tests" {
Remove-Module $moduleName -Force
Import-Module $modulePath\$moduleFileName
$commands = Get-Command -Module $moduleName | Select-Object -ExpandProperty Name
foreach ($command in $commands) {
$externalHelpFile = "{0}/{1}.md" -f $docsPath, $command
$path = "{0}/{1}.ps1" -f $filePath, $command
context "$command File Tests" {
it "$command is backed by a file with the same name" {
$path | should exist
}
it "$command file has openbraces on the same line as the statement" {
$content = Get-Content -Path $path
$openingBracesExist = $content | 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
}
it "$command has an external help file" {
$externalHelpFile | should exist
}
it "$command has the External Help File Defined" {
Get-Content -Path $path -First 1 | should be "<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>"
}
it "$command external Help file is filled out" {
$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
}
}
}
}
+112
View File
@@ -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
}
}
}
}
+5 -6
View File
@@ -1,5 +1,5 @@
@{
psake = @{
InvokeBuild = @{
Name = 'InvokeBuild'
DependencyType = 'PSGalleryModule'
Parameters = @{
@@ -7,7 +7,7 @@
SkipPublisherCheck = $true
}
Target = 'CurrentUser'
Version = '5.4.3'
Version = '5.5.1'
Tags = 'Bootstrap'
}
@@ -19,7 +19,7 @@
SkipPublisherCheck = $true
}
Target = 'CurrentUser'
Version = '4.6.0'
Version = '4.7.3'
Tags = 'Bootstrap'
}
@@ -31,7 +31,7 @@
SkipPublisherCheck = $true
}
Target = 'CurrentUser'
Version = '1.17.1'
Version = '1.18.0'
Tags = 'Bootstrap'
}
@@ -43,8 +43,7 @@
SkipPublisherCheck = $true
}
Target = 'CurrentUser'
Version = '0.12.0'
Version = '0.14.0'
Tags = 'Bootstrap'
}
}
+43 -14
View File
@@ -7,12 +7,9 @@
param([switch]$Install,
[string]$Configuration = (property Configuration Release))
$targetDir = "temp/$Configuration/ZertoApiWrapper" #>
$version = "{0}.{1}" -f $(Get-Content .\version.txt), $(get-date -format 'yyyyMMdd')
$versionMajor = '0'
$versionMinor = '1'
$versionBuild = "{0}" -f $(get-date -format 'yyyyMMdd')
task . AnalyzeSourceFiles, CreateModule
task . CreateArtifacts
<# Synopsis: Ensure platyPS is installed #>
task CheckPlatyPSInstalled {
@@ -51,13 +48,13 @@ task AnalyzeSourceFiles CheckPSScriptAnalyzerInstalled, {
}
}
task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, {
task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, CreatePsm1ForRelease, {
$scriptAnalyzerParams = @{
Path = "$BuildRoot\temp\"
Severity = @('Error', 'Warning')
Recurse = $true
Verbose = $false
ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments', 'PSUseShouldProcessForStateChangingFunctions', 'PSUseToExportFieldsInManifest')
ExcludeRule = @()
}
$saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams
@@ -68,8 +65,8 @@ task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, {
}
task FileTests CheckPesterInstalled, {
$testResultsFile = "$BuildRoot\Tests\Public\TestResults.xml"
$script:results = Invoke-Pester -Script "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -OutputFile $testResultsFile -PassThru
$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
}
@@ -94,10 +91,12 @@ task UpdateMarkdownHelp CheckPlatyPSInstalled, {
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 = '{0}.{1}.{2}' -f $versionMajor, $versionMinor, $versionBuild
ModuleVersion = $version
GUID = '4c0b9e17-141b-4dd5-8549-fb21cccaa325'
Author = 'Wes Carroll'
CompanyName = 'Zerto'
@@ -111,6 +110,7 @@ task CreatePsd1ForRelease CleanTemp, {
CmdletsToExport = @()
VariablesToExport = @()
AliasesToExport = @()
ReleaseNotes = $releaseNotes
}
New-ModuleManifest @ManifestParams
}
@@ -126,8 +126,19 @@ task CreatePsm1ForRelease CreatePsd1ForRelease, {
$emptyLine = ""
$psm1Path = "$BuildRoot\temp\ZertoApiWrapper.psm1"
$lines = '#------------------------------------------------------------#'
$Public = @( Get-ChildItem -Path $PSScriptRoot\ZertoApiWrapper\Public\*.ps1 -ErrorAction SilentlyContinue )
$Private = @( Get-ChildItem -Path $PSScriptRoot\ZertoApiWrapper\Private\*.ps1 -ErrorAction SilentlyContinue )
$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
@@ -144,9 +155,27 @@ task CreatePsm1ForRelease CreatePsd1ForRelease, {
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 CreateModule CleanTemp, FileTests, CreatePsd1ForRelease, CreatePsm1ForRelease, AnalyzeBuiltFiles, BuildMamlHelp, {
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, {
}
+73
View File
@@ -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'
}
+3 -1
View File
@@ -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,6 +1,7 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Connect-ZertoServer {
[cmdletbinding()]
[OutputType([hashtable])]
param(
[Parameter(
Mandatory = $true,
@@ -12,14 +13,15 @@ function Connect-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
)
@@ -37,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
+10 -1
View File
@@ -6,11 +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",
@@ -36,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 {
@@ -49,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 {
@@ -68,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)")) {
@@ -79,3 +87,4 @@ function Edit-ZertoVra {
# Nothing to Do
}
}
#TODO: Refactor
+9 -4
View File
@@ -6,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
)
@@ -31,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,45 +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",
@@ -7,6 +7,7 @@ function Get-ZertoDatastore {
ParameterSetName = "datastoreIdentifier",
HelpMessage = "datastoreIdentifier or array of datastoreIdentifiers to be queried"
)]
[ValidateNotNullOrEmpty()]
[string[]]$datastoreIdentifier
)
+14 -2
View File
@@ -6,43 +6,51 @@ 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(
@@ -55,12 +63,13 @@ function Get-ZertoEvent {
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: 'All', 'Events', 'Alerts'"
)]
[ValidateNotNullOrEmpty()]
[string]$category,
[Parameter(
ParameterSetName = "filter",
@@ -72,6 +81,7 @@ function Get-ZertoEvent {
ParameterSetName = "filter",
HelpMessage = "The internal alert identifier for the Event"
)]
[ValidateNotNullOrEmpty()]
[Alias("alertId")]
[string]$alertIdentifier,
[Parameter(
@@ -79,7 +89,9 @@ function Get-ZertoEvent {
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,7 @@ 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(
@@ -26,21 +27,25 @@ 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
)
@@ -9,32 +9,38 @@ 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",
@@ -46,22 +52,26 @@ function Get-ZertoProtectedVm {
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,31 +6,37 @@ 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",
@@ -42,6 +48,7 @@ function Get-ZertoRecoveryReport {
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,12 +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
View File
@@ -6,6 +6,7 @@ function Get-ZertoTask {
ParameterSetName = "taskIdentifier",
HelpMessage = "The identifier(s) for which task information is to be returned."
)]
[ValidateNotNullOrEmpty()]
[Alias("taskId")]
[string[]]$taskIdentifier,
[Parameter(
@@ -17,26 +18,31 @@ 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",
@@ -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,7 @@ function Get-ZertoVirtualizationSite {
Mandatory = $true,
HelpMessage = "The identifier of the Zerto Virtual Manager site."
)]
[ValidateNotNullOrEmpty()]
[Alias("siteId")]
[string]$siteIdentifier,
[Parameter(
@@ -82,6 +83,7 @@ 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(
@@ -6,29 +6,34 @@ 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
)
+16 -3
View File
@@ -17,6 +17,7 @@ function Get-ZertoVpg {
Mandatory = $true,
HelpMessage = "The identifier(s) of the Virtual Protection Group to return"
)]
[ValidateNotNullOrEmpty()]
[Alias("vpgId", "protectionGroupId", "pgId")]
[string[]]$protectionGroupIdentifier,
[Parameter(
@@ -29,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,
@@ -86,47 +89,56 @@ 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",
@@ -138,6 +150,7 @@ function Get-ZertoVpg {
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",
@@ -173,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
@@ -131,6 +131,7 @@ function Get-ZertoVpgSetting {
Mandatory = $true,
HelpMessage = "The identifier of the VPG settings object for which information is retrieved."
)]
[ValidateNotNullOrEmpty()]
[Alias("vpgSettingsId", "settingsId")]
[string]$vpgSettingsIdentifier,
[Parameter(
@@ -230,6 +231,7 @@ function Get-ZertoVpgSetting {
Mandatory = $true,
HelpMessage = "VM Identifier"
)]
[ValidateNotNullOrEmpty()]
[Alias("vmId")]
[string]$vmIdentifier,
[Parameter(
@@ -243,6 +245,7 @@ function Get-ZertoVpgSetting {
Mandatory = $true,
HelpMessage = "Return NIC information for specified NIC of the specified VM"
)]
[ValidateNotNullOrEmpty()]
[Alias("nicId")]
[string]$nicIdentifier,
[Parameter(
@@ -256,6 +259,7 @@ function Get-ZertoVpgSetting {
Mandatory = $true,
HelpMessage = "Return volume information for the specified volume of the specified VM"
)]
[ValidateNotNullOrEmpty()]
[Alias("volumeId")]
[string]$volumeIdentifier
)
+11 -1
View File
@@ -18,52 +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
)
@@ -84,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
+1
View File
@@ -6,6 +6,7 @@ function Get-ZertoZorg {
ParameterSetName = "zorgIdentifier",
HelpMessage = "Identifier(s) of the ZORG."
)]
[ValidateNotNullOrEmpty()]
[Alias("zorgId")]
[string[]]$zorgIdentifier
)
@@ -6,6 +6,7 @@ function Get-ZertoZsspSession {
ParameterSetName = "zsspSessionIdentifier",
HelpMessage = "ZSSP Session Id(s) to get information."
)]
[ValidateNotNullOrEmpty()]
[Alias("zsspSessionId")]
[string[]]$zsspSessionIdentifier
)
@@ -8,6 +8,7 @@ function Import-ZertoVpg {
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true
)]
[ValidateNotNullOrEmpty()]
[Alias("FullName")]
[string[]]$settingsFile
)
+5 -1
View File
@@ -1,18 +1,22 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
#TODO - Add ability to installed with root password.
#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,
+52 -24
View File
@@ -1,16 +1,19 @@
<# .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 = "'Rollback': After the seconds specified in the commitValue setting have elapsed, the failover is rolled back.
@@ -19,22 +22,20 @@ function Invoke-ZertoFailover {
Default is the Site Settings setting."
)]
[ValidateSet("Rollback", "Commit", "None")]
[string]$commitPolicy,
[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."
@@ -43,29 +44,56 @@ function Invoke-ZertoFailover {
[Parameter(
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 {
@@ -6,31 +6,36 @@ function Invoke-ZertoFailoverCommit {
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}
if ( $reverseProtection ) {
$body = @{"IsReverseProtection" = $true}
} else {
$body = @{"IsReverseProtect" = $false}
$body = @{"IsReverseProtection" = $false}
}
}
process {
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
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"
}
}
}
+48 -29
View File
@@ -1,11 +1,12 @@
<# .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 = "'Rollback': After the seconds specified in the commitValue setting have elapsed, the failover is rolled back.
@@ -18,37 +19,35 @@ function Invoke-ZertoMove {
[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
}
@@ -56,24 +55,44 @@ 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)
}
}
}
}
@@ -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"
}
}
}
}
+16 -2
View File
@@ -6,6 +6,7 @@ function New-ZertoVpg {
HelpMessage = "Name of the VPG",
Mandatory = $true
)]
[ValidateNotNullOrEmpty()]
[string]$vpgName,
[Parameter(
HelpMessage = "VPG Priority. High, Medium, or Low. Default value is Medium"
@@ -27,6 +28,7 @@ function New-ZertoVpg {
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.",
@@ -38,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.",
@@ -49,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.",
@@ -60,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.",
@@ -76,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.",
@@ -92,11 +98,13 @@ 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"
@@ -111,6 +119,7 @@ function New-ZertoVpg {
[Parameter(
HelpMessage = "Service profile name to use."
)]
[ValidateNotNullOrEmpty()]
[string]$serviceProfile,
[Parameter(
HelpMessage = "Turn on or off WAN and Journal Compression. Default is turned on."
@@ -119,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
)
@@ -241,8 +256,7 @@ function New-ZertoVpg {
}
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."
Break
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
}
}
@@ -1,6 +1,6 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function New-ZertoVpgSettingsIdentifier {
[cmdletbinding()]
[cmdletbinding( SupportsShouldProcess = $true )]
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.",
@@ -9,6 +9,7 @@ function New-ZertoVpgSettingsIdentifier {
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true
)]
[ValidateNotNullOrEmpty()]
[Alias("vpgId")]
[string]$vpgIdentifier,
[Parameter(
@@ -33,10 +34,12 @@ function New-ZertoVpgSettingsIdentifier {
}
process {
Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST"
if ($PSCmdlet.ShouldProcess("Creating VPG Settings Object")) {
Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST"
}
}
end {
#Nothing to do
}
}
@@ -12,6 +12,7 @@ function Remove-ZertoPeerSite {
ValueFromPipelineByPropertyName = $true,
Mandatory = $true
)]
[ValidateNotNullOrEmpty()]
[Alias("siteId")]
[string[]]$siteIdentifier,
[Parameter(
@@ -21,6 +22,7 @@ function Remove-ZertoPeerSite {
ValueFromPipelineByPropertyName = $true,
Mandatory = $true
)]
[ValidateNotNullOrEmpty()]
[string[]]$peerSiteName,
[Parameter(
HelpMessage = "IP address of the peer site to be removed from the connected site",
+3 -1
View File
@@ -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,6 +18,7 @@ function Remove-ZertoVpg {
ValueFromPipelineByPropertyName = $true,
HelpMessage = "vpgIdentifier(s) of the VPG(s) to delete."
)]
[ValidateNotNullOrEmpty()]
[Alias("vpgId")]
[string[]]$vpgidentifier,
[Parameter(
@@ -55,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"
}
}
}
+7 -2
View File
@@ -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"
}
}
}
@@ -10,6 +10,7 @@ function Save-ZertoVpgSetting {
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true
)]
[ValidateNotNullOrEmpty()]
[Alias("vpgSettingsId")]
[string]$vpgSettingsIdentifier
)
+2 -2
View File
@@ -2,14 +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."
)]
[Alias("alertIdentifier")]
[ValidateNotNullOrEmpty()]
[Alias("alertIdentifier", "identifier", "id")]
[string[]]$alertId,
[Parameter(
ParameterSetName = "dismiss",
@@ -6,6 +6,7 @@ function Set-ZertoLicense {
Mandatory = $true,
HelpMessage = "License Key to apply to the Zerto Virtual Manager"
)]
[ValidateNotNullOrEmpty()]
[string]$licenseKey
)

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