diff --git a/.gitignore b/.gitignore index 03a576d..2f58130 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,7 @@ *.zip +temp/* +Tests/Public/TestResults.xml +Tests/TestResults.xml +publish/* +CodeCoverage.xml diff --git a/LICENSE b/LICENSE index f288702..44122ce 100644 --- a/LICENSE +++ b/LICENSE @@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - - Copyright (C) + ZertoApiWrapper + Copyright (C) 2019 Wes Carroll This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - Copyright (C) + ZertoApiWrapper Copyright (C) 2019 Wes Carroll This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. diff --git a/README.md b/README.md index 6508ec2..0fa3a9a 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,11 @@ PowerShell Core wrapper for Zerto Virtual Manager API +## Current Build Status + +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/0e31e5cdad534271ac688a82cc3ca17d)](https://app.codacy.com/app/wcarroll/ZertoApiWrapper?utm_source=github.com&utm_medium=referral&utm_content=wcarroll/ZertoApiWrapper&utm_campaign=Badge_Grade_Settings) +[![Build Status](https://dev.azure.com/wescarroll/ZertoApiWrapper/_apis/build/status/wcarroll.ZertoApiWrapper?branchName=master)](https://dev.azure.com/wescarroll/ZertoApiWrapper/_build/latest?definitionId=1&branchName=master) + ## Legal Disclaimer This script is an example script and is not supported under any Zerto support program or service. The author and Zerto further disclaim all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. diff --git a/RELEASENOTES.md b/RELEASENOTES.md new file mode 100644 index 0000000..cfd8e79 --- /dev/null +++ b/RELEASENOTES.md @@ -0,0 +1,6 @@ + + +* New Feature 1 +* New Feature 2 + * New SubFeature 1 +* What is happening??? diff --git a/Tests/Private/Get-ZertoApiFilter.Tests.ps1 b/Tests/Private/Get-ZertoApiFilter.Tests.ps1 index c70178f..92af238 100644 --- a/Tests/Private/Get-ZertoApiFilter.Tests.ps1 +++ b/Tests/Private/Get-ZertoApiFilter.Tests.ps1 @@ -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 } diff --git a/Tests/Private/Invoke-ZertoRestRequest.Tests.ps1 b/Tests/Private/Invoke-ZertoRestRequest.Tests.ps1 new file mode 100644 index 0000000..984d682 --- /dev/null +++ b/Tests/Private/Invoke-ZertoRestRequest.Tests.ps1 @@ -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 + } +} \ No newline at end of file diff --git a/Tests/Public/Add-ZertoPeerSite.Tests.ps1 b/Tests/Public/Add-ZertoPeerSite.Tests.ps1 index 2d8dbc5..a55ee59 100644 --- a/Tests/Public/Add-ZertoPeerSite.Tests.ps1 +++ b/Tests/Public/Add-ZertoPeerSite.Tests.ps1 @@ -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\(.+\)' + } } -} \ No newline at end of file + + 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 + } +} + diff --git a/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 b/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 index 2d8dbc5..f07f347 100644 --- a/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Connect-ZertoServer.Tests.ps1 b/Tests/Public/Connect-ZertoServer.Tests.ps1 index c55a46f..59c5e8b 100644 --- a/Tests/Public/Connect-ZertoServer.Tests.ps1 +++ b/Tests/Public/Connect-ZertoServer.Tests.ps1 @@ -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 } + #> diff --git a/Tests/Public/Disconnect-ZertoServer.Tests.ps1 b/Tests/Public/Disconnect-ZertoServer.Tests.ps1 index 2d8dbc5..5be178d 100644 --- a/Tests/Public/Disconnect-ZertoServer.Tests.ps1 +++ b/Tests/Public/Disconnect-ZertoServer.Tests.ps1 @@ -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 { + } -} \ No newline at end of file + + 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 + } + } +} diff --git a/Tests/Public/Edit-ZertoVra.Tests.ps1 b/Tests/Public/Edit-ZertoVra.Tests.ps1 index 2d8dbc5..4026b3d 100644 --- a/Tests/Public/Edit-ZertoVra.Tests.ps1 +++ b/Tests/Public/Edit-ZertoVra.Tests.ps1 @@ -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 " 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 } \ No newline at end of file diff --git a/Tests/Public/Export-ZertoVpg.Tests.ps1 b/Tests/Public/Export-ZertoVpg.Tests.ps1 new file mode 100644 index 0000000..e46b59e --- /dev/null +++ b/Tests/Public/Export-ZertoVpg.Tests.ps1 @@ -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 + } +} diff --git a/Tests/Public/Get-ZertoAlert.Tests.ps1 b/Tests/Public/Get-ZertoAlert.Tests.ps1 index 2d8dbc5..1367839 100644 --- a/Tests/Public/Get-ZertoAlert.Tests.ps1 +++ b/Tests/Public/Get-ZertoAlert.Tests.ps1 @@ -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[] + } + } -} \ No newline at end of file + +} + diff --git a/Tests/Public/Get-ZertoDatastore.Tests.ps1 b/Tests/Public/Get-ZertoDatastore.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Get-ZertoDatastore.Tests.ps1 +++ b/Tests/Public/Get-ZertoDatastore.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Get-ZertoEvent.Tests.ps1 b/Tests/Public/Get-ZertoEvent.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Get-ZertoEvent.Tests.ps1 +++ b/Tests/Public/Get-ZertoEvent.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Get-ZertoLicense.Tests.ps1 b/Tests/Public/Get-ZertoLicense.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Get-ZertoLicense.Tests.ps1 +++ b/Tests/Public/Get-ZertoLicense.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Get-ZertoLocalSite.Tests.ps1 b/Tests/Public/Get-ZertoLocalSite.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Get-ZertoLocalSite.Tests.ps1 +++ b/Tests/Public/Get-ZertoLocalSite.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Get-ZertoPeerSite.Tests.ps1 b/Tests/Public/Get-ZertoPeerSite.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Get-ZertoPeerSite.Tests.ps1 +++ b/Tests/Public/Get-ZertoPeerSite.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Get-ZertoProtectedVm.Tests.ps1 b/Tests/Public/Get-ZertoProtectedVm.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Get-ZertoProtectedVm.Tests.ps1 +++ b/Tests/Public/Get-ZertoProtectedVm.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Get-ZertoRecoveryReport.Tests.ps1 b/Tests/Public/Get-ZertoRecoveryReport.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Get-ZertoRecoveryReport.Tests.ps1 +++ b/Tests/Public/Get-ZertoRecoveryReport.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Get-ZertoResourcesReport.Tests.ps1 b/Tests/Public/Get-ZertoResourcesReport.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Get-ZertoResourcesReport.Tests.ps1 +++ b/Tests/Public/Get-ZertoResourcesReport.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Get-ZertoServiceProfile.Tests.ps1 b/Tests/Public/Get-ZertoServiceProfile.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Get-ZertoServiceProfile.Tests.ps1 +++ b/Tests/Public/Get-ZertoServiceProfile.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Get-ZertoTask.Tests.ps1 b/Tests/Public/Get-ZertoTask.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Get-ZertoTask.Tests.ps1 +++ b/Tests/Public/Get-ZertoTask.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Get-ZertoUnprotectedVm.Test.ps1 b/Tests/Public/Get-ZertoUnprotectedVm.Test.ps1 deleted file mode 100644 index 2d8dbc5..0000000 --- a/Tests/Public/Get-ZertoUnprotectedVm.Test.ps1 +++ /dev/null @@ -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 - } -} \ No newline at end of file diff --git a/Tests/Public/Get-ZertoUnprotectedVm.Tests.ps1 b/Tests/Public/Get-ZertoUnprotectedVm.Tests.ps1 new file mode 100644 index 0000000..50d2f9d --- /dev/null +++ b/Tests/Public/Get-ZertoUnprotectedVm.Tests.ps1 @@ -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 + } +} \ No newline at end of file diff --git a/Tests/Public/Get-ZertoVirtualizationSite.Tests.ps1 b/Tests/Public/Get-ZertoVirtualizationSite.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Get-ZertoVirtualizationSite.Tests.ps1 +++ b/Tests/Public/Get-ZertoVirtualizationSite.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Get-ZertoVolume.Tests.ps1 b/Tests/Public/Get-ZertoVolume.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Get-ZertoVolume.Tests.ps1 +++ b/Tests/Public/Get-ZertoVolume.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Get-ZertoVpg.Tests.ps1 b/Tests/Public/Get-ZertoVpg.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Get-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Get-ZertoVpg.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Get-ZertoVpgSetting.Tests.ps1 b/Tests/Public/Get-ZertoVpgSetting.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Get-ZertoVpgSetting.Tests.ps1 +++ b/Tests/Public/Get-ZertoVpgSetting.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Get-ZertoVra.Tests.ps1 b/Tests/Public/Get-ZertoVra.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Get-ZertoVra.Tests.ps1 +++ b/Tests/Public/Get-ZertoVra.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Get-ZertoZorg.Tests.ps1 b/Tests/Public/Get-ZertoZorg.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Get-ZertoZorg.Tests.ps1 +++ b/Tests/Public/Get-ZertoZorg.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Get-ZertoZsspSession.Tests.ps1 b/Tests/Public/Get-ZertoZsspSession.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Get-ZertoZsspSession.Tests.ps1 +++ b/Tests/Public/Get-ZertoZsspSession.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Import-ZertoVpg.Tests.ps1 b/Tests/Public/Import-ZertoVpg.Tests.ps1 new file mode 100644 index 0000000..bd91e77 --- /dev/null +++ b/Tests/Public/Import-ZertoVpg.Tests.ps1 @@ -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" { + + } +} diff --git a/Tests/Public/Install-ZertoVra.Tests.ps1 b/Tests/Public/Install-ZertoVra.Tests.ps1 index 2d8dbc5..598a6e4 100644 --- a/Tests/Public/Install-ZertoVra.Tests.ps1 +++ b/Tests/Public/Install-ZertoVra.Tests.ps1 @@ -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: " -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: " -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: " -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 + } + } -} \ No newline at end of file + + Context "$($file.BaseName)::Function Unit Tests" { + #TODO + } +} diff --git a/Tests/Public/Invoke-ZertoFailover.Tests.ps1 b/Tests/Public/Invoke-ZertoFailover.Tests.ps1 index 2d8dbc5..8582291 100644 --- a/Tests/Public/Invoke-ZertoFailover.Tests.ps1 +++ b/Tests/Public/Invoke-ZertoFailover.Tests.ps1 @@ -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\(.+\)' + } } -} \ No newline at end of file + + Context "$($file.BaseName)::Function Unit Tests" { + #TODO + } +} diff --git a/Tests/Public/Invoke-ZertoFailoverCommit.Tests.ps1 b/Tests/Public/Invoke-ZertoFailoverCommit.Tests.ps1 index 2d8dbc5..2fa2e2e 100644 --- a/Tests/Public/Invoke-ZertoFailoverCommit.Tests.ps1 +++ b/Tests/Public/Invoke-ZertoFailoverCommit.Tests.ps1 @@ -1,23 +1,44 @@ -$moduleFileName = "ZertoApiWrapper.psm1" -$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper' -$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.' -$commandName = $fileName -replace '.ps1', '' -$modulePath = $filePath -replace "Public", "" -Import-Module $modulePath\$moduleFileName -Force +#Requires -Modules Pester +$moduleFileName = "ZertoApiWrapper.psd1" +$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") +$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") +$file = Get-ChildItem "$here\$sut" +$modulePath = $here -replace "Public", "" +$moduleFile = Get-ChildItem "$modulePath\$moduleFileName" +Get-Module -Name ZertoApiWrapper | Remove-Module -Force +Import-Module $moduleFile -Force -$userName = "zerto\build" -$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force -$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password) +Describe $file.BaseName -Tag 'Unit' { -# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml -$zertoServer = "192.168.1.100" -$zertoPort = "7669" - -Describe "$commandName" { - it "file should exist" { - "$filePath\$fileName" | should exist + It "is valid Powershell (Has no script errors)" { + $contents = Get-Content -Path $file -ErrorAction Stop + $errors = $null + $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) + $errors | Should -HaveCount 0 } - it "module should have a function called $commandName" { - get-command $commandName | should be $true + + Context "$($file.BaseName)::Parameter Unit Tests" { + + it "Supports 'ShouldProcess'" { + Get-Command $file.BaseName | Should -HaveParameter WhatIf + Get-Command $file.BaseName | Should -HaveParameter Confirm + $file | Should -FileContentMatch 'SupportsShouldProcess' + $file | Should -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)' + } + + it "has a mandatory string parameter for the vpgName" { + Get-Command $file.BaseName | Should -HaveParameter vpgName + Get-Command $file.BaseName | Should -HaveParameter vpgName -Type string[] + Get-Command $file.BaseName | Should -HaveParameter vpgName -Mandatory + } + + it "has a switch parameter for reverse protection" { + Get-Command $file.BaseName | Should -HaveParameter reverseProtection + Get-Command $file.BaseName | Should -HaveParameter reverseProtection -Type switch + } } -} \ No newline at end of file + + Context "$($file.BaseName)::Function Unit Tests" { + #TODO + } +} diff --git a/Tests/Public/Invoke-ZertoFailoverRollback.Tests.ps1 b/Tests/Public/Invoke-ZertoFailoverRollback.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Invoke-ZertoFailoverRollback.Tests.ps1 +++ b/Tests/Public/Invoke-ZertoFailoverRollback.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Invoke-ZertoForceSync.Tests.ps1 b/Tests/Public/Invoke-ZertoForceSync.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Invoke-ZertoForceSync.Tests.ps1 +++ b/Tests/Public/Invoke-ZertoForceSync.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Invoke-ZertoMove.Tests.ps1 b/Tests/Public/Invoke-ZertoMove.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Invoke-ZertoMove.Tests.ps1 +++ b/Tests/Public/Invoke-ZertoMove.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Invoke-ZertoMoveCommit.Tests.ps1 b/Tests/Public/Invoke-ZertoMoveCommit.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Invoke-ZertoMoveCommit.Tests.ps1 +++ b/Tests/Public/Invoke-ZertoMoveCommit.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Invoke-ZertoMoveRollback.Tests.ps1 b/Tests/Public/Invoke-ZertoMoveRollback.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Invoke-ZertoMoveRollback.Tests.ps1 +++ b/Tests/Public/Invoke-ZertoMoveRollback.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/New-ZertoVpg.Tests.ps1 b/Tests/Public/New-ZertoVpg.Tests.ps1 new file mode 100644 index 0000000..50d2f9d --- /dev/null +++ b/Tests/Public/New-ZertoVpg.Tests.ps1 @@ -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 + } +} \ No newline at end of file diff --git a/Tests/Public/New-ZertoVpgSettingsIdentifier.Tests.ps1 b/Tests/Public/New-ZertoVpgSettingsIdentifier.Tests.ps1 new file mode 100644 index 0000000..50d2f9d --- /dev/null +++ b/Tests/Public/New-ZertoVpgSettingsIdentifier.Tests.ps1 @@ -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 + } +} \ No newline at end of file diff --git a/Tests/Public/Remove-ZertoPeerSite.Tests.ps1 b/Tests/Public/Remove-ZertoPeerSite.Tests.ps1 new file mode 100644 index 0000000..50d2f9d --- /dev/null +++ b/Tests/Public/Remove-ZertoPeerSite.Tests.ps1 @@ -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 + } +} \ No newline at end of file diff --git a/Tests/Public/Remove-ZertoVpg.Tests.ps1 b/Tests/Public/Remove-ZertoVpg.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Remove-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Remove-ZertoVpg.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Resume-ZertoVpg.Tests.ps1 b/Tests/Public/Resume-ZertoVpg.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Resume-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Resume-ZertoVpg.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Save-ZertoVpgSetting.Tests.ps1 b/Tests/Public/Save-ZertoVpgSetting.Tests.ps1 new file mode 100644 index 0000000..50d2f9d --- /dev/null +++ b/Tests/Public/Save-ZertoVpgSetting.Tests.ps1 @@ -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 + } +} \ No newline at end of file diff --git a/Tests/Public/Set-ZertoAlert.Tests.ps1 b/Tests/Public/Set-ZertoAlert.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Set-ZertoAlert.Tests.ps1 +++ b/Tests/Public/Set-ZertoAlert.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Set-ZertoLicense.Tests.ps1 b/Tests/Public/Set-ZertoLicense.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Set-ZertoLicense.Tests.ps1 +++ b/Tests/Public/Set-ZertoLicense.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Start-ZertoCloneVpg.Tests.ps1 b/Tests/Public/Start-ZertoCloneVpg.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Start-ZertoCloneVpg.Tests.ps1 +++ b/Tests/Public/Start-ZertoCloneVpg.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Start-ZertoFailoverTest.Tests.ps1 b/Tests/Public/Start-ZertoFailoverTest.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Start-ZertoFailoverTest.Tests.ps1 +++ b/Tests/Public/Start-ZertoFailoverTest.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Stop-ZertoCloneVpg.Tests.ps1 b/Tests/Public/Stop-ZertoCloneVpg.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Stop-ZertoCloneVpg.Tests.ps1 +++ b/Tests/Public/Stop-ZertoCloneVpg.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Stop-ZertoFailoverTest.Tests.ps1 b/Tests/Public/Stop-ZertoFailoverTest.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Stop-ZertoFailoverTest.Tests.ps1 +++ b/Tests/Public/Stop-ZertoFailoverTest.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Suspend-ZertoVpg.Tests.ps1 b/Tests/Public/Suspend-ZertoVpg.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Suspend-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Suspend-ZertoVpg.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/Uninstall-ZertoVra.Tests.ps1 b/Tests/Public/Uninstall-ZertoVra.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Uninstall-ZertoVra.Tests.ps1 +++ b/Tests/Public/Uninstall-ZertoVra.Tests.ps1 @@ -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 } } \ No newline at end of file diff --git a/Tests/Public/ZertoApiWrapper.Tests.ps1 b/Tests/Public/ZertoApiWrapper.Tests.ps1 deleted file mode 100644 index 529c086..0000000 --- a/Tests/Public/ZertoApiWrapper.Tests.ps1 +++ /dev/null @@ -1,23 +0,0 @@ -$moduleFileName = "ZertoApiWrapper.psm1" -$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper' -$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.' -$modulePath = $filePath -replace "Public", "" -Import-Module $modulePath\$moduleFileName -Force - -$userName = "zerto\build" -$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force -$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password) - -# $credential = Import-Clixml -Path C:\ZertoScripts\Creds.xml -$zertoServer = "192.168.1.100" -$zertoPort = "7669" - -Describe "File Tests" { - $commands = Get-Command -Module ZertoApiWrapper | Select-Object -ExpandProperty Name - foreach ($command in $commands) { - $path = "{0}/{1}.ps1" -f $filePath, $command - it "$command is backed by a file with the same name" { - $path | should exist - } - } -} \ No newline at end of file diff --git a/Tests/ZertoApiWrapper.Tests.ps1 b/Tests/ZertoApiWrapper.Tests.ps1 new file mode 100644 index 0000000..bcbb9ca --- /dev/null +++ b/Tests/ZertoApiWrapper.Tests.ps1 @@ -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 + } + } + } +} diff --git a/ZertoApiWrapper.Depend.psd1 b/ZertoApiWrapper.Depend.psd1 new file mode 100644 index 0000000..196f108 --- /dev/null +++ b/ZertoApiWrapper.Depend.psd1 @@ -0,0 +1,49 @@ +@{ + InvokeBuild = @{ + Name = 'InvokeBuild' + DependencyType = 'PSGalleryModule' + Parameters = @{ + Repository = 'PSGallery' + SkipPublisherCheck = $true + } + Target = 'CurrentUser' + Version = '5.5.1' + Tags = 'Bootstrap' + } + + Pester = @{ + Name = 'Pester' + DependencyType = 'PSGalleryModule' + Parameters = @{ + Repository = 'PSGallery' + SkipPublisherCheck = $true + } + Target = 'CurrentUser' + Version = '4.7.3' + Tags = 'Bootstrap' + } + + PSScriptAnalyzer = @{ + Name = 'PSScriptAnalyzer' + DependencyType = 'PSGalleryModule' + Parameters = @{ + Repository = 'PSGallery' + SkipPublisherCheck = $true + } + Target = 'CurrentUser' + Version = '1.18.0' + Tags = 'Bootstrap' + } + + Platyps = @{ + Name = 'Platyps' + DependencyType = 'PSGalleryModule' + Parameters = @{ + Repository = 'PSGallery' + SkipPublisherCheck = $true + } + Target = 'CurrentUser' + Version = '0.14.0' + Tags = 'Bootstrap' + } +} diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index d4f7348..9a9ad17 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -1,17 +1,60 @@ -task . InstallDependencies, Analyze +#Requires -Modules 'InvokeBuild' -task InstallDependencies { - Install-Module Pester -Force - Install-Module PSScriptAnalyzer -Force +. '.\ZertoApiWrapper.settings.ps1' +# import-module "$BuildRoot\ZertoApiWrapper\ZertoApiWrapper.psd1" -Verbose -Force + +<# [CmdletBinding()] +param([switch]$Install, + [string]$Configuration = (property Configuration Release)) +$targetDir = "temp/$Configuration/ZertoApiWrapper" #> +$version = "{0}.{1}" -f $(Get-Content .\version.txt), $(get-date -format 'yyyyMMdd') + +task . CreateArtifacts + +<# Synopsis: Ensure platyPS is installed #> +task CheckPlatyPSInstalled { + if ($null -eq (Get-Module -List platyPS)) { + Install-Module -Scope CurrentUser -Repository PSGallery -Name platyPS + } } -task Analyze { +<# Synopsis: Ensure Pester is installed #> +task CheckPesterInstalled { + if ($null -eq (Get-Module -List Pester)) { + Install-Module -Scope CurrentUser -Repository PSGallery -Name Pester + } +} + +<# Synopsis: Ensure PSScriptAnalyzer is installed #> +task CheckPSScriptAnalyzerInstalled { + if ($null -eq (Get-Module -List PSScriptAnalyzer)) { + Install-Module -Scope CurrentUser -Repository PSGallery -Name PSScriptAnalyzer + } +} + +<# Synopsis: Analyze ZertoApiWrapper functions for Code Violations #> +task AnalyzeSourceFiles CheckPSScriptAnalyzerInstalled, { $scriptAnalyzerParams = @{ Path = "$BuildRoot\ZertoApiWrapper\" Severity = @('Error', 'Warning') Recurse = $true Verbose = $false - ExcludeRule = 'PSUseDeclaredVarsMoreThanAssignments' + ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments', 'PSUseShouldProcessForStateChangingFunctions', 'PSUseToExportFieldsInManifest') + } + $saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams + if ($saResults) { + $saResults | Format-Table + throw "One or more PSScriptAnalyzer errors/warnings were found" + } +} + +task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, CreatePsm1ForRelease, { + $scriptAnalyzerParams = @{ + Path = "$BuildRoot\temp\" + Severity = @('Error', 'Warning') + Recurse = $true + Verbose = $false + ExcludeRule = @() } $saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams @@ -21,3 +64,118 @@ task Analyze { } } +task FileTests CheckPesterInstalled, { + $testResultsFile = "$BuildRoot\Tests\TestResults.xml" + $script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru + $FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount + assert ($results.FailedCount -eq 0) $FailureMessage +} + +$buildMamlParams = @{ + Inputs = { Get-ChildItem docs\*.md } + Outputs = "$BuildRoot\temp\en-us\ZertoApiWrapper-help.xml" +} + +task BuildMamlHelp CheckPlatyPSInstalled, { + if (Test-Path $buildMamlParams.Outputs) { + Remove-Item $buildMamlParams.Outputs + } + platyPS\New-ExternalHelp .\docs -Force -OutputPath $buildMamlParams.Outputs +} + +task UpdateMarkdownHelp CheckPlatyPSInstalled, { + remove-module ZertoApiWrapper -force -ErrorAction SilentlyContinue + Import-Module .\ZertoApiWrapper\ZertoApiWrapper.psm1 -Force + Update-MarkDownHelp -Path docs -AlphabeticParamsOrder +} + +task CreatePsd1ForRelease CleanTemp, { + $functionsToExport = Get-ChildItem -Path 'ZertoApiWrapper\Public\*.ps1' | ForEach-Object { $_.BaseName } + $releaseNotes = "# {0}{1}" -f $version, $(Get-Content .\RELEASENOTES.md -Raw) + + $ManifestParams = @{ + Path = "$BuildRoot\temp\ZertoApiWrapper.psd1" + RootModule = 'ZertoApiWrapper.psm1' + ModuleVersion = $version + GUID = '4c0b9e17-141b-4dd5-8549-fb21cccaa325' + Author = 'Wes Carroll' + CompanyName = 'Zerto' + Copyright = '(c) {0} Wes Carroll. All rights reserved.' -f $(Get-Date -format 'yyyy') + Description = 'PowerShell Core Wrapper Module for Zerto Virtual Manager API' + PowerShellVersion = '6.0.0' + ProjectUri = 'https://github.com/wcarroll/ZertoApiWrapper' + LicenseUri = 'https://github.com/wcarroll/ZertoApiWrapper/blob/master/LICENSE' + Tags = @("Zerto", "Automation") + FunctionsToExport = $functionsToExport + CmdletsToExport = @() + VariablesToExport = @() + AliasesToExport = @() + ReleaseNotes = $releaseNotes + } + New-ModuleManifest @ManifestParams +} + +task CleanTemp { + if (-not $(Test-Path "$BuildRoot\temp")) { + New-Item -Path $BuildRoot -Name "temp" -ItemType "Directory" + } + Remove-Item -Recurse -Path "$BuildRoot\temp\*" +} + +task CreatePsm1ForRelease CreatePsd1ForRelease, { + $emptyLine = "" + $psm1Path = "$BuildRoot\temp\ZertoApiWrapper.psm1" + $lines = '#------------------------------------------------------------#' + $Public = @( Get-ChildItem -Path $BuildRoot\ZertoApiWrapper\Public\*.ps1 -ErrorAction SilentlyContinue ) + $functionCount = 0 + $exportString = "" + foreach ($file in $Public) { + if ($functionCount -eq 0) { + $functionCount++ + $exportString = "{0}" -f $file.BaseName + } else { + $functionCount++ + $exportString = "{0}, {1}" -f $exportString, $file.BaseName + } + } + $Private = @( Get-ChildItem -Path $BuildRoot\ZertoApiWrapper\Private\*.ps1 -ErrorAction SilentlyContinue ) + Add-Content -Path $psm1Path -Value $lines + Add-Content -Path $psm1Path -Value "#---------------------Private Functions----------------------#" + Add-Content -Path $psm1Path -Value $lines + Add-Content -Path $psm1Path -Value $emptyLine + foreach ($file in $private) { + Add-Content -Path $psm1Path -Value $(Get-Content -Path $file.Fullname -Raw) + Add-Content -Path $psm1Path -Value $emptyLine + } + Add-Content -Path $psm1Path -Value $lines + Add-Content -Path $psm1Path -Value "#----------------------Public Functions----------------------#" + Add-Content -Path $psm1Path -Value $lines + Add-Content -Path $psm1Path -Value $emptyLine + foreach ($file in $public) { + Add-Content -Path $psm1Path -Value $(Get-Content -Path $file.Fullname -Raw) + Add-Content -Path $psm1Path -Value $emptyLine + } + Add-Content -Path $psm1Path -Value $emptyLine + Add-Content -Path $psm1Path -Value "Export-ModuleMember -Function $exportString" +} + +task CreateArtifacts CleanPublish, CreateModule, { + if (-not $(Test-Path "$BuildRoot\publish")) { + New-Item -Path $BuildRoot -Name "publish" -ItemType Directory + } + Compress-Archive -Path .\temp\* -DestinationPath .\publish\ZertoApiWrapper.zip + Get-Module -Name ZertoApiWrapper | Remove-Module -Force + Import-Module .\temp\ZertoApiWrapper.psd1 -Force + (Get-Module ZertoApiWrapper).ReleaseNotes | Add-Content .\publish\release-notes.txt + (Get-Module ZertoApiWrapper).Version.ToString() | Add-Content .\publish\release-version.txt +} + +task CleanPublish { + if ($(Test-Path "$BuildRoot\publish")) { + Remove-Item -Recurse -Path "$BuildRoot\publish\*" + } +} + +task CreateModule CleanTemp, FileTests, AnalyzeBuiltFiles, BuildMamlHelp, { + +} diff --git a/ZertoApiWrapper.settings.ps1 b/ZertoApiWrapper.settings.ps1 index e69de29..2d56eae 100644 --- a/ZertoApiWrapper.settings.ps1 +++ b/ZertoApiWrapper.settings.ps1 @@ -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'(?\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' +} diff --git a/ZertoApiWrapper/Public/Add-ZertoPeerSite.ps1 b/ZertoApiWrapper/Public/Add-ZertoPeerSite.ps1 index 272fb2a..ecf104e 100644 --- a/ZertoApiWrapper/Public/Add-ZertoPeerSite.ps1 +++ b/ZertoApiWrapper/Public/Add-ZertoPeerSite.ps1 @@ -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 } -} \ No newline at end of file +} diff --git a/ZertoApiWrapper/Public/Checkpoint-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Checkpoint-ZertoVpg.ps1 index 83515b9..e8d94b7 100644 --- a/ZertoApiWrapper/Public/Checkpoint-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Checkpoint-ZertoVpg.ps1 @@ -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 ) diff --git a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 index 7cec66b..5c7b3b0 100644 --- a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 +++ b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 @@ -1,23 +1,27 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Connect-ZertoServer { [cmdletbinding()] + [OutputType([hashtable])] param( [Parameter( Mandatory = $true, HelpMessage = "IP address or FQDN of your Zerto Management Server" )] [ValidateNotNullOrEmpty()] + [Alias("server", "zvm")] [string]$zertoServer, [Parameter( HelpMessage = "Zerto Virtual Manager management port. Default value is 9669." )] + [ValidateNotNullOrEmpty()] + [ValidateRange(1024, 65535)] + [Alias("port")] [string]$zertoPort = "9669", [Parameter( Mandatory = $true, HelpMessage = "Valid credentials to connect to the Zerto Management Server" )] - [System.Management.Automation.PSCredential] - $credential, + [System.Management.Automation.PSCredential]$credential, [switch]$returnHeaders ) @@ -35,7 +39,7 @@ function Connect-ZertoServer { process { # Send authorization request to the function and send back the results including headers - $results = Invoke-ZertoRestRequest -uri $uri -credential $credential -returnHeaders -body $body -method POST + $results = Invoke-ZertoRestRequest -uri $uri -credential $credential -returnHeaders -body $body -method POST -ErrorAction Stop } end { diff --git a/ZertoApiWrapper/Public/Disconnect-ZertoServer.ps1 b/ZertoApiWrapper/Public/Disconnect-ZertoServer.ps1 index b7d07ca..4559701 100644 --- a/ZertoApiWrapper/Public/Disconnect-ZertoServer.ps1 +++ b/ZertoApiWrapper/Public/Disconnect-ZertoServer.ps1 @@ -1,6 +1,7 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Disconnect-ZertoServer { [cmdletbinding()] + param() $uri = "session" # Delete API Authorization diff --git a/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 b/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 index a0ca0c4..acf1693 100644 --- a/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 @@ -6,10 +6,13 @@ function Edit-ZertoVra { Mandatory = $true, HelpMessage = "Identifier of the VRA to be updated." )] + [ValidateNotNullOrEmpty()] + [Alias("vraId")] [string]$vraIdentifier, [Parameter( HelpMessage = "Bandwidth group to assign to the VRA. If unspecified will not modify current assignment" )] + [ValidateNotNullOrEmpty()] [string]$groupName, [Parameter( ParameterSetName = "StaticIp", @@ -35,6 +38,9 @@ function Edit-ZertoVra { $baseUri = "vras/{0}" -f $vraIdentifier # Get the current VRA information for use if an updated parameter is not supplied $vra = Get-ZertoVra -vraIdentifier $vraIdentifier + if ( -not $vra ) { + Write-Error "VRA with Identifier: $vraIdentifier could not be found. Please check the ID and try again." + } } process { @@ -48,7 +54,7 @@ function Edit-ZertoVra { $vraUpdate['GroupName'] = $vra.VraGroup } # If ParameterSetName StaticIp is used, update the parameters submitted - if ( $PSCmdlet.ParameterSetName -eq 'StaticIp' ) { + if ( $PSCmdlet.ParameterSetName -eq 'StaticIp' -or $vra.VraNetworkDataApi.VraIPConfigurationTypeApi -eq "Static" ) { if ( $PSBoundParameters.ContainsKey('defaultGateway') ) { $vraNetwork['DefaultGateway'] = $defaultGateway } else { @@ -67,6 +73,9 @@ function Edit-ZertoVra { $vraNetwork['VraIPConfigurationTypeApi'] = "Static" # Add network information to update object. $vraUpdate['VraNetworkDataApi'] = $vraNetwork + } else { + $vraNetwork['VraIPConfigurationTypeApi'] = "Dhcp" + $vraUpdate['VraNetworkDataApi'] = $vraNetwork } # -WhatIf processing and submit! if ($PSCmdlet.ShouldProcess( "Updating " + $vra.vraName + " with these settings: $($vraUpdate | convertTo-Json)")) { @@ -78,3 +87,4 @@ function Edit-ZertoVra { # Nothing to Do } } +#TODO: Refactor \ No newline at end of file diff --git a/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 index 90d0c73..3f5efb8 100644 --- a/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 @@ -1,3 +1,4 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Export-ZertoVpg { [cmdletbinding()] param( @@ -5,17 +6,22 @@ function Export-ZertoVpg { HelpMessage = "Location where to dump the resulting JSON files containing the VPG Settings", Mandatory = $true )] - [string]$outputFolder, + [ValidateNotNullOrEmpty()] + [Alias("outputFolder")] + [string]$outputPath, [parameter( HelpMessage = "Name(s) of the VPG(s) to be exported", - ParameterSetName = "namedVpgs" + ParameterSetName = "namedVpgs", + Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string[]]$vpgName, [parameter( HelpMessage = "Export all VPGs at this site", ParameterSetName = "allVpgs", valuefrompipeline = $true, - ValueFromPipelineByPropertyName = $true + ValueFromPipelineByPropertyName = $true, + Mandatory = $true )] [switch]$allVpgs ) @@ -30,7 +36,7 @@ function Export-ZertoVpg { foreach ($name in $vpgName) { $vpgSettingsIdentifier = New-ZertoVpgSettingsIdentifier -vpgIdentifier $(Get-ZertoVpg -name $name).vpgIdentifier $vpgSettings = Get-ZertoVpgSetting -vpgSettingsIdentifier $vpgSettingsIdentifier - $filePath = "{0}\{1}.json" -f $outputFolder, $name + $filePath = "{0}\{1}.json" -f $outputPath, $name $vpgSettings | Convertto-Json -depth 10 | Out-File -FilePath $filePath } } diff --git a/ZertoApiWrapper/Public/Get-ZertoAlert.ps1 b/ZertoApiWrapper/Public/Get-ZertoAlert.ps1 index d38dedb..1ee27f6 100644 --- a/ZertoApiWrapper/Public/Get-ZertoAlert.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoAlert.ps1 @@ -9,6 +9,7 @@ function Get-ZertoAlert { ValueFromPipelineByPropertyName = $true , HelpMessage = "AlertId or array of AlertIds to be queried" )] + [ValidateNotNullOrEmpty()] [string[]]$alertId, [Parameter( ParameterSetName = "entities", @@ -32,41 +33,53 @@ function Get-ZertoAlert { ParameterSetName = "filter", HelpMessage = "Returns Alerts after the Start Date. Provide the string in the format of 'yyyy-MM-ddTHH:mm:ss.fff'" )] + [ValidateNotNullOrEmpty()] [string]$startDate, [Parameter( ParameterSetName = "filter", HelpMessage = "Returns Alerts before the End Date. Provide the string in the format of 'yyyy-MM-ddTHH:mm:ss.fff'" )] + [ValidateNotNullOrEmpty()] [string]$endDate, [Parameter( ParameterSetName = "filter", HelpMessage = "Returns alerts for the specified vraIdentifier" )] + [ValidateNotNullOrEmpty()] + [Alias("vpgId")] [string]$vpgIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "Returns alerts for the specified siteIdentifier" )] + [ValidateNotNullOrEmpty()] + [Alias("siteId")] [string]$siteIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "Returns alerts for the specified zorgIdentifier" )] + [ValidateNotNullOrEmpty()] + [Alias("zorgId")] [string]$zorgIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "Returns alerts for the specified level" )] + [ValidateNotNullOrEmpty()] [string]$level, [Parameter( ParameterSetName = "filter", HelpMessage = "Returns alerts for the specified helpIdentifier" )] + [ValidateNotNullOrEmpty()] + [Alias("helpId")] [string]$helpIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "Returns alerts for the specified entity" )] + [ValidateNotNullOrEmpty()] [string]$entity, [Parameter( ParameterSetName = "filter", diff --git a/ZertoApiWrapper/Public/Get-ZertoDatastore.ps1 b/ZertoApiWrapper/Public/Get-ZertoDatastore.ps1 index fc62429..8584e90 100644 --- a/ZertoApiWrapper/Public/Get-ZertoDatastore.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoDatastore.ps1 @@ -2,10 +2,12 @@ function Get-ZertoDatastore { [cmdletbinding( DefaultParameterSetName = "main" )] param( + [Alias("datastoreId")] [Parameter( ParameterSetName = "datastoreIdentifier", HelpMessage = "datastoreIdentifier or array of datastoreIdentifiers to be queried" )] + [ValidateNotNullOrEmpty()] [string[]]$datastoreIdentifier ) diff --git a/ZertoApiWrapper/Public/Get-ZertoEvent.ps1 b/ZertoApiWrapper/Public/Get-ZertoEvent.ps1 index 87aa95c..1c45ee8 100644 --- a/ZertoApiWrapper/Public/Get-ZertoEvent.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoEvent.ps1 @@ -6,72 +6,92 @@ function Get-ZertoEvent { ParameterSetName = "filter", HelpMessage = "The starting date for the list of events, supplied as a date with the format of the Zerto Virtual Manager where the API runs, for example, yyyy-MM-dd. You can also specify a local time with the following format: yyyy-MM-ddTHH:mm:ss.fffZ. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$startDate, [Parameter( ParameterSetName = "filter", HelpMessage = "The end date for the list, supplied as a date with the format of the Zerto Virtual Manager where the API runs, for example, yyyy-MM-dd. You can also specify a local time with the following format: yyyy-MM-ddTHH:mm:ss.fffZ. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$endDate, [Parameter( ParameterSetName = "filter", HelpMessage = "The name of the VPG for which you want to return events." )] + [ValidateNotNullOrEmpty()] + [Alias("vpgName")] [string]$vpg, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the VPG for which you want to return events." )] + [ValidateNotNullOrEmpty()] + [Alias("vpgId")] [string]$vpgIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The type of event. For the description of events, refer to the Zerto Virtual Replication documentation about alerts and events. Please see Zerto API Documentation for possible values." )] + [ValidateNotNullOrEmpty()] [string]$eventType, [Parameter( ParameterSetName = "filter", HelpMessage = "The name of the site for which you want to return events." )] + [ValidateNotNullOrEmpty()] [string]$siteName, [Parameter( ParameterSetName = "filter", HelpMessage = "The internal site identifier for which you want to return events." )] + [ValidateNotNullOrEmpty()] + [Alias("siteId")] [string]$siteIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the ZORG, Zerto organization, defined in the Zerto Cloud Manager for which you want to return results." )] + [ValidateNotNullOrEmpty()] + [Alias("zorgId")] [string]$zorgIdentifier, [Parameter( ParameterSetName = "filter", - HelpMessage = "The type of entity for which you wish to return results. Possible Values are: '0' or 'VPG', '1' or 'VRA', '2' or 'Unknown', or '3' or 'Site'" + HelpMessage = "The type of entity for which you wish to return results. Possible Values are: 'VPG', 'VRA', 'Unknown', or 'Site'" )] + [ValidateSet("VPG", "VRA", "Unknown", "Site")] [string]$entityType, [Parameter( ParameterSetName = "filter", HelpMessage = "The name of the user for which the event occurred. If the event occurred as a result of a task started by the Zerto Virtual Manager, for example, when moving a VPG before the commit stage, the user is System." )] + [ValidateNotNullOrEmpty()] [string]$userName, [Parameter( ParameterSetName = "filter", - HelpMessage = "The type of event to return. This filter behaves in the same way as the eventCategory filter. Possible Values are: Possible Values are: '0' or 'All', '1' or 'Events', '2' or 'Alerts'" + HelpMessage = "The type of event to return. This filter behaves in the same way as the eventCategory filter. Possible Values are: Possible Values are: 'All', 'Events', 'Alerts'" )] + [ValidateNotNullOrEmpty()] [string]$category, [Parameter( ParameterSetName = "filter", - HelpMessage = " This filter behaves in the same way as the category filter. If both category and eventCategory filters are specified, only the category filter value is used and the eventCategory filter value is ignored. The type of event to return. Possible Values are: '0' or 'All', '1' or 'Events', '2' or 'Alerts'" + HelpMessage = " This filter behaves in the same way as the category filter. If both category and eventCategory filters are specified, only the category filter value is used and the eventCategory filter value is ignored. The type of event to return. Possible Values are: 'All', 'Events', 'Alerts'" )] + [ValidateSet("All", "Events", "Alerts")] [string]$eventCategory, [Parameter( ParameterSetName = "filter", HelpMessage = "The internal alert identifier for the Event" )] + [ValidateNotNullOrEmpty()] + [Alias("alertId")] [string]$alertIdentifier, [Parameter( ParameterSetName = "eventId", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, - HelpMessage = "The identifier or identifiers of the event for which information is returned.")] + HelpMessage = "The identifier or identifiers of the event for which information is returned." + )] + [ValidateNotNullOrEmpty()] [string[]]$eventId, [Parameter( ParameterSetName = "categories", diff --git a/ZertoApiWrapper/Public/Get-ZertoLicense.ps1 b/ZertoApiWrapper/Public/Get-ZertoLicense.ps1 index 2bb4e1a..1dba563 100644 --- a/ZertoApiWrapper/Public/Get-ZertoLicense.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoLicense.ps1 @@ -1,6 +1,7 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Get-ZertoLicense { [cmdletbinding()] + param() $uri = "license" Invoke-ZertoRestRequest -uri $uri } diff --git a/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 b/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 index 9c25df1..8f64673 100644 --- a/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 @@ -15,6 +15,8 @@ function Get-ZertoPeerSite { ValueFromPipelineByPropertyName = $true, HelpMessage = "The identifier(s) of the peer site(s) for which information is to be returned." )] + [ValidateNotNullOrEmpty()] + [Alias("siteId")] [string[]]$siteIdentifier, [Parameter( ParameterSetName = "filter", @@ -25,27 +27,30 @@ function Get-ZertoPeerSite { ParameterSetName = "filter", HelpMessage = "The pairing status for which information is to be returned." )] + [ValidateNotNullOrEmpty()] [string]$paringStatus, [Parameter ( ParameterSetName = "filter", HelpMessage = "The site location, as specified in the site information, for which information is to be returned." )] + [ValidateNotNullOrEmpty()] [string]$location, [Parameter ( ParameterSetName = "filter", HelpMessage = "The IP address of a Zerto Virtual Manager, paired with this site, for which information is to be returned." )] + [ValidateNotNullOrEmpty()] [string]$hostName, [Parameter ( ParameterSetName = "filter", HelpMessage = "The port used to access peer sites for which information is to be returned. The default port is 9081." )] + [ValidateNotNullOrEmpty()] [string]$port ) begin { $baseUri = "peersites" - $returnObject = [System.Collections.ArrayList]@() } process { @@ -53,14 +58,14 @@ function Get-ZertoPeerSite { "main" { $uri = "{0}" -f $baseUri $results = Invoke-ZertoRestRequest -uri $uri - $returnObject.Add($results) | Out-Null + return $results } "siteIdentifier" { foreach ( $id in $siteIdentifier ) { $uri = "{0}/{1}" -f $baseUri, $id $results = Invoke-ZertoRestRequest -uri $uri - $returnObject.Add($results) | Out-Null + return $results } } @@ -68,18 +73,18 @@ function Get-ZertoPeerSite { $filter = Get-ZertoApiFilter -filterTable $PSBoundParameters $uri = "{0}{1}" -f $baseUri, $filter $results = Invoke-ZertoRestRequest -uri $uri - $returnObject.Add($results) | Out-Null + return $results } default { $uri = "{0}/{1}" -f $baseUri, $PSCmdlet.ParameterSetName.ToLower() $results = Invoke-ZertoRestRequest -uri $uri - $returnObject.Add($results) | Out-Null + return $results } } } end { - return $returnObject + #Nothing to do! } } diff --git a/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 b/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 index db71c52..36dc2aa 100644 --- a/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 @@ -9,56 +9,70 @@ function Get-ZertoProtectedVm { ValueFromPipelineByPropertyName = $true, HelpMessage = "vmIdentifier(s) for which to return information" )] + [ValidateNotNullOrEmpty()] + [Alias("vmId")] [string[]]$vmIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The name of the VPG which protects the virtual machine." )] + [ValidateNotNullOrEmpty()] [string]$vpgName, [Parameter( ParameterSetName = "filter", HelpMessage = "The name of the virtual machine." )] + [ValidateNotNullOrEmpty()] [string]$vmName, [Parameter( ParameterSetName = "filter", HelpMessage = "The status of the VPG. Please see Zerto API documentation for possible values." )] + [ValidateNotNullOrEmpty()] [string]$status, [Parameter( ParameterSetName = "filter", HelpMessage = "The substatus of the VPG, for example the VPG is in a bitmap sync. For the description of substatuses, refer to the Zerto Virtual Manager Administration Guide. Please see Zerto API documentation for possible values." )] + [ValidateNotNullOrEmpty()] [string]$substatus, [Parameter( ParameterSetName = "filter", HelpMessage = "The ZORG for this VPG." )] + [ValidateNotNullOrEmpty()] [string]$organizationName, [Parameter( ParameterSetName = "filter", - HelpMessage = "The priority specified for the VPG. Possible values are: '0' or 'Low', '1' or 'Medium', '2' or 'High'" + HelpMessage = "The priority specified for the VPG. Possible values are: 'Low', 'Medium', or 'High'" )] + [ValidateSet("Low", "Medium", "High")] [string]$priority, [Parameter( ParameterSetName = "filter", HelpMessage = "The protected site type. Please see Zerto API documentation for possible values." )] + [ValidateNotNullOrEmpty()] [string]$protectedSiteType, [Parameter( ParameterSetName = "filter", HelpMessage = "The recovery site type. Please see Zerto API documentation for possible values." )] + [ValidateNotNullOrEmpty()] [string]$recoverySiteType, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the protected site where the VPG virtual machines are protected." )] + [ValidateNotNullOrEmpty()] + [Alias("protectedSiteId")] [string]$protectedSiteIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the recovery site where the VPG virtual machines are recovered." )] + [ValidateNotNullOrEmpty()] + [Alias("recoverySiteId")] [string]$recoverySiteIdentifier ) diff --git a/ZertoApiWrapper/Public/Get-ZertoRecoveryReport.ps1 b/ZertoApiWrapper/Public/Get-ZertoRecoveryReport.ps1 index 9f3b5ae..c15ba9c 100644 --- a/ZertoApiWrapper/Public/Get-ZertoRecoveryReport.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoRecoveryReport.ps1 @@ -6,41 +6,49 @@ function Get-ZertoRecoveryReport { ParameterSetName = "filter", HelpMessage = "Operations performed between the specified start Time and end Time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$startTime, [Parameter( ParameterSetName = "filter", HelpMessage = "Operations performed between the specified start Time and end Time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$endTime, [Parameter( ParameterSetName = "filter", HelpMessage = "The page number the user wants to retrieve. Minimum value is 1." )] + [ValidateNotNullOrEmpty()] [string]$pageNumber, [Parameter( ParameterSetName = "filter", HelpMessage = "The number of reports to display in a single page. The maximum number of reports per page is 1000." )] + [ValidateNotNullOrEmpty()] [string]$pageSize, [Parameter( ParameterSetName = "filter", HelpMessage = "The internal identifier of the VPG. You can specify more than one VPG, separated by commas." )] + [ValidateNotNullOrEmpty()] [string]$vpgIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The name of the VPG. You can specify more than one VPG, separated by commas." )] + [ValidateNotNullOrEmpty()] [string]$vpgName, [Parameter( ParameterSetName = "filter", HelpMessage = "The type of recovery operations. Possible values are: 'Failover', 'Failover Test', or 'Move'" )] + [ValidateSet("Failover", "Failover Test", "Move")] [string]$recoveryType, [Parameter( ParameterSetName = "filter", HelpMessage = "Whether the recovery operation has completed." )] + [ValidateNotNullOrEmpty()] [string]$state ) diff --git a/ZertoApiWrapper/Public/Get-ZertoResourcesReport.ps1 b/ZertoApiWrapper/Public/Get-ZertoResourcesReport.ps1 index ce35557..f447777 100644 --- a/ZertoApiWrapper/Public/Get-ZertoResourcesReport.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoResourcesReport.ps1 @@ -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 ) diff --git a/ZertoApiWrapper/Public/Get-ZertoServiceProfile.ps1 b/ZertoApiWrapper/Public/Get-ZertoServiceProfile.ps1 index 2de7a8c..76a5e2e 100644 --- a/ZertoApiWrapper/Public/Get-ZertoServiceProfile.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoServiceProfile.ps1 @@ -6,11 +6,15 @@ function Get-ZertoServiceProfile { ParameterSetName = "siteIdentifier", HelpMessage = "The identifier of the site for which service profiles should be returned." )] + [ValidateNotNullOrEmpty()] + [Alias("siteId")] [string]$siteIdentifier, [Parameter( ParameterSetName = "serviceProfileId", HelpMessage = "The service profile ID for which information should be returned." )] + [ValidateNotNullOrEmpty()] + [Alias("serviceProfileIdentifier")] [string[]]$serviceProfileId ) diff --git a/ZertoApiWrapper/Public/Get-ZertoTask.ps1 b/ZertoApiWrapper/Public/Get-ZertoTask.ps1 index cd8dd21..d8f1537 100644 --- a/ZertoApiWrapper/Public/Get-ZertoTask.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoTask.ps1 @@ -6,6 +6,8 @@ function Get-ZertoTask { ParameterSetName = "taskIdentifier", HelpMessage = "The identifier(s) for which task information is to be returned." )] + [ValidateNotNullOrEmpty()] + [Alias("taskId")] [string[]]$taskIdentifier, [Parameter( ParameterSetName = "types", @@ -16,31 +18,37 @@ function Get-ZertoTask { ParameterSetName = "filter", HelpMessage = "Tasks started before this time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$startedBeforeDate, [Parameter( ParameterSetName = "filter", HelpMessage = "Tasks started after this time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$startedAfterDate, [Parameter( ParameterSetName = "filter", HelpMessage = "Tasks completed after this time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$completedAfterDate, [Parameter( ParameterSetName = "filter", HelpMessage = "Tasks completed before this time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$completedBeforeDate, [Parameter( ParameterSetName = "filter", HelpMessage = "The type of task. For the description of the tasks, refer to the Zerto Virtual Replication documentation about monitoring tasks. Please see Zerto API Documentation for possible types and values." )] + [ValidateNotNullOrEmpty()] [string]$type, [Parameter( ParameterSetName = "filter", - HelpMessage = "The status of the task. Possible values are: '1' or 'InProgress', '3' or 'Paused', '4' or 'Failed', '6' or 'Completed', '7' or 'Cancelling'" + HelpMessage = "The status of the task. Possible values are: 'InProgress', 'Paused', 'Failed', 'Completed', or 'Cancelling'" )] + [ValidateSet("InProgress", "Paused", "Failed", "Completed", "Cancelling")] [string]$status ) diff --git a/ZertoApiWrapper/Public/Get-ZertoUnprotectedVm.ps1 b/ZertoApiWrapper/Public/Get-ZertoUnprotectedVm.ps1 index b69aa27..d76e96c 100644 --- a/ZertoApiWrapper/Public/Get-ZertoUnprotectedVm.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoUnprotectedVm.ps1 @@ -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 } diff --git a/ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 b/ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 index 5063f96..e296887 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 @@ -52,6 +52,8 @@ function Get-ZertoVirtualizationSite { Mandatory = $true, HelpMessage = "The identifier of the Zerto Virtual Manager site." )] + [ValidateNotNullOrEmpty()] + [Alias("siteId")] [string]$siteIdentifier, [Parameter( ParameterSetName = "datastoreClusters", @@ -81,6 +83,8 @@ function Get-ZertoVirtualizationSite { Mandatory = $false, HelpMessage = "The identifier of the host at the selected site to return information for only one host." )] + [ValidateNotNullOrEmpty()] + [Alias("hostId")] [string]$hostIdentifier, [Parameter( ParameterSetName = "folders", diff --git a/ZertoApiWrapper/Public/Get-ZertoVolume.ps1 b/ZertoApiWrapper/Public/Get-ZertoVolume.ps1 index 3855679..dee5130 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVolume.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVolume.ps1 @@ -6,26 +6,35 @@ function Get-ZertoVolume { ParameterSetName = "filter", HelpMessage = "The type of volume. Please see Zerto API Documentation for possible values." )] + [ValidateNotNullOrEmpty()] [string]$volumeType, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the VPG." )] + [ValidateNotNullOrEmpty()] + [Alias("vpgId")] [string]$vpgIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the datastore." )] + [ValidateNotNullOrEmpty()] + [Alias("datastoreId", "dsId")] [string]$datastoreIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the protected virtual machine." )] + [ValidateNotNullOrEmpty()] + [Alias("protectedVmId")] [string]$protectedVmIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the owning virtual machine." )] + [ValidateNotNullOrEmpty()] + [Alias("owningVmId")] [string]$owningVmIdentifier ) diff --git a/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 index f9750ef..d151152 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 @@ -17,6 +17,8 @@ function Get-ZertoVpg { Mandatory = $true, HelpMessage = "The identifier(s) of the Virtual Protection Group to return" )] + [ValidateNotNullOrEmpty()] + [Alias("vpgId", "protectionGroupId", "pgId")] [string[]]$protectionGroupIdentifier, [Parameter( ParameterSetName = "checkpoints", @@ -28,11 +30,13 @@ function Get-ZertoVpg { ParameterSetName = "checkpoints", HelpMessage = "Return checkpoints after the specified start date. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$startDate, [Parameter( ParameterSetName = "checkpoints", HelpMessage = "Return checkpoints before the specified start date. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$endDate, [Parameter( ParameterSetName = "stats", Mandatory = $true, @@ -85,57 +89,68 @@ function Get-ZertoVpg { ParameterSetName = "filter", HelpMessage = "The name of the VPG." )] + [ValidateNotNullOrEmpty()] [Alias("vpgName")] [string]$name, [Parameter( ParameterSetName = "filter", HelpMessage = "The status of the VPG. Please use 'Get-ZertoVpg -statuses' for valid values" )] + [ValidateNotNullOrEmpty()] [string]$status, [Parameter( ParameterSetName = "filter", HelpMessage = "The substatus of the VPG. Please use 'Get-ZertoVpg -substatuses' for valid values" )] + [ValidateNotNullOrEmpty()] [string]$subStatus, [Parameter( ParameterSetName = "filter", HelpMessage = "The protected site environment. This filter behaves in the same way as the sourceType filter. Please see Zerto API Documentation for vaild values and discriptions." )] + [ValidateNotNullOrEmpty()] [string]$protectedSiteType, [Parameter( ParameterSetName = "filter", HelpMessage = "The recovery site environment. This filter behaves in the same way as the sourceType filter. Please see Zerto API Documentation for vaild values and discriptions." )] + [ValidateNotNullOrEmpty()] [string]$recoverySiteType, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the protected site where the VPG virtual machines are protected." )] + [ValidateNotNullOrEmpty()] [string]$protectedSiteIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the protected site where the VPG virtual machines are recovered." )] + [ValidateNotNullOrEmpty()] [string]$recoverySiteIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The ZORG for this VPG." )] + [ValidateNotNullOrEmpty()] [string]$organizationName, [Parameter( ParameterSetName = "filter", HelpMessage = "The internal identifier for the ZORG." )] + [ValidateNotNullOrEmpty()] [string]$zorgIdentifier, [Parameter( ParameterSetName = "filter", - HelpMessage = "The VPG priority. Possible values are: '0' or 'Low', '1' or 'Medium', '2' or 'High'" + HelpMessage = "The VPG priority. Possible values are: 'Low', 'Medium', 'High'" )] + [ValidateSet("Low", "Medium", "High")] [string]$priority, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the service profile to use for the VPG when a Zerto Cloud Manager is used." )] + [ValidateNotNullOrEmpty()] [string]$serviceProfileIdentifier, [Parameter( ParameterSetName = "filter", @@ -171,9 +186,9 @@ function Get-ZertoVpg { if ( $PSBoundParameters.ContainsKey("startDate") -or $PSBoundParameters.ContainsKey("endDate") ) { $filter = $true $filterTable = @{} - foreach ( $key in $PSBoundParameters.Keys ) { - if ( $key -eq "startDate" -or $key -eq "endDate") { - $filterTable[$key] = $PSBoundParameters[$key] + foreach ( $param in $PSBoundParameters.GetEnumerator() ) { + if ( $param.key -eq "startDate" -or $param.key -eq "endDate") { + $filterTable[$param.key] = $param.value } } $filter = Get-ZertoApiFilter -filterTable $filterTable diff --git a/ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 b/ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 index 500e1af..39a59e3 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 @@ -9,6 +9,7 @@ function Get-ZertoVpgSetting { ParameterSetName = "vpgSettingsIdentifier", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, + ValueFromRemainingArguments = $true, Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] @@ -16,6 +17,7 @@ function Get-ZertoVpgSetting { ParameterSetName = "backup", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, + ValueFromRemainingArguments = $true, Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] @@ -23,6 +25,7 @@ function Get-ZertoVpgSetting { ParameterSetName = "dayOfWeek", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, + ValueFromRemainingArguments = $true, Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] @@ -30,6 +33,7 @@ function Get-ZertoVpgSetting { ParameterSetName = "retentionPeriod", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, + ValueFromRemainingArguments = $true, Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] @@ -37,6 +41,7 @@ function Get-ZertoVpgSetting { ParameterSetName = "schedulerPeriod", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, + ValueFromRemainingArguments = $true, Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] @@ -44,12 +49,14 @@ function Get-ZertoVpgSetting { ParameterSetName = "basic", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, + ValueFromRemainingArguments = $true, Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] [Parameter( ParameterSetName = "bootGroup", ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." @@ -57,6 +64,7 @@ function Get-ZertoVpgSetting { [Parameter( ParameterSetName = "journal", ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." @@ -64,6 +72,7 @@ function Get-ZertoVpgSetting { [Parameter( ParameterSetName = "networks", ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." @@ -71,6 +80,7 @@ function Get-ZertoVpgSetting { [Parameter( ParameterSetName = "priority", ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." @@ -78,6 +88,7 @@ function Get-ZertoVpgSetting { [Parameter( ParameterSetName = "recovery", ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." @@ -85,6 +96,7 @@ function Get-ZertoVpgSetting { [Parameter( ParameterSetName = "scripting", ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." @@ -92,6 +104,7 @@ function Get-ZertoVpgSetting { [Parameter( ParameterSetName = "vms", ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." @@ -99,6 +112,7 @@ function Get-ZertoVpgSetting { [Parameter( ParameterSetName = "vmIdentifier", ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." @@ -106,6 +120,7 @@ function Get-ZertoVpgSetting { [Parameter( ParameterSetName = "nics", ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." @@ -113,6 +128,7 @@ function Get-ZertoVpgSetting { [Parameter( ParameterSetName = "nicIdentifier", ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." @@ -120,6 +136,7 @@ function Get-ZertoVpgSetting { [Parameter( ParameterSetName = "volumes", ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." @@ -127,11 +144,14 @@ function Get-ZertoVpgSetting { [Parameter( ParameterSetName = "volumeIdentifier", ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $true, Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] - [string]$vpgSettingsIdentifier, + [ValidateNotNullOrEmpty()] + [Alias("vpgSettingsId", "settingsId")] + [string[]]$vpgSettingsIdentifier, [Parameter( ParameterSetName = "backup", Mandatory = $true, @@ -229,6 +249,8 @@ function Get-ZertoVpgSetting { Mandatory = $true, HelpMessage = "VM Identifier" )] + [ValidateNotNullOrEmpty()] + [Alias("vmId")] [string]$vmIdentifier, [Parameter( ParameterSetName = "nics", @@ -241,6 +263,8 @@ function Get-ZertoVpgSetting { Mandatory = $true, HelpMessage = "Return NIC information for specified NIC of the specified VM" )] + [ValidateNotNullOrEmpty()] + [Alias("nicId")] [string]$nicIdentifier, [Parameter( ParameterSetName = "volumes", @@ -253,43 +277,105 @@ function Get-ZertoVpgSetting { Mandatory = $true, HelpMessage = "Return volume information for the specified volume of the specified VM" )] + [ValidateNotNullOrEmpty()] + [Alias("volumeId")] [string]$volumeIdentifier ) begin { $baseUri = "vpgSettings" - $returnObject = @() } - #TODO - Update to Switch Logic process { - if ( $PSCmdlet.ParameterSetName -eq "main" ) { - $returnObject = Invoke-ZertoRestRequest -uri $baseUri - } elseif ($PSCmdlet.ParameterSetName -eq "vpgSettingsIdentifier") { - $uri = "{0}/{1}" -f $baseUri, $vpgSettingsIdentifier - $returnObject = Invoke-ZertoRestRequest -uri $uri - } elseif ( $PSCmdlet.ParameterSetName -eq "dayOfWeek" -or $PSCmdlet.ParameterSetName -eq "retentionPeriod" -or $PSCmdlet.ParameterSetName -eq "schedulerPeriod" ) { - $uri = "{0}/{1}/backup/{2}" -f $baseUri, $vpgSettingsIdentifier, $PSCmdlet.ParameterSetName.ToLower() - $returnObject = Invoke-ZertoRestRequest -uri $uri - } elseif ( $PSCmdlet.ParameterSetName -eq "nics" -or $PSCmdlet.ParameterSetName -eq "volumes" ) { - $uri = "{0}/{1}/vms/{2}/{3}" -f $baseUri, $vpgSettingsIdentifier, $vmIdentifier, $PSCmdlet.ParameterSetName.ToLower() - $returnObject = Invoke-ZertoRestRequest -uri $uri - } elseif ( $PSCmdlet.ParameterSetName -eq "vmIdentifier" ) { - $uri = "{0}/{1}/vms/{2}" -f $baseUri, $vpgSettingsIdentifier, $vmIdentifier - $returnObject = Invoke-ZertoRestRequest -uri $uri - } elseif ( $PSCmdlet.ParameterSetName -eq "nicIdentifier" ) { - $uri = "{0}/{1}/vms/{2}/nics/{3}" -f $baseUri, $vpgSettingsIdentifier, $vmIdentifier, $nicIdentifier - $returnObject = Invoke-ZertoRestRequest -uri $uri - } elseif ( $PSCmdlet.ParameterSetName -eq "volumeIdentifier" ) { - $uri = "{0}/{1}/vms/{2}/volumes/{3}" -f $baseUri, $vpgSettingsIdentifier, $vmIdentifier, $volumeIdentifier - $returnObject = Invoke-ZertoRestRequest -uri $uri - } else { - $uri = "{0}/{1}/{2}" -f $baseUri, $vpgSettingsIdentifier, $PSCmdlet.ParameterSetName.ToLower() - $returnObject = Invoke-ZertoRestRequest -uri $uri + switch ( $PSCmdlet.ParameterSetName ) { + "main" { + Invoke-ZertoRestRequest -uri $baseUri + break + } + + "vpgSettingsIdentifier" { + foreach ($id in $vpgSettingsIdentifier) { + $uri = "{0}/{1}" -f $baseUri, $id + Invoke-ZertoRestRequest -uri $uri + } + break + } + + "dayOfWeek" { + foreach ($id in $vpgSettingsIdentifier) { + $uri = "{0}/{1}/backup/{2}" -f $baseUri, $id, $PSCmdlet.ParameterSetName.ToLower() + Invoke-ZertoRestRequest -uri $uri + } + break + } + + "retentionPeriod" { + foreach ($id in $vpgSettingsIdentifier) { + $uri = "{0}/{1}/backup/{2}" -f $baseUri, $id, $PSCmdlet.ParameterSetName.ToLower() + Invoke-ZertoRestRequest -uri $uri + } + break + } + + "schedulerPeriod" { + foreach ($id in $vpgSettingsIdentifier) { + $uri = "{0}/{1}/backup/{2}" -f $baseUri, $id, $PSCmdlet.ParameterSetName.ToLower() + Invoke-ZertoRestRequest -uri $uri + } + break + } + + "nics" { + foreach ($id in $vpgSettingsIdentifier) { + $uri = "{0}/{1}/vms/{2}/{3}" -f $baseUri, $id, $vmIdentifier, $PSCmdlet.ParameterSetName.ToLower() + Invoke-ZertoRestRequest -uri $uri + } + break + } + + "volumes" { + foreach ($id in $vpgSettingsIdentifier) { + $uri = "{0}/{1}/vms/{2}/{3}" -f $baseUri, $id, $vmIdentifier, $PSCmdlet.ParameterSetName.ToLower() + Invoke-ZertoRestRequest -uri $uri + } + break + } + + "vmIdentifier" { + foreach ($id in $vpgSettingsIdentifier) { + $uri = "{0}/{1}/vms/{2}" -f $baseUri, $id, $vmIdentifier + Invoke-ZertoRestRequest -uri $uri + } + break + } + + "nicIdentifier" { + foreach ($id in $vpgSettingsIdentifier) { + $uri = "{0}/{1}/vms/{2}/nics/{3}" -f $baseUri, $id, $vmIdentifier, $nicIdentifier + Invoke-ZertoRestRequest -uri $uri + } + break + } + + "volumeIdentifier" { + foreach ($id in $vpgSettingsIdentifier) { + $uri = "{0}/{1}/vms/{2}/volumes/{3}" -f $baseUri, $id, $vmIdentifier, $volumeIdentifier + Invoke-ZertoRestRequest -uri $uri + } + break + } + + default { + foreach ($id in $vpgSettingsIdentifier) { + $uri = "{0}/{1}/{2}" -f $baseUri, $id, $PSCmdlet.ParameterSetName.ToLower() + Invoke-ZertoRestRequest -uri $uri + } + break + } } } end { - return $returnObject + #Nothing to do! } } diff --git a/ZertoApiWrapper/Public/Get-ZertoVra.ps1 b/ZertoApiWrapper/Public/Get-ZertoVra.ps1 index 6192848..e94d08b 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVra.ps1 @@ -18,51 +18,62 @@ function Get-ZertoVra { ParameterSetName = "vraIdentifier", HelpMessage = "Returns information for provided VRA identifier(s)" )] + [ValidateNotNullOrEmpty()] + [Alias("vraId")] [string[]]$vraIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "VRA Name to return information for." )] + [ValidateNotNullOrEmpty()] [string]$vraName, [Parameter( ParameterSetName = "filter", HelpMessage = "Search for VRAs in a specific status" )] + [ValidateNotNullOrEmpty()] [string]$status, [Parameter( ParameterSetName = "filter", HelpMessage = "Search for VRAs of a specific version" )] + [ValidateNotNullOrEmpty()] [string]$vraVersion, [Parameter( ParameterSetName = "filter", HelpMessage = "Search for VRAs paired to a specific host version" )] + [ValidateNotNullOrEmpty()] [string]$hostVersion, [Parameter( ParameterSetName = "filter", HelpMessage = "Search for a VRA with the specified IP address" )] + [ValidateNotNullOrEmpty()] [string]$ipAddress, [Parameter( ParameterSetName = "filter", HelpMessage = "Search for VRAs belonging to a specific group" )] + [ValidateNotNullOrEmpty()] [string]$vraGroup, [Parameter( ParameterSetName = "filter", HelpMessage = "Search for VRAs on a specific datastore" )] + [ValidateNotNullOrEmpty()] [string]$datastoreName, [Parameter( ParameterSetName = "filter", HelpMessage = "Search for VRAs on a specific datastore cluster" )] + [ValidateNotNullOrEmpty()] [string]$datastoreClusterName, [Parameter( ParameterSetName = "filter", HelpMessage = "Search for VRAs on a specific network" )] + [ValidateNotNullOrEmpty()] [string]$networkName ) @@ -83,7 +94,7 @@ function Get-ZertoVra { } # When vra ids are provided, return for each id provided - "vraIdentifierifierifier" { + "vraIdentifier" { $returnObject = foreach ( $vraId in $vraIdentifier ) { $uri = "{0}/{1}" -f $baseUri, $vraId Invoke-ZertoRestRequest -uri $uri diff --git a/ZertoApiWrapper/Public/Get-ZertoZorg.ps1 b/ZertoApiWrapper/Public/Get-ZertoZorg.ps1 index 65a908f..27f39ee 100644 --- a/ZertoApiWrapper/Public/Get-ZertoZorg.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoZorg.ps1 @@ -6,6 +6,8 @@ function Get-ZertoZorg { ParameterSetName = "zorgIdentifier", HelpMessage = "Identifier(s) of the ZORG." )] + [ValidateNotNullOrEmpty()] + [Alias("zorgId")] [string[]]$zorgIdentifier ) diff --git a/ZertoApiWrapper/Public/Get-ZertoZsspSession.ps1 b/ZertoApiWrapper/Public/Get-ZertoZsspSession.ps1 index 3cd1743..1c11b36 100644 --- a/ZertoApiWrapper/Public/Get-ZertoZsspSession.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoZsspSession.ps1 @@ -6,6 +6,8 @@ function Get-ZertoZsspSession { ParameterSetName = "zsspSessionIdentifier", HelpMessage = "ZSSP Session Id(s) to get information." )] + [ValidateNotNullOrEmpty()] + [Alias("zsspSessionId")] [string[]]$zsspSessionIdentifier ) diff --git a/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 index f3e54ec..48a72cc 100644 --- a/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 @@ -1,3 +1,4 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Import-ZertoVpg { [cmdletbinding()] param( @@ -7,6 +8,7 @@ function Import-ZertoVpg { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true )] + [ValidateNotNullOrEmpty()] [Alias("FullName")] [string[]]$settingsFile ) @@ -23,7 +25,7 @@ function Import-ZertoVpg { $importedSettings.VpgSettingsIdentifier = $vpgSettingsIdentifier $uri = "{0}/{1}" -f $baseUri, $vpgSettingsIdentifier Invoke-ZertoRestRequest -uri $uri -method "PUT" -body $($importedSettings | convertto-json -Depth 10) - $vpgSettingsIdentifier | Save-ZertoVpgSettings + $vpgSettingsIdentifier | Save-ZertoVpgSetting if ($settingsFile.Count -gt 1) { Start-Sleep 5 } diff --git a/ZertoApiWrapper/Public/Install-ZertoVra.ps1 b/ZertoApiWrapper/Public/Install-ZertoVra.ps1 index d549457..2bca65f 100644 --- a/ZertoApiWrapper/Public/Install-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Install-ZertoVra.ps1 @@ -1,18 +1,22 @@ -#TODO - Add ability to installed with root password. <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +#TODO - Add ability to installed with root password, Move to Begin, Process, End Format function Install-ZertoVra { [cmdletbinding( SupportsShouldProcess = $true )] param( [Parameter( Mandatory = $true, HelpMessage = "Host name where the VRA is to be installed." )] + [ValidateNotNullOrEmpty()] [string]$hostName, [Parameter( Mandatory = $true, HelpMessage = "Datastore name where the VRA is to be installed." )] + [ValidateNotNullOrEmpty()] [string]$datastoreName, [Parameter( Mandatory = $true, HelpMessage = "Network name the VRA is to be assigned." )] + [ValidateNotNullOrEmpty()] [string]$networkName, [Parameter( HelpMessage = "Initial amount of memory to assign to the VRA in GB. Default is 3, Minimum is 1, Maximum is 16" )] [ValidateRange(1, 16)] [int]$memoryInGB = 3, [Parameter( HelpMessage = "Bandwidth group to assign to the VRA. If unspecified will assign to the 'default_group'" )] + [ValidateNotNullOrEmpty()] [string]$groupName, [Parameter( ParameterSetName = "Dhcp", Mandatory = $true, HelpMessage = "Assign a DHCP address to the VRA." )] [switch]$Dhcp, diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 index a307d5e..5eb5500 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 @@ -1,68 +1,99 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Invoke-ZertoFailover { - [cmdletbinding()] + [cmdletbinding( SupportsShouldProcess = $true )] param( + #TODO - Refactor? [Parameter( Mandatory = $true, HelpMessage = "Name of the VPG to Failover" )] + [ValidateNotNullOrEmpty()] [string]$vpgName, [Parameter( HelpMessage = "Checkpoint Identifier to use as the Point-In-Time to rollback to." )] + [Alias("checkpointId")] + [ValidateNotNullOrEmpty()] [string]$checkpointIdentifier, [Parameter( - HelpMessage = "0: After the seconds specified in the commitValue setting have elapsed, the failover is rolled back. - 1: After the seconds specified in the commitValue setting have elapsed, the failover continues, committing the virtual machines in the recovery site. - 2: The virtual machines in the VPG being failed over remain in the Before Commit state until either they are committed with Commit a failover, or rolled back with Roll back a failover. + HelpMessage = "'Rollback': After the seconds specified in the commitValue setting have elapsed, the failover is rolled back. + 'Commit': After the seconds specified in the commitValue setting have elapsed, the failover continues, committing the virtual machines in the recovery site. + 'None': The virtual machines in the VPG being failed over remain in the Before Commit state until either they are committed with Commit a failover, or rolled back with Roll back a failover. Default is the Site Settings setting." )] - [string]$commitPolicy, + [ValidateSet("Rollback", "Commit", "None")] + [string]$commitPolicy = "Rollback", [Parameter( - HelpMessage = "The amount of time in seconds the failover waits in a Before Commit state to enable checking that the failover is as required before performing the commitPolicy setting. Default is the Site Setting" - )] - [string]$commitValue, - [Parameter( - HelpMessage = "0: The protected virtual machines are not touched before starting the failover. This assumes that you do not have access to the protected virtual machines. -- DEFAULT - 1: If the protected virtual machines have VMware Tools or Microsoft Integration Services available, the virtual machines are gracefully shut down, otherwise the failover operation fails. This is similar to performing a Move operation to a specified checkpoint. - 2: The protected virtual machines are forcibly shut down before starting the failover. If the protected virtual machines have VMware Tools or Microsoft Integration Services available, the procedure waits five minutes for the virtual machines to be gracefully shut down before forcibly powering them off. This is similar to performing a Move operation to a specified checkpoint." + HelpMessage = "0: The protected virtual machines are not touched before starting the failover. -- DEFAULT + 1: If the protected virtual machines have VMware Tools or Microsoft Integration Services available, the virtual machines are gracefully shut down, otherwise the failover operation fails. This is similar to performing a Move operation to a specified checkpoint. This assumes that you do not have access to the protected virtual machines. + 2: The protected virtual machines are forcibly shut down before starting the failover. If the protected virtual machines have VMware Tools or Microsoft Integration Services available, the procedure waits five minutes for the virtual machines to be gracefully shut down before forcibly powering them off. This is similar to performing a Move operation to a specified checkpoint. This assumes that you do not have access to the protected virtual machines" )] + [ValidateSet(0, 1, 2)] [int]$shutdownPolicy = 0, [Parameter( - HelpMessage = "Time, in seconds, before VMs are forcibly turned off if the Force Shutdown option is seclected after attempting to gracefully shut down the VMs" + HelpMessage = "The amount of time in seconds the failover waits in a Before Commit state to enable checking that the failover is as required before performing the commitPolicy setting. Default is 60 Minutes (3600 Seconds)" )] - [long]$timeToWaitBeforeShutdownInSec = 300, + # Min 5 Minutes, Max 24 Hours, Default 1 Hour. + [ValidateRange(300, 86400)] + [int]$timeToWaitBeforeShutdownInSec = 3600, [Parameter( HelpMessage = "True: Enable reverse protection. The virtual machines are recovered on the recovery site and then protected using the default reverse protection settings. False: Do not enable reverse protection. The VPG definition is kept with the status Needs Configuration and the reverse settings in the VPG definition are not set." )] [bool]$reverseProtection, [Parameter( - HelpMessage = "Name(s) of VMs in the " + HelpMessage = "Name(s) of VMs in the VPG to failover" )] + [ValidateNotNullOrEmpty()] [string[]]$vmName ) begin { - $vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier - $baseUri = "vpgSettings/{0}/failover" -f $vpgId - $body = [ordered]@{} - foreach ($key in $PSBoundParameters.Keys) { - if ($key -notlike 'vpgGroup' -or $key -notlike 'vmName') { - $body[$key] = $PSBoundParameters['key'] - } + $vpgId = $(Get-ZertoVpg -name $vpgName).vpgIdentifier + if ( -not $vpgId) { + Write-Error "VPG: $vpgName Not Found. Please check the name and try again!" -ErrorAction Stop } - if ($PSBoundParameters.ContainsKey('vmName')) { - $vmIdentifiers = @() - $vmIdentifiers = foreach ( $name in $vmName ) { - $(Get-ZertoProtectedVm -vmName $name).vmIdentifier + $baseUri = "vpgs/{0}/failover" -f $vpgId + $body = @{} + # Setup Required Defaults + $body['commitpolicy'] = $commitPolicy + $body['TimeToWaitBeforeShutdownInSec'] = $timeToWaitBeforeShutdownInSec + + Switch ($PSBoundParameters.Keys) { + "checkpointIdentifier" { + $body['checkpointIdentifier'] = $checkpointIdentifier + } + + "shutdownPolicy" { + $body['shutdownPolicy'] = $shutdownPolicy + } + + "reverseProtection" { + $body['reverseProtection'] = $reverseProtection + } + + "vmName" { + $vpgVmInformation = Get-ZertoProtectedVm -vpgName $vpgName + [System.Collections.ArrayList]$vmIdentifiers = @() + foreach ( $name in $vmName ) { + $selectedVm = $vpgVmInformation | Where-Object {$_.VmName.toLower() -eq $name.toLower()} + if ($null -eq $selectedVm) { + Write-Error "VM: $name NOT found in VPG $vpgName. Check the name and try again." -ErrorAction Stop + } elseif ($vmIdentifiers.Contains($selectedVm.vmIdentifier.toString())) { + Write-Error "VM: $($selectedVm.VmName) specified more than once. Please check parameters and try again." -ErrorAction Stop + } else { + $vmIdentifiers.Add($selectedVm.vmIdentifier.toString()) | Out-Null + } + } + $body['VmIdentifiers'] = $vmIdentifiers } - $body['VmIdentifiers'] = $vmIdentifiers } } process { - Invoke-ZertoRestRequest -uri $baseUri -body $($body | ConvertTo-Json) -method "POST" + if ($PSCmdlet.ShouldProcess("$vpgName with identifier $vpgId and these options $($body | convertto-json)")) { + Invoke-ZertoRestRequest -uri $baseUri -body $($body | ConvertTo-Json) -method "POST" + } } end { diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 index 05f40b5..cbd5250 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 @@ -1,36 +1,43 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Invoke-ZertoFailoverCommit { - [cmdletbinding()] + [cmdletbinding( SupportsShouldProcess = $true )] param( [Parameter( HelpMessage = "Name(s) of the VPG(s) to commit.", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string[]]$vpgName, [Parameter( HelpMessage = "Use this switch to reverse protect the VPG(s) to the source site." )] - [switch]$reverseProtect + [switch]$reverseProtection ) begin { $baseUri = "vpgs" - if ( $reverseProtect ) { - $body = @{"IsReverseProtect" = $true} - } else { - $body = @{"IsReverseProtect" = $false} - } } process { + if ( $reverseProtection.IsPresent ) { + $body = @{"IsReverseProtection" = $true } + } else { + $body = @{"IsReverseProtection" = $false } + } foreach ($name in $vpgName) { $vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier - $uri = "{0}/{1}/FailoverCommit" -f $baseUri, $vpgId - Invoke-ZertoRestRequest -uri $uri -body $($body | convertto-json) -method "POST" + if ( -not $vpgId ) { + Write-Error "VPG: $name could not be found. Please check the name and try again. Skipping." + } else { + $uri = "{0}/{1}/FailoverCommit" -f $baseUri, $vpgId + if ($PSCmdlet.ShouldProcess($body, $uri)) { + Invoke-ZertoRestRequest -uri $uri -body $($body | convertto-json) -method "POST" + } + } } } end { # Nothing to do } -} \ No newline at end of file +} diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailoverRollback.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailoverRollback.ps1 index e6bc6cb..fc6b92f 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailoverRollback.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailoverRollback.ps1 @@ -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" + } } } diff --git a/ZertoApiWrapper/Public/Invoke-ZertoForceSync.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoForceSync.ps1 index 5dac2eb..81ee866 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoForceSync.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoForceSync.ps1 @@ -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" + } } } diff --git a/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 index a245da9..8c7a9a3 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 @@ -1,50 +1,53 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Invoke-ZertoMove { - [CmdletBinding()] + [CmdletBinding( DefaultParameterSetName = "main", SupportsShouldProcess = $true )] param( [Parameter( HelpMessage = "Name(s) of the VPG(s) you want to move.", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string[]]$vpgName, [Parameter( - HelpMessage = "The policy to use after the move enters a 'Before Commit' state. If omitted, the site settings default will be applied. Valid values are: '0' or 'Rollback', '1' or 'Commit', '2' or 'None'. Please see Zerto API Documentation for additional information." + HelpMessage = "'Rollback': After the seconds specified in the commitValue setting have elapsed, the failover is rolled back. + 'Commit': After the seconds specified in the commitValue setting have elapsed, the failover continues, committing the virtual machines in the recovery site. + 'None': The virtual machines in the VPG being failed over remain in the Before Commit state until either they are committed with Commit a failover, or rolled back with Roll back a failover. + Default is the Site Settings setting." )] + [ValidateSet("Rollback", "Commit", "None")] [string]$commitPolicy, [Parameter( HelpMessage = "The amount of time, in seconds, the Move is in a 'Before Commit' state, before performing the commitPolicy setting. If omitted, the site settings default will be applied." )] - [Int32]$commitPolicyTimeout, + # Min 5 Minutes, Max 24 Hours, Default 1 Hour. + [ValidateRange(300, 86400)] + [Int]$commitPolicyTimeout, [Parameter( - HelpMessage = "False: If a utility (VMware Tools) is installed on the protected virtual machines, the procedure waits five minutes for the virtual machines to be gracefully shut down before forcibly powering them off. - True: To force a shutdown of the virtual machines. - Default: True" + HelpMessage = "If this switch is specified, Zerto will attempt to gracefully shut down the Virtual Machines. If the machines do not poweroff within 5 minutes, they will be forcibly powering them off." )] - [bool]$forceShutdown, + [switch]$forceShutdown, [Parameter( - HelpMessage = "False: Do not enable reverse protection. The VPG definition is kept with the status Needs Configuration and the reverse settings in the VPG definition are not set. - True: Enable reverse protection. The virtual machines are recovered on the recovery site and then protected using the default reverse protection settings. - Default Value: True - Note: If ReverseProtection is set to True, the KeepSourceVMs should be ignored because the virtual disks of the VMs are used for replication and cannot have VMs attached." + ParameterSetName = "disableReverseProtection", + HelpMessage = "Do not enable reverse protection. The VPG definition is kept with the status Needs Configuration and the reverse settings in the VPG definition are not set.", + Mandatory = $true )] - [bool]$reverseProtection = $false, + [switch]$disableReverseProtection, [Parameter( - HelpMessage = "False: Remove the protected virtual machines from the protected site. - True: Prevent the protected virtual machines from being deleted in the protected site. - Default: False" + ParameterSetName = "keepSourceVms", + HelpMessage = "Prevent the protected virtual machines from being deleted in the protected site. Using this setting disables reverse protection.", + Mandatory = $true )] - [bool]$keepSourceVms = $false, + [switch]$keepSourceVms, [Parameter( - HelpMessage = "False: Do not continue the Move operation in case of failure of script executing prior the operation. - True: Continue the Move operation in case of failure of script executing prior the operation. - Default: False" + HelpMessage = "Continue the Move operation in case of failure of script executing prior the operation. If this switch is not set a failure of the script executing prior to the operation will cause the operation to fail." )] - [bool]$continueOnPreScriptFailure + [switch]$ContinueOnPreScriptFailure ) begin { $baseUri = "vpgs" $body = [ordered]@{} + #TODO - use a foreach loop to populate the body without all the if statments if ($PSBoundParameters.ContainsKey('commitPolicy')) { $body['commitPolicy'] = $commitPolicy } @@ -52,28 +55,48 @@ function Invoke-ZertoMove { $body['commitPolicyTimeout'] = $commitPolicyTimeout } if ($PSBoundParameters.ContainsKey('forceShutdown')) { - $body['forceShutdown'] = $forceShutdown + $body['forceShutdown'] = $true + } else { + $body['forceShutdown'] = $false } - if ($PSBoundParameters.ContainsKey('reverseProtection')) { - $body['reverseProtection'] = $reverseProtection + if ($PSBoundParameters.ContainsKey('ContinueOnPreScriptFailure')) { + $body['ContinueOnPreScriptFailure'] = $true + } else { + $body['ContinueOnPreScriptFailure'] = $false } - if ($PSBoundParameters.ContainsKey('keepSourceVms')) { - $body['keepSourceVms'] = $keepSourceVms - } - if ($PSBoundParameters.ContainsKey('continueOnPreScriptFail')) { - $body['continueOnPreScriptFail'] = $continueOnPreScriptFailure + switch ($PSCmdlet.ParameterSetName) { + "disableReverseProtection" { + $body['reverseProtection'] = $false + $body['keepSourceVms'] = $false + } + + "keepSourceVms" { + $body['reverseProtection'] = $false + $body['keepSourceVms'] = $true + } + + "main" { + $body['reverseProtection'] = $true + $body['keepSourceVms'] = $false + } } } process { foreach ($name in $vpgName) { $vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier - $uri = "{0}/{1}/move" -f $baseUri, $vpgId - Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) + if ( -not $vpgId ) { + Write-Error "VPG: $name not found. Please check the name and try again. Skipping" + } else { + $uri = "{0}/{1}/move" -f $baseUri, $vpgId + if ($PSCmdlet.ShouldProcess("Moving VPG: $name wiht settings: $($body | convertto-json)")) { + Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) + } + } } } end { # Nothing to do. } -} \ No newline at end of file +} diff --git a/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 index eedb889..f524af1 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 @@ -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 } -} \ No newline at end of file +} diff --git a/ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 index d51ecc5..b1d7e24 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 @@ -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" + } + } } } diff --git a/ZertoApiWrapper/Public/New-ZertoVpg.ps1 b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 index 753554a..a4885f5 100644 --- a/ZertoApiWrapper/Public/New-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 @@ -1,11 +1,12 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function New-ZertoVpg { - [cmdletbinding()] + [cmdletbinding(SupportsShouldProcess = $true)] param( [Parameter( HelpMessage = "Name of the VPG", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$vpgName, [Parameter( HelpMessage = "VPG Priority. High, Medium, or Low. Default value is Medium" @@ -21,11 +22,13 @@ function New-ZertoVpg { HelpMessage = "Name(s) of the VM(s) to be protected.", Mandatory = $true )] - [ValidateNotNullOrEmpty()][string[]]$protectedVm, + [ValidateNotNullOrEmpty()] + [string[]]$protectedVm, [Parameter( HelpMessage = "Name of the site where the VM(s) will be recovered", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$recoverySite, [Parameter( HelpMessage = "Name of the cluster where the VM(s) will be recovered.", @@ -37,6 +40,7 @@ function New-ZertoVpg { ParameterSetName = "recoveryClusterDatastoreCluster", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$recoveryCluster, [Parameter( HelpMessage = "Name of the host where the VM(s) will be recovered.", @@ -48,6 +52,7 @@ function New-ZertoVpg { ParameterSetName = "recoveryHostDatastoreCluster", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$recoveryHost, [Parameter( HelpMessage = "Name of the resource pool where the VM(s) will be recovered.", @@ -59,6 +64,7 @@ function New-ZertoVpg { ParameterSetName = "recoveryResourcePoolDatastoreCluster", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$recoveryResourcePool, [Parameter( HelpMessage = "Name of the datastore where the VM(s), Volume(s), and Journal(s) will reside.", @@ -75,6 +81,7 @@ function New-ZertoVpg { ParameterSetName = "recoveryResourcePoolDatastore", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$datastore, [Parameter( HelpMessage = "Name of the datastore cluster where the VM(s), Volume(s), and Journal(s) will reside.", @@ -91,23 +98,28 @@ function New-ZertoVpg { ParameterSetName = "recoveryResourcePoolDatastoreCluster", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$datastoreCluster, [Parameter( HelpMessage = "Name of folder at recovery location where the recovered virtual machine(s) will be created.", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$recoveryFolder, [Parameter( HelpMessage = "RPO alert" )] - [ValidateRange(60, 864200)][Int32]$rpoInSeconds = 300, + [ValidateRange(60, 864200)] + [Int32]$rpoInSeconds = 300, [Parameter( HelpMessage = "Minimum test interval for this VPG. Valid values are 0: Off, 43200: 1 Month, 131040: 3 Months, 262080: 6 Months, 294560: 9 Months, 252600: 12 Months" )] - [ValidateSet(0, 43200, 131040, 262080, 294560, 252600)][int]$testIntervalInMinutes = 262080, + [ValidateSet(0, 43200, 131040, 262080, 294560, 252600)] + [int]$testIntervalInMinutes = 262080, [Parameter( HelpMessage = "Service profile name to use." )] + [ValidateNotNullOrEmpty()] [string]$serviceProfile, [Parameter( HelpMessage = "Turn on or off WAN and Journal Compression. Default is turned on." @@ -116,31 +128,37 @@ function New-ZertoVpg { [Parameter( HelpMessage = "Name of ZORG to use." )] + [ValidateNotNullOrEmpty()] [String]$zorg, [Parameter( HelpMessage = "Name of the network to use during a Failover Live \ Move VPG operation.", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [String]$recoveryNetwork, [Parameter( HelpMessage = "Name of the network to use during a Failover Test operation", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$testNetwork, [Parameter( HelpMessage = "Name of the datastore to utilize to store Journal data. If not specified, the default datastore will be used.", Mandatory = $false )] + [ValidateNotNullOrEmpty()] [string]$journalDatastore, [Parameter( HelpMessage = "Default journal hard limit in megabytes. Default set to 153600 MB (150 GB). Set to 0 to set the journal to unlimited", Mandatory = $false )] + [ValidateNotNullOrEmpty()] [uint64]$journalHardLimitInMb = 153600, [Parameter( HelpMessage = "Default journal warning threshold in megabytes. If unset or greater than the hard limit, will be set to 75% of the journal hard limit.", Mandatory = $false )] + [ValidateNotNullOrEmpty()] [uint64]$journalWarningThresholdInMb = 0 ) @@ -223,6 +241,23 @@ function New-ZertoVpg { if (($journalWarningThresholdInMb -eq 0) -or ($journalWarningThresholdInMb -gt $journalHardLimitInMb)) { $journalWarningThresholdInMb = $journalHardLimitInMb * .75 } + + #Validate all items in the hashtable are populated with valid data. + $validSettings = $true + foreach ($item in $identifiersTable.GetEnumerator()) { + if ([String]::IsNullOrEmpty($item.value)) { + $validSettings = $false + Write-Error "$($item.key) is not associated with a valid identifier. Please check the submitted values and try again." + } + } + if ($vmIdentifiers.count -eq 0) { + $validSettings = $false + Write-Error "No valid VM names were passed or all passed VMs are already protected and cannot be further protected." + } + + if ( -not $validSettings ) { + Write-Error "One or more parameters passed do not have valid identifiers or 0 valid VMs were found. Please check your settings and try again." -ErrorAction Stop + } } process { @@ -292,7 +327,9 @@ function New-ZertoVpg { $baseSettings.Journal.Limitation.HardLimitInMB = $journalHardLimitInMb $baseSettings.Journal.Limitation.WarningThresholdInMB = $journalWarningThresholdInMb $settingsURI = "{0}/{1}" -f $baseUri, $vpgSettingsIdentifier - Invoke-ZertoRestRequest -uri $settingsURI -body $($baseSettings | ConvertTo-Json -Depth 10) -method "PUT" | Out-Null + if ($PSCmdlet.ShouldProcess($($baseSettings | ConvertTo-Json -Depth 10))) { + $results = Invoke-ZertoRestRequest -uri $settingsURI -body $($baseSettings | ConvertTo-Json -Depth 10) -method "PUT" + } } end { diff --git a/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 b/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 index 1ae97dc..06150d2 100644 --- a/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 +++ b/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 @@ -1,5 +1,6 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function New-ZertoVpgSettingsIdentifier { - [cmdletbinding()] + [cmdletbinding( SupportsShouldProcess = $true, DefaultParameterSetName = "newVpg" )] param( [Parameter( HelpMessage = "Identifier of the VPG to create a VPG settings identifier. If a vpgIdentifier is not provided, a new VPG settings object is created without any configured settings. This would be used for creating a new VPG from scratch.", @@ -8,7 +9,9 @@ function New-ZertoVpgSettingsIdentifier { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true )] - [string]$vpgIdentifier, + [ValidateNotNullOrEmpty()] + [Alias("vpgId")] + [string[]]$vpgIdentifier, [Parameter( HelpMessage = "Use this switch when creating a vpgSettingsIdentifier for a new VPG", ParameterSetName = "newVpg", @@ -19,22 +22,28 @@ function New-ZertoVpgSettingsIdentifier { begin { $baseUri = "vpgSettings" + } + + process { switch ($PSCmdlet.ParameterSetName) { "newVpg" { $body = "{}" + if ($PSCmdlet.ShouldProcess("Creating VPG Settings Object")) { + Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST" + } } - "existingVpg" { - $body = "{""VpgIdentifier"":""$vpgIdentifier""}" + foreach ($id in $vpgIdentifier) { + $body = "{""VpgIdentifier"":""$id""}" + if ($PSCmdlet.ShouldProcess("Creating VPG Settings Object")) { + Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST" + } + } } } } - process { - Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST" - } - end { - + #Nothing to do } } diff --git a/ZertoApiWrapper/Public/Remove-ZertoPeerSite.ps1 b/ZertoApiWrapper/Public/Remove-ZertoPeerSite.ps1 new file mode 100644 index 0000000..0d818e9 --- /dev/null +++ b/ZertoApiWrapper/Public/Remove-ZertoPeerSite.ps1 @@ -0,0 +1,81 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +function Remove-ZertoPeerSite { + [cmdletbinding( + SupportsShouldProcess = $true, + DefaultParameterSetName = "siteIdentifier" + )] + param ( + [Parameter( + HelpMessage = "Identifier of the site to be removed from the connected site", + ParameterSetName = "siteIdentifier", + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, + Mandatory = $true + )] + [ValidateNotNullOrEmpty()] + [Alias("siteId")] + [string[]]$siteIdentifier, + [Parameter( + HelpMessage = "Name of the peer site to be removed from the connected site", + ParameterSetName = "peerSiteName", + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, + Mandatory = $true + )] + [ValidateNotNullOrEmpty()] + [string[]]$peerSiteName, + [Parameter( + HelpMessage = "IP address of the peer site to be removed from the connected site", + ParameterSetName = "hostName", + ValueFromPipeline = $true, + ValueFromPipelineByPropertyName = $true, + Mandatory = $true + )] + [ValidateScript( {$_ -match [IPAddress]$_ })] + [string[]]$hostName, + [Parameter( + HelpMessage = "Specify this switch to Keep the target replica disks for any VPGs replicating between the sites as the VPGs will be deleted by unpairing the sites. If this switch is not used, the target replica disks will be deleted" + )] + [switch]$keepTargetDisks + ) + + begin { + $baseUri = "peersites" + $body = @{} + if ( $keepTargetDisks ) { + $body['IsKeepTargetDisks'] = $true + } else { + $body['IsKeepTargetDisks'] = $false + } + } + + process { + switch ( $PSCmdlet.ParameterSetName ) { + "peerSiteName" { + $siteIdentifier = @() + $siteIdentifier = foreach ($site in $peerSiteName) { + $(Get-ZertoPeerSite -peerName $site).siteIdentifier + } + } + + "hostName" { + $siteIdentifier = @() + $siteIdentifier = foreach ($name in $hostName) { + $(Get-ZertoPeerSite -hostName $name).siteIdentifier + } + } + } + + foreach ($id in $siteIdentifier) { + $uri = "{0}/{1}" -f $baseUri, $id + if ($PSCmdlet.ShouldProcess("Removing siteIdentifier $id")) { + Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -Method "DELETE" + } + } + + } + + end { + # Nothing to do + } +} \ No newline at end of file diff --git a/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 index 38ec249..5e453fb 100644 --- a/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 @@ -9,6 +9,7 @@ function Remove-ZertoVpg { ValueFromPipelineByPropertyName = $true, HelpMessage = "Name(s) of the VPG(s) to delete." )] + [ValidateNotNullOrEmpty()] [string[]]$vpgName, [Parameter( Mandatory = $true, @@ -17,15 +18,17 @@ function Remove-ZertoVpg { ValueFromPipelineByPropertyName = $true, HelpMessage = "vpgIdentifier(s) of the VPG(s) to delete." )] + [ValidateNotNullOrEmpty()] + [Alias("vpgId")] [string[]]$vpgidentifier, [Parameter( HelpMessage = "Use this parameter to keep the recovery volumes at the target site, by setting it to True. If the virtual machines in the deleted VPG are reprotected, these volumes can be used as preseeded volumes to speed up the initial synchronization of the new VPG. Default is to remove Recovery Volumes" )] - [switch]$keepRecoveryVolumes = $false, + [switch]$keepRecoveryVolumes, [Parameter( HelpMessage = "Use this parameter to force delete the VPG, by setting this parameter equal to true." )] - [switch]$force = $false + [switch]$force ) begin { @@ -54,7 +57,7 @@ function Remove-ZertoVpg { Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -Method "DELETE" } } else { - Write-Output "VPG with name $vpgName not found. Please check the name and try again" + Write-Error "VPG with name $vpgName not found. Please check the name and try again" } } } diff --git a/ZertoApiWrapper/Public/Resume-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Resume-ZertoVpg.ps1 index f5e1181..24e1c8f 100644 --- a/ZertoApiWrapper/Public/Resume-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Resume-ZertoVpg.ps1 @@ -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" + } } } diff --git a/ZertoApiWrapper/Public/Save-ZertoVpgSettings.ps1 b/ZertoApiWrapper/Public/Save-ZertoVpgSetting.ps1 similarity index 86% rename from ZertoApiWrapper/Public/Save-ZertoVpgSettings.ps1 rename to ZertoApiWrapper/Public/Save-ZertoVpgSetting.ps1 index 015a79e..64c9127 100644 --- a/ZertoApiWrapper/Public/Save-ZertoVpgSettings.ps1 +++ b/ZertoApiWrapper/Public/Save-ZertoVpgSetting.ps1 @@ -1,5 +1,5 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> -function Save-ZertoVpgSettings { +function Save-ZertoVpgSetting { [cmdletbinding( SupportsShouldProcess = $true )] @@ -10,6 +10,8 @@ function Save-ZertoVpgSettings { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true )] + [ValidateNotNullOrEmpty()] + [Alias("vpgSettingsId")] [string]$vpgSettingsIdentifier ) @@ -17,4 +19,4 @@ function Save-ZertoVpgSettings { if ($PSCmdlet.ShouldProcess("Commiting VPG Settings with Settigns identifier $vpgSettingsIdentifier")) { Invoke-ZertoRestRequest -uri $baseUri -method "POST" } -} \ No newline at end of file +} diff --git a/ZertoApiWrapper/Public/Set-ZertoAlert.ps1 b/ZertoApiWrapper/Public/Set-ZertoAlert.ps1 index 7c1792d..1969177 100644 --- a/ZertoApiWrapper/Public/Set-ZertoAlert.ps1 +++ b/ZertoApiWrapper/Public/Set-ZertoAlert.ps1 @@ -2,13 +2,14 @@ function Set-ZertoAlert { [cmdletbinding( SupportsShouldProcess = $true )] param ( - [Alias("identifier")] [Parameter( ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true, HelpMessage = "Alert identifier(s) to be dismissed or undismissed." )] + [ValidateNotNullOrEmpty()] + [Alias("alertIdentifier", "identifier", "id")] [string[]]$alertId, [Parameter( ParameterSetName = "dismiss", @@ -40,4 +41,4 @@ function Set-ZertoAlert { end { # Nothing to do. } -} \ No newline at end of file +} diff --git a/ZertoApiWrapper/Public/Set-ZertoLicense.ps1 b/ZertoApiWrapper/Public/Set-ZertoLicense.ps1 index 3c5de54..6ce7e32 100644 --- a/ZertoApiWrapper/Public/Set-ZertoLicense.ps1 +++ b/ZertoApiWrapper/Public/Set-ZertoLicense.ps1 @@ -6,6 +6,7 @@ function Set-ZertoLicense { Mandatory = $true, HelpMessage = "License Key to apply to the Zerto Virtual Manager" )] + [ValidateNotNullOrEmpty()] [string]$licenseKey ) diff --git a/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 b/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 index 24cdc15..1678c8b 100644 --- a/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 +++ b/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 @@ -1,40 +1,62 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Start-ZertoCloneVpg { - [cmdletbinding()] + [cmdletbinding( SupportsShouldProcess = $true )] param( [Parameter( HelpMessage = "Name of the VPG you wish to clone.", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$vpgName, [Parameter( HelpMessage = "The identifier of the checkpoint to use for cloning. If unspecified, the latest checkpoint will be used." )] + [ValidateNotNullOrEmpty()] + [Alias("checkpointId")] [string]$checkpointIdentifier, [Parameter( HelpMessage = "The datastore name where the clone is to be created. If unspecified, will auto select the datastore with the most free space." )] + [ValidateNotNullOrEmpty()] [string]$datastoreName, [Parameter( HelpMessage = "The name(s) of the VMs you wish to clone. If unspecified, all VMs in the VPG will be cloned." )] + [ValidateNotNullOrEmpty()] [string[]]$vmName ) begin { $baseUri = "vpgs" - $vpgInfo = Get-ZertoVpg -name $vpgName + if ( -not $vpgInfo ) { + Write-Error "VPG: $vpgName could not be found. Please check the name and try again." + } $vpgIdentifier = $vpgInfo.vpgIdentifier if ( $PSBoundParameters.ContainsKey('datastoreName') ) { $recoverysiteIdentifier = $vpgInfo.recoverysite.identifier $recoverySiteDatastores = Get-ZertoVirtualizationSite -siteIdentifier $recoverysiteIdentifier -datastores $datastoreIdentifier = $($recoverySiteDatastores | Where-Object {$_.datastoreName -like $datastoreName}).DatastoreIdentifier + if ( -not $datastoreIdentifier ) { + Write-Error "Datastore: $datastoreName is not a valid datastore. Please check the name and try again." -ErrorAction Stop + } } if ( $PSBoundParameters.ContainsKey('vmName') ) { - $vmIdentifiers = @() - $vmIdentifiers = foreach ( $name in $vmName ) { - $(Get-ZertoProtectedVm -vmName $name).vmIdentifier + $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 + if ($checkpointIdentifier) { + $body['CheckpointIdentifier'] = $checkpointIdentifier } } } @@ -52,7 +74,9 @@ function Start-ZertoCloneVpg { $body['VmIdentifiers'] = $vmIdentifiers } Write-Verbose $body - Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -method "POST" + if ($PSCmdlet.ShouldProcess("Clone Vpg")) { + Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -method "POST" + } } end { diff --git a/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 b/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 index 578f1d5..ee044e3 100644 --- a/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 +++ b/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 @@ -1,47 +1,57 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Start-ZertoFailoverTest { - [cmdletbinding()] + [cmdletbinding( SupportsShouldProcess = $true )] param( [Parameter( HelpMessage = "Name of VPG to failover test", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$vpgName, [Parameter( HelpMessage = "The identifier of the checkpoint to use for testing. If unspecified, the latest checkpoint will be used." )] + [ValidateNotNullOrEmpty()] + [Alias("checkpointId")] [string]$checkpointIdentifier, [Parameter( HelpMessage = "The name(s) of the VMs within the selected VPG you wish to test. If unspecified, all VMs in the VPG will be tested." )] + [ValidateNotNullOrEmpty()] [string[]]$vmName ) begin { $baseUri = "vpgs" $vpgIdentifier = $(Get-ZertoVpg -name $vpgName).vpgIdentifier + if ( -not $vpgIdentifier) { + 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 + $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 + if ($checkpointIdentifier) { + $body['CheckpointIdentifier'] = $checkpointIdentifier } } } process { $uri = "{0}/{1}/FailoverTest" -f $baseUri, $vpgIdentifier - $body = [ordered]@{} - if ($checkpointIdentifier) { - $body['CheckpointIdentifier'] = $checkpointIdentifier + if ($PSCmdlet.ShouldProcess($vpgName)) { + Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) } - if ( $PSBoundParameters.ContainsKey('vmName') ) { - $vmIdentifiers = @() - $vmIdentifiers = foreach ( $name in $vmName ) { - $(Get-ZertoProtectedVm -vmName $name).vmIdentifier - } - $body['VmIdentifiers'] = $vmIdentifiers - } - Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) } end { diff --git a/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 b/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 index 8e797d7..6e78ade 100644 --- a/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 +++ b/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 @@ -1,21 +1,29 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Stop-ZertoCloneVpg { + [cmdletbinding( SupportsShouldProcess = $true )] param( [Parameter( HelpMessage = "Name of the VPG to stop cloning", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$vpgName ) begin { $baseUri = "vpgs" $vpgIdentifier = $(Get-ZertoVpg -name $vpgName).vpgIdentifier + if ( -not $vpgIdentifier ) { + Write-Error "VPG: $vpgName could not be found. Please check the name and try again." -ErrorAction Stop + } } process { $uri = "{0}/{1}/CloneAbort" -f $baseUri, $vpgIdentifier - invoke-ZertoRestRequest -uri $uri -method "POST" + if ($PSCmdlet.ShouldProcess("Stopping VPG Clone Operation")) { + invoke-ZertoRestRequest -uri $uri -method "POST" + } + } end { diff --git a/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 b/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 index 56f7d1b..babb190 100644 --- a/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 +++ b/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 @@ -1,11 +1,12 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Stop-ZertoFailoverTest { - [cmdletbinding()] + [cmdletbinding( SupportsShouldProcess = $true )] param( [Parameter( HelpMessage = "Name(s) of VPG(s) to stop testing.", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string[]]$vpgName, [Parameter( HelpMessage = "Was the test successful? True or False. True is Default." @@ -14,6 +15,7 @@ function Stop-ZertoFailoverTest { [Parameter( HelpMessage = "Free text field for any notes to add to the test report." )] + [ValidateNotNullOrEmpty()] [string]$failoverTestSummary = "Stop Failover Test for $vpgName" ) @@ -25,8 +27,13 @@ function Stop-ZertoFailoverTest { process { foreach ($name in $vpgName) { $vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier + if ( -not $vpgId) { + Write-Error "VPG: $vpgName Not Found. Please check the name and try again!" -ErrorAction Stop + } $uri = "{0}/{1}/FailoverTestStop" -f $baseUri, $vpgId - Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) + if ($PSCmdlet.ShouldProcess("Stopping Failover Test on VPG: $name")) { + Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) + } } } diff --git a/ZertoApiWrapper/Public/Suspend-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Suspend-ZertoVpg.ps1 index e19bf3f..c590859 100644 --- a/ZertoApiWrapper/Public/Suspend-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Suspend-ZertoVpg.ps1 @@ -6,6 +6,7 @@ function Suspend-ZertoVpg { HelpMessage = "Name(s) of VPG(s) to pause replication", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string[]]$vpgName ) @@ -16,8 +17,12 @@ function Suspend-ZertoVpg { process { foreach ($name in $vpgName) { $id = $(Get-ZertoVpg -name $name).vpgIdentifier - $uri = "{0}/{1}/pause" -f $baseUri, $id - Invoke-ZertoRestRequest -uri $uri -method "POST" + if ( -not $id ) { + Write-Error "VPG: $name not found. Skipping." + } else { + $uri = "{0}/{1}/pause" -f $baseUri, $id + Invoke-ZertoRestRequest -uri $uri -method "POST" + } } } diff --git a/ZertoApiWrapper/Public/Uninstall-ZertoVra.ps1 b/ZertoApiWrapper/Public/Uninstall-ZertoVra.ps1 index dc5b8b4..b62f332 100644 --- a/ZertoApiWrapper/Public/Uninstall-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Uninstall-ZertoVra.ps1 @@ -6,6 +6,7 @@ function Uninstall-ZertoVra { Mandatory = $true, HelpMessage = "Host Name attached to the VRA to be removed." )] + [ValidateNotNullOrEmpty()] [string[]]$hostName ) @@ -17,8 +18,12 @@ function Uninstall-ZertoVra { foreach ($name in $hostName) { $vraName = "Z-VRA-{0}" -f $name $vraIdentifier = get-zertovra -vraName $vraName | Select-Object vraIdentifier -ExpandProperty vraIdentifier - $uri = "{0}/{1}" -f $baseUri, $vraIdentifier.toString() - Invoke-ZertoRestRequest -uri $uri -method "DELETE" + if ( -not $vraIdentifier ) { + Write-Error "Host: $hostName either does not have a VRA or was not found. Please check the name and try again. Skipping." + } else { + $uri = "{0}/{1}" -f $baseUri, $vraIdentifier.toString() + Invoke-ZertoRestRequest -uri $uri -method "DELETE" + } if ($hostName.Count -gt 1) { Start-Sleep 1 } diff --git a/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml b/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml index 39806eb..6ae1461 100644 --- a/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml +++ b/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml @@ -285,7 +285,7 @@ Connect-ZertoServer - + zertoServer IP address or FQDN of your Zerto Management Server @@ -297,7 +297,7 @@ None - + zertoPort Zerto Virtual Manager management port. Default value is 9669. @@ -359,7 +359,7 @@ False - + zertoPort Zerto Virtual Manager management port. Default value is 9669. @@ -371,7 +371,7 @@ "9669" - + zertoServer IP address or FQDN of your Zerto Management Server @@ -554,7 +554,7 @@ None - + vraIdentifier Identifier of the VRA to be updated. @@ -639,7 +639,7 @@ None - + vraIdentifier Identifier of the VRA to be updated. @@ -769,7 +769,7 @@ Export-ZertoVpg - + allVpgs Export all VPGs at this site @@ -780,8 +780,8 @@ False - - outputFolder + + outputPath Location where to dump the resulting JSON files containing the VPG Settings @@ -795,8 +795,8 @@ Export-ZertoVpg - - outputFolder + + outputPath Location where to dump the resulting JSON files containing the VPG Settings @@ -807,7 +807,7 @@ None - + vpgName Name(s) of the VPG(s) to be exported @@ -822,7 +822,7 @@ - + allVpgs Export all VPGs at this site @@ -834,8 +834,8 @@ False - - outputFolder + + outputPath Location where to dump the resulting JSON files containing the VPG Settings @@ -846,7 +846,7 @@ None - + vpgName Name(s) of the VPG(s) to be exported @@ -887,14 +887,14 @@ -------------------------- Example 1 -------------------------- - PS C:> Export-ZertoVpg -outputFolder "C:\ZertoVPGs" -vpgName "My Vpg", "My Other Vpg" + PS C:> Export-ZertoVpg -outputPath "C:\ZertoVPGs" -vpgName "My Vpg", "My Other Vpg" Exports VPG settings for VPGs "My Vpg" and "My Other Vpg". Each settings object will be placed inside a JSON file at C:\ZertoVPGs\ with the name of the file being the name of the VPG. -------------------------- Example 2 -------------------------- - PS C:> Export-ZertoVpg -outputFolder "C:\ZertoVPGs" -allVpgs + PS C:> Export-ZertoVpg -outputPath "C:\ZertoVPGs" -allVpgs Exports VPG settings for all Vpgs replicated to or from this site. Each settings object will be placed inside a JSON file at C:\ZertoVPGs\ with the name of the file being the name of the VPG. If a VPG is in an un-editable state, it cannot be exported. @@ -967,7 +967,7 @@ None - + helpIdentifier Returns alerts for the specified helpIdentifier @@ -1003,7 +1003,7 @@ None - + siteIdentifier Returns alerts for the specified siteIdentifier @@ -1027,7 +1027,7 @@ None - + vpgIdentifier Returns alerts for the specified vraIdentifier @@ -1039,7 +1039,7 @@ None - + zorgIdentifier Returns alerts for the specified zorgIdentifier @@ -1144,7 +1144,7 @@ None - + helpIdentifier Returns alerts for the specified helpIdentifier @@ -1204,7 +1204,7 @@ False - + siteIdentifier Returns alerts for the specified siteIdentifier @@ -1228,7 +1228,7 @@ None - + vpgIdentifier Returns alerts for the specified vraIdentifier @@ -1240,7 +1240,7 @@ None - + zorgIdentifier Returns alerts for the specified zorgIdentifier @@ -1348,7 +1348,7 @@ Get-ZertoDatastore - + datastoreIdentifier datastoreIdentifier or array of datastoreIdentifiers to be queried @@ -1363,7 +1363,7 @@ - + datastoreIdentifier datastoreIdentifier or array of datastoreIdentifiers to be queried @@ -1444,7 +1444,7 @@ Get-ZertoEvent - + alertIdentifier The internal alert identifier for the Event @@ -1459,7 +1459,7 @@ category - The type of event to return. This filter behaves in the same way as the eventCategory filter. Possible Values are: Possible Values are: '0' or 'All', '1' or 'Events', '2' or 'Alerts' + 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' String @@ -1483,7 +1483,7 @@ entityType - The type of entity for which you wish to return results. Possible Values are: '0' or 'VPG', '1' or 'VRA', '2' or 'Unknown', or '3' or 'Site' + The type of entity for which you wish to return results. Possible Values are: 'VPG', 'VRA', 'Unknown', or 'Site' String @@ -1495,7 +1495,7 @@ eventCategory - This filter behaves in the same way as the category filter. If both category and eventCategory filters are specified, only the category filter value is used and the eventCategory filter value is ignored. The type of event to return. Possible Values are: '0' or 'All', '1' or 'Events', '2' or 'Alerts' + This filter behaves in the same way as the category filter. If both category and eventCategory filters are specified, only the category filter value is used and the eventCategory filter value is ignored. The type of event to return. Possible Values are: 'All', 'Events', 'Alerts' String @@ -1516,7 +1516,7 @@ None - + siteIdentifier The internal site identifier for which you want to return events. @@ -1564,7 +1564,7 @@ None - + vpg The name of the VPG for which you want to return events. @@ -1576,7 +1576,7 @@ None - + vpgIdentifier The identifier of the VPG for which you want to return events. @@ -1588,7 +1588,7 @@ None - + zorgIdentifier The identifier of the ZORG, Zerto organization, defined in the Zerto Cloud Manager for which you want to return results. @@ -1660,7 +1660,7 @@ - + alertIdentifier The internal alert identifier for the Event @@ -1687,7 +1687,7 @@ category - The type of event to return. This filter behaves in the same way as the eventCategory filter. Possible Values are: Possible Values are: '0' or 'All', '1' or 'Events', '2' or 'Alerts' + 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' String @@ -1723,7 +1723,7 @@ entityType - The type of entity for which you wish to return results. Possible Values are: '0' or 'VPG', '1' or 'VRA', '2' or 'Unknown', or '3' or 'Site' + The type of entity for which you wish to return results. Possible Values are: 'VPG', 'VRA', 'Unknown', or 'Site' String @@ -1735,7 +1735,7 @@ eventCategory - This filter behaves in the same way as the category filter. If both category and eventCategory filters are specified, only the category filter value is used and the eventCategory filter value is ignored. The type of event to return. Possible Values are: '0' or 'All', '1' or 'Events', '2' or 'Alerts' + This filter behaves in the same way as the category filter. If both category and eventCategory filters are specified, only the category filter value is used and the eventCategory filter value is ignored. The type of event to return. Possible Values are: 'All', 'Events', 'Alerts' String @@ -1768,7 +1768,7 @@ None - + siteIdentifier The internal site identifier for which you want to return events. @@ -1828,7 +1828,7 @@ None - + vpg The name of the VPG for which you want to return events. @@ -1840,7 +1840,7 @@ None - + vpgIdentifier The identifier of the VPG for which you want to return events. @@ -1852,7 +1852,7 @@ None - + zorgIdentifier The identifier of the ZORG, Zerto organization, defined in the Zerto Cloud Manager for which you want to return results. @@ -2166,7 +2166,7 @@ Get-ZertoPeerSite - + siteIdentifier The identifier(s) of the peer site(s) for which information is to be returned. @@ -2253,7 +2253,7 @@ None - + siteIdentifier The identifier(s) of the peer site(s) for which information is to be returned. @@ -2349,7 +2349,7 @@ priority - The priority specified for the VPG. Possible values are: '0' or 'Low', '1' or 'Medium', '2' or 'High' + The priority specified for the VPG. Possible values are: 'Low', 'Medium', or 'High' String @@ -2358,7 +2358,7 @@ None - + protectedSiteIdentifier The identifier of the protected site where the VPG virtual machines are protected. @@ -2382,7 +2382,7 @@ None - + recoverySiteIdentifier The identifier of the recovery site where the VPG virtual machines are recovered. @@ -2457,7 +2457,7 @@ Get-ZertoProtectedVm - + vmIdentifier vmIdentifier(s) for which to return information @@ -2487,7 +2487,7 @@ priority - The priority specified for the VPG. Possible values are: '0' or 'Low', '1' or 'Medium', '2' or 'High' + The priority specified for the VPG. Possible values are: 'Low', 'Medium', or 'High' String @@ -2496,7 +2496,7 @@ None - + protectedSiteIdentifier The identifier of the protected site where the VPG virtual machines are protected. @@ -2520,7 +2520,7 @@ None - + recoverySiteIdentifier The identifier of the recovery site where the VPG virtual machines are recovered. @@ -2568,7 +2568,7 @@ None - + vmIdentifier vmIdentifier(s) for which to return information @@ -3422,7 +3422,7 @@ Get-ZertoServiceProfile - + serviceProfileId The service profile ID for which information should be returned. @@ -3437,7 +3437,7 @@ Get-ZertoServiceProfile - + siteIdentifier The identifier of the site for which service profiles should be returned. @@ -3452,7 +3452,7 @@ - + serviceProfileId The service profile ID for which information should be returned. @@ -3464,7 +3464,7 @@ None - + siteIdentifier The identifier of the site for which service profiles should be returned. @@ -3588,7 +3588,7 @@ status - The status of the task. Possible values are: '1' or 'InProgress', '3' or 'Paused', '4' or 'Failed', '6' or 'Completed', '7' or 'Cancelling' + The status of the task. Possible values are: 'InProgress', 'Paused', 'Failed', 'Completed', or 'Cancelling' String @@ -3612,7 +3612,7 @@ Get-ZertoTask - + taskIdentifier The identifier(s) for which task information is to be returned. @@ -3692,7 +3692,7 @@ status - The status of the task. Possible values are: '1' or 'InProgress', '3' or 'Paused', '4' or 'Failed', '6' or 'Completed', '7' or 'Cancelling' + The status of the task. Possible values are: 'InProgress', 'Paused', 'Failed', 'Completed', or 'Cancelling' String @@ -3701,7 +3701,7 @@ None - + taskIdentifier The identifier(s) for which task information is to be returned. @@ -3859,11 +3859,11 @@ Get ZertoVirtualizationSite - {{Fill in the Synopsis}} + Returns information about the hypervisor site where the API is run and all the sites paired with this site. The information returned can be tailored to specific information about the resources managed at a specified site. - {{Fill in the Description}} + Returns information about the hypervisor site where the API is run and all the sites paired with this site. The information returned can be tailored to specific information about the resources managed at a specified site. @@ -3879,7 +3879,7 @@ False - + siteIdentifier The identifier of the Zerto Virtual Manager site. @@ -3905,7 +3905,7 @@ False - + siteIdentifier The identifier of the Zerto Virtual Manager site. @@ -3931,7 +3931,7 @@ False - + hostIdentifier The identifier of the host at the selected site to return information for only one host. @@ -3943,7 +3943,7 @@ None - + siteIdentifier The identifier of the Zerto Virtual Manager site. @@ -3969,7 +3969,7 @@ False - + siteIdentifier The identifier of the Zerto Virtual Manager site. @@ -3995,7 +3995,7 @@ False - + siteIdentifier The identifier of the Zerto Virtual Manager site. @@ -4010,7 +4010,7 @@ Get-ZertoVirtualizationSite - + hostIdentifier The identifier of the host at the selected site to return information for only one host. @@ -4033,7 +4033,7 @@ False - + siteIdentifier The identifier of the Zerto Virtual Manager site. @@ -4059,7 +4059,7 @@ False - + siteIdentifier The identifier of the Zerto Virtual Manager site. @@ -4085,7 +4085,7 @@ False - + siteIdentifier The identifier of the Zerto Virtual Manager site. @@ -4100,7 +4100,7 @@ Get-ZertoVirtualizationSite - + siteIdentifier The identifier of the Zerto Virtual Manager site. @@ -4126,7 +4126,7 @@ Get-ZertoVirtualizationSite - + siteIdentifier The identifier of the Zerto Virtual Manager site. @@ -4201,7 +4201,7 @@ False - + hostIdentifier The identifier of the host at the selected site to return information for only one host. @@ -4249,7 +4249,7 @@ False - + siteIdentifier The identifier of the Zerto Virtual Manager site. @@ -4302,9 +4302,30 @@ -------------------------- Example 1 -------------------------- - PS C:\> {{ Add example code here }} + PS C:\> Get-ZertoVirtualizationSite -siteIdentifier "MySiteIdentifier" - {{ Add example description here }} + Returns information about the site with identifier "MySiteIdentifier" + + + + -------------------------- Example 2 -------------------------- + PS C:\> Get-ZertoVirtualizationSite -siteIdentifier "MySiteIdentifier" -datastoreClusters + + Returns information about datastore clusters at site with site identifier "MySiteidentifier" + + + + -------------------------- Example 3 -------------------------- + PS C:\> Get-ZertoVirtualizationSite -siteIdentifier "MySiteIdentifier" -datastores + + Returns information about datastores at site with site identifier "MySiteidentifier" + + + + -------------------------- Example 4 -------------------------- + PS C:\> Get-ZertoVirtualizationSite -siteIdentifier "MySiteIdentifier" -devices + + Returns information about devices at site with site identifier "MySiteidentifier" @@ -4334,7 +4355,7 @@ Get-ZertoVolume - + datastoreIdentifier The identifier of the datastore. @@ -4346,7 +4367,7 @@ None - + owningVmIdentifier The identifier of the owning virtual machine. @@ -4358,7 +4379,7 @@ None - + protectedVmIdentifier The identifier of the protected virtual machine. @@ -4382,7 +4403,7 @@ None - + vpgIdentifier The identifier of the VPG. @@ -4397,7 +4418,7 @@ - + datastoreIdentifier The identifier of the datastore. @@ -4409,7 +4430,7 @@ None - + owningVmIdentifier The identifier of the owning virtual machine. @@ -4421,7 +4442,7 @@ None - + protectedVmIdentifier The identifier of the protected virtual machine. @@ -4445,7 +4466,7 @@ None - + vpgIdentifier The identifier of the VPG. @@ -4570,7 +4591,7 @@ priority - The VPG priority. Possible values are: '0' or 'Low', '1' or 'Medium', '2' or 'High' + The VPG priority. Possible values are: 'Low', 'Medium', 'High' String @@ -4701,7 +4722,7 @@ None - + protectionGroupIdentifier The identifier(s) of the Virtual Protection Group to return @@ -4739,7 +4760,7 @@ False - + protectionGroupIdentifier The identifier(s) of the Virtual Protection Group to return @@ -4810,7 +4831,7 @@ Get-ZertoVpg - + protectionGroupIdentifier The identifier(s) of the Virtual Protection Group to return @@ -4990,7 +5011,7 @@ priority - The VPG priority. Possible values are: '0' or 'Low', '1' or 'Medium', '2' or 'High' + The VPG priority. Possible values are: 'Low', 'Medium', 'High' String @@ -5023,7 +5044,7 @@ None - + protectionGroupIdentifier The identifier(s) of the Virtual Protection Group to return @@ -5235,14 +5256,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5261,14 +5282,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5287,14 +5308,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5313,14 +5334,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5339,14 +5360,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5365,14 +5386,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5380,7 +5401,7 @@ Get-ZertoVpgSetting - + nicIdentifier Return NIC information for specified NIC of the specified VM @@ -5392,7 +5413,7 @@ None - + vmIdentifier VM Identifier @@ -5404,14 +5425,14 @@ None - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5430,7 +5451,7 @@ False - + vmIdentifier VM Identifier @@ -5442,14 +5463,14 @@ None - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5468,14 +5489,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5494,14 +5515,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5520,14 +5541,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5546,14 +5567,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5572,14 +5593,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5587,7 +5608,7 @@ Get-ZertoVpgSetting - + vmIdentifier VM Identifier @@ -5599,7 +5620,7 @@ None - + volumeIdentifier Return volume information for the specified volume of the specified VM @@ -5611,14 +5632,14 @@ None - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5626,7 +5647,7 @@ Get-ZertoVpgSetting - + vmIdentifier VM Identifier @@ -5649,14 +5670,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5664,7 +5685,7 @@ Get-ZertoVpgSetting - + vmIdentifier VM Identifier @@ -5676,14 +5697,14 @@ None - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5702,14 +5723,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5717,14 +5738,14 @@ Get-ZertoVpgSetting - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5804,7 +5825,7 @@ False - + nicIdentifier Return NIC information for specified NIC of the specified VM @@ -5888,7 +5909,7 @@ False - + vmIdentifier VM Identifier @@ -5912,7 +5933,7 @@ False - + volumeIdentifier Return volume information for the specified volume of the specified VM @@ -5936,14 +5957,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5977,35 +5998,35 @@ -------------------------- Example 1 -------------------------- - PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" + PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" Returns all current settings for vpgSettingsIdentifier "MySettingsIdentifier" -------------------------- Example 2 -------------------------- - PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" + PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" Returns all current vm level settings for the vmIdentifier "MyVmId" in vpgSettingsIdentifier "MySettingsIdentifier" -------------------------- Example 3 -------------------------- - PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" -volumes + PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" -volumes Returns current vm level settings for volumes for vmId "MyVmId" in vpgSettingsIdentifier "MySettingsIdentifier" -------------------------- Example 4 -------------------------- - PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -nics + PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -nics Returns current vm level settings for nics for vmId "MyVmId" in vpgSettingsIdentifier "MySettingsIdentifier" -------------------------- Example 5 -------------------------- - PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -basic + PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -basic Returns current basic settings for vpgSettingsIdentifier "MySettingsIdentifier" @@ -6176,7 +6197,7 @@ Get-ZertoVra - + vraIdentifier Returns information for provided VRA identifier(s) @@ -6299,7 +6320,7 @@ None - + vraIdentifier Returns information for provided VRA identifier(s) @@ -6403,7 +6424,7 @@ Get-ZertoZorg - + zorgIdentifier Identifier(s) of the ZORG. @@ -6418,7 +6439,7 @@ - + zorgIdentifier Identifier(s) of the ZORG. @@ -6498,7 +6519,7 @@ Get-ZertoZsspSession - + zsspSessionIdentifier ZSSP Session Id(s) to get information. @@ -6513,7 +6534,7 @@ - + zsspSessionIdentifier ZSSP Session Id(s) to get information. @@ -7103,7 +7124,7 @@ None - + checkpointIdentifier Checkpoint Identifier to use as the Point-In-Time to rollback to. @@ -7118,9 +7139,9 @@ commitPolicy - 0: After the seconds specified in the commitValue setting have elapsed, the failover is rolled back. - 1: After the seconds specified in the commitValue setting have elapsed, the failover continues, committing the virtual machines in the recovery site. - 2: The virtual machines in the VPG being failed over remain in the Before Commit state until either they are committed with Commit a failover, or rolled back with Roll back a failover. + 'Rollback': After the seconds specified in the commitValue setting have elapsed, the failover is rolled back. + 'Commit': After the seconds specified in the commitValue setting have elapsed, the failover continues, committing the virtual machines in the recovery site. + 'None': The virtual machines in the VPG being failed over remain in the Before Commit state until either they are committed with Commit a failover, or rolled back with Roll back a failover. Default is the Site Settings setting. String @@ -7130,18 +7151,6 @@ None - - commitValue - - 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 - - String - - - None - shutdownPolicy @@ -7159,11 +7168,11 @@ timeToWaitBeforeShutdownInSec - Time, in seconds, before VMs are forcibly turned off if the Force Shutdown option is seclected after attempting to gracefully shut down the VMs + Time, in seconds, before the commitPolicy is invoked. Default setting is 3600 seconds (60 Minutes). Min value is 300 seconds (5 minutes). Max Value is 86,400 seconds (24 Hours). - Int64 + Int32 - Int64 + Int32 None @@ -7184,7 +7193,7 @@ vmName - Name(s) of VMs in the + Name(s) of VMs in the VPG to failover String[] @@ -7193,10 +7202,32 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + - + checkpointIdentifier Checkpoint Identifier to use as the Point-In-Time to rollback to. @@ -7211,9 +7242,9 @@ commitPolicy - 0: After the seconds specified in the commitValue setting have elapsed, the failover is rolled back. - 1: After the seconds specified in the commitValue setting have elapsed, the failover continues, committing the virtual machines in the recovery site. - 2: The virtual machines in the VPG being failed over remain in the Before Commit state until either they are committed with Commit a failover, or rolled back with Roll back a failover. + 'Rollback': After the seconds specified in the commitValue setting have elapsed, the failover is rolled back. + 'Commit': After the seconds specified in the commitValue setting have elapsed, the failover continues, committing the virtual machines in the recovery site. + 'None': The virtual machines in the VPG being failed over remain in the Before Commit state until either they are committed with Commit a failover, or rolled back with Roll back a failover. Default is the Site Settings setting. String @@ -7223,18 +7254,6 @@ None - - commitValue - - 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 - - String - - - None - reverseProtection @@ -7265,11 +7284,11 @@ timeToWaitBeforeShutdownInSec - Time, in seconds, before VMs are forcibly turned off if the Force Shutdown option is seclected after attempting to gracefully shut down the VMs + Time, in seconds, before the commitPolicy is invoked. Default setting is 3600 seconds (60 Minutes). Min value is 300 seconds (5 minutes). Max Value is 86,400 seconds (24 Hours). - Int64 + Int32 - Int64 + Int32 None @@ -7277,7 +7296,7 @@ vmName - Name(s) of VMs in the + Name(s) of VMs in the VPG to failover String[] @@ -7298,6 +7317,30 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + @@ -7332,6 +7375,13 @@ Start a failover of VPG "MyVpg" with the latest checkpoint and site default policies. + + -------------------------- Example 2 -------------------------- + PS C:\> Invoke-ZertoFailover -vpgName "MyVpg" -shutdownPolicy 2 -reverseProtection $false -commitPolicy 'Commit' -timeToWaitBeforeShutdownInSec 7200 + + Start a failover of VPG "MyVpg" with the latest checkpoint. VMs will attempt to be gracefully shutdown and if unsuccessful will be forcibly powered off. After 2 hours, if the VPG has not been committed or rolled back, the VPG will auto commit. Reverse protection will not be enabled. + + @@ -7372,7 +7422,7 @@ None - reverseProtect + reverseProtection Use this switch to reverse protect the VPG(s) to the source site. @@ -7386,7 +7436,7 @@ - reverseProtect + reverseProtection Use this switch to reverse protect the VPG(s) to the source site. @@ -7445,7 +7495,7 @@ -------------------------- Example 1 -------------------------- - PS C:\> Invoke-ZertoFailoverCommit -vpgName "MyVpg" -reverseProtect + PS C:\> Invoke-ZertoFailoverCommit -vpgName "MyVpg" -reverseProtection Commits a VPG with reverse protection @@ -7668,7 +7718,10 @@ commitPolicy - The policy to use after the move enters a 'Before Commit' state. If omitted, the site settings default will be applied. Valid values are: '0' or 'Rollback', '1' or 'Commit', '2' or 'None'. Please see Zerto API Documentation for additional information. + 'Rollback': After the seconds specified in the commitValue setting have elapsed, the failover is rolled back. + 'Commit': After the seconds specified in the commitValue setting have elapsed, the failover continues, committing the virtual machines in the recovery site. + 'None': The virtual machines in the VPG being failed over remain in the Before Commit state until either they are committed with Commit a failover, or rolled back with Roll back a failover. + Default is the Site Settings setting. String @@ -7692,67 +7745,165 @@ forceShutdown - 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 + By default all virtual machines will attempt to be gracefully shutdown. If a source VM is not running VMware tools or cannot be gracefully shutdown, use this switch to force shutdown the source VMs. - Boolean - Boolean + SwitchParameter - None - - - reverseProtection - - 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. - - Boolean - - Boolean - - - None - - - keepSourceVms - - 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 - - Boolean - - Boolean - - - None + False - continueOnPreScriptFailure + ContinueOnPreScriptFailure - 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 + Use this switch to continue the Move operation even if the Pre-Script fails to run properly. - Boolean - Boolean + SwitchParameter + + + False + + + disableReverseProtection + + 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. + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + + Invoke-ZertoMove + + vpgName + + Name(s) of the VPG(s) you want to move. + + String[] + + String[] None + + commitPolicy + + 'Rollback': After the seconds specified in the commitValue setting have elapsed, the failover is rolled back. + 'Commit': After the seconds specified in the commitValue setting have elapsed, the failover continues, committing the virtual machines in the recovery site. + 'None': The virtual machines in the VPG being failed over remain in the Before Commit state until either they are committed with Commit a failover, or rolled back with Roll back a failover. + Default is the Site Settings setting. + + String + + String + + + None + + + commitPolicyTimeout + + 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 + + Int32 + + + None + + + forceShutdown + + By default all virtual machines will attempt to be gracefully shutdown. If a source VM is not running VMware tools or cannot be gracefully shutdown, use this switch to force shutdown the source VMs. + + + SwitchParameter + + + False + + + keepSourceVms + + Use this switch to Prevent the protected virtual machines from being deleted in the protected site. Reverse protection is not automatic with this selection and should reverse protection be required, must be manually configured post commit. + + + SwitchParameter + + + False + + + ContinueOnPreScriptFailure + + Use this switch to continue the Move operation even if the Pre-Script fails to run properly. + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + commitPolicy - The policy to use after the move enters a 'Before Commit' state. If omitted, the site settings default will be applied. Valid values are: '0' or 'Rollback', '1' or 'Commit', '2' or 'None'. Please see Zerto API Documentation for additional information. + 'Rollback': After the seconds specified in the commitValue setting have elapsed, the failover is rolled back. + 'Commit': After the seconds specified in the commitValue setting have elapsed, the failover continues, committing the virtual machines in the recovery site. + 'None': The virtual machines in the VPG being failed over remain in the Before Commit state until either they are committed with Commit a failover, or rolled back with Roll back a failover. + Default is the Site Settings setting. String @@ -7774,61 +7925,52 @@ None - continueOnPreScriptFailure + ContinueOnPreScriptFailure - 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 + Use this switch to continue the Move operation even if the Pre-Script fails to run properly. - Boolean + SwitchParameter - Boolean + SwitchParameter - None + False + + + disableReverseProtection + + 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. + + SwitchParameter + + SwitchParameter + + + False forceShutdown - 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 + By default all virtual machines will attempt to be gracefully shutdown. If a source VM is not running VMware tools or cannot be gracefully shutdown, use this switch to force shutdown the source VMs. - Boolean + SwitchParameter - Boolean + SwitchParameter - None + False - + keepSourceVms - 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 + Use this switch to Prevent the protected virtual machines from being deleted in the protected site. Reverse protection is not automatic with this selection and should reverse protection be required, must be manually configured post commit. - Boolean + SwitchParameter - Boolean + SwitchParameter - None - - - reverseProtection - - 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. - - Boolean - - Boolean - - - None + False vpgName @@ -7842,6 +7984,30 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + @@ -7915,18 +8081,6 @@ None - - reverseProtect - - 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 - - Boolean - - Boolean - - - None - keepSourceVms @@ -7938,6 +8092,39 @@ False + + reverseProtection + + Set this to True to reverse protect the VPG(s) to the source site. If not set, will use selection made during move initiation. True or False + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + @@ -7953,17 +8140,17 @@ False - - reverseProtect + + reverseProtection Set this to True to reverse protect the VPG(s) to the source site. If not set, will use selection made during move initiation. True or False - Boolean + SwitchParameter - Boolean + SwitchParameter - None + False vpgName @@ -7977,6 +8164,30 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + @@ -8050,6 +8261,28 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + @@ -8065,6 +8298,30 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + @@ -8356,6 +8613,28 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + New-ZertoVpg @@ -8588,6 +8867,28 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + New-ZertoVpg @@ -8820,6 +9121,28 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + New-ZertoVpg @@ -9052,6 +9375,28 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + New-ZertoVpg @@ -9284,6 +9629,28 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + New-ZertoVpg @@ -9516,6 +9883,28 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + @@ -9771,6 +10160,30 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + @@ -9920,21 +10333,65 @@ False + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + New-ZertoVpgSettingsIdentifier - + vpgIdentifier 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. - String + String[] - String + String[] None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + @@ -9950,18 +10407,42 @@ False - + vpgIdentifier 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. - String + String[] - String + String[] None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + @@ -10015,6 +10496,279 @@ + + + Remove-ZertoPeerSite + Remove + ZertoPeerSite + + Unpair the current site from another site paired to it. + + + + Unpair the current site from another site paired to it. + + + + Remove-ZertoPeerSite + + hostName + + IP address of the peer site to be removed from the connected site + + String[] + + String[] + + + None + + + keepTargetDisks + + Specify this switch to Keep the target replica disks for any VPGs replicating between the sites as the VPGs will be deleted by unpairing the sites. If this switch is not used, the target replica disks will be deleted + + + SwitchParameter + + + False + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + + Remove-ZertoPeerSite + + keepTargetDisks + + Specify this switch to Keep the target replica disks for any VPGs replicating between the sites as the VPGs will be deleted by unpairing the sites. If this switch is not used, the target replica disks will be deleted + + + SwitchParameter + + + False + + + peerSiteName + + Name of the peer site to be removed from the connected site + + String[] + + String[] + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + + Remove-ZertoPeerSite + + keepTargetDisks + + Specify this switch to Keep the target replica disks for any VPGs replicating between the sites as the VPGs will be deleted by unpairing the sites. If this switch is not used, the target replica disks will be deleted + + + SwitchParameter + + + False + + + siteIdentifier + + Identifier of the site to be removed from the connected site + + String[] + + String[] + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + + + + + + hostName + + IP address of the peer site to be removed from the connected site + + String[] + + String[] + + + None + + + keepTargetDisks + + Specify this switch to Keep the target replica disks for any VPGs replicating between the sites as the VPGs will be deleted by unpairing the sites. If this switch is not used, the target replica disks will be deleted + + SwitchParameter + + SwitchParameter + + + False + + + peerSiteName + + Name of the peer site to be removed from the connected site + + String[] + + String[] + + + None + + + siteIdentifier + + Identifier of the site to be removed from the connected site + + String[] + + String[] + + + None + + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> Remove-ZertoPeerSite -siteIdentifier "MySiteIdentifier" + + Unpairs the current site for the site with siteIdentifier "MySiteIdentifier" + + + + -------------------------- Example 2 -------------------------- + PS C:\> Remove-ZertoPeerSite -peerSiteName "Recovery Site" + + Unpairs the current site for the site with site name "Recovery Site" + + + + -------------------------- Example 1 -------------------------- + PS C:\> Remove-ZertoPeerSite -hostName "192.168.1.100" + + Unpairs the current site for the site with ip address "192.168.1.100" + + + + + + Online Version: + https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Remove-ZertoPeerSite.md + + + Zerto REST API Peer Site End Point Documentation + http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/index.html#page/RestfulAPIs%2FStatusAPIs.5.044.html%23 + + + Remove-ZertoVpg @@ -10052,7 +10806,7 @@ False - + vpgidentifier vpgIdentifier(s) of the VPG(s) to delete. @@ -10172,7 +10926,7 @@ False - + vpgidentifier vpgIdentifier(s) of the VPG(s) to delete. @@ -10377,9 +11131,9 @@ - Save-ZertoVpgSettings + Save-ZertoVpgSetting Save - ZertoVpgSettings + ZertoVpgSetting Commits the updated Vpg Settings with the configured Vpg Settings Identifier @@ -10389,8 +11143,8 @@ - Save-ZertoVpgSettings - + Save-ZertoVpgSetting + vpgSettingsIdentifier VpgSettings Identifier to save @@ -10427,7 +11181,7 @@ - + vpgSettingsIdentifier VpgSettings Identifier to save @@ -10492,7 +11246,7 @@ -------------------------- Example 1 -------------------------- - PS C:> Save-ZertoVpgSettings -vpgSettingsIdentifier "MyVpgSettingsIdentifier" + PS C:> Save-ZertoVpgSetting -vpgSettingsIdentifier "MyVpgSettingsIdentifier" Commits vpg settings with vpg settings identifier "MyVpgSettingsIdentifier" @@ -10501,7 +11255,7 @@ Online Version: - https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSettings.md + https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSetting.md Zerto REST API VPG Settings End Point Documentation @@ -10524,7 +11278,7 @@ Set-ZertoAlert - + alertId Alert identifier(s) to be dismissed or undismissed. @@ -10572,7 +11326,7 @@ Set-ZertoAlert - + alertId Alert identifier(s) to be dismissed or undismissed. @@ -10620,7 +11374,7 @@ - + alertId Alert identifier(s) to be dismissed or undismissed. @@ -10894,7 +11648,7 @@ None - + checkpointIdentifier The identifier of the checkpoint to use for cloning. If unspecified, the latest checkpoint will be used. @@ -10930,10 +11684,32 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + - + checkpointIdentifier The identifier of the checkpoint to use for cloning. If unspecified, the latest checkpoint will be used. @@ -10981,6 +11757,30 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + @@ -11054,7 +11854,7 @@ None - + checkpointIdentifier The identifier of the checkpoint to use for testing. If unspecified, the latest checkpoint will be used. @@ -11078,10 +11878,32 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + - + checkpointIdentifier The identifier of the checkpoint to use for testing. If unspecified, the latest checkpoint will be used. @@ -11117,6 +11939,30 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + @@ -11190,6 +12036,28 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + @@ -11205,6 +12073,30 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + @@ -11302,6 +12194,28 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + + SwitchParameter + + + False + @@ -11341,6 +12255,30 @@ None + + Confirm + + Prompts you for confirmation before running the cmdlet. + + SwitchParameter + + SwitchParameter + + + False + + + WhatIf + + Shows what would happen if the cmdlet runs. The cmdlet is not run. + + SwitchParameter + + SwitchParameter + + + False + diff --git a/ZertoApiWrapper/ZertoApiWrapper.psd1 b/ZertoApiWrapper/ZertoApiWrapper.psd1 index 58177f0..c86a32b 100644 --- a/ZertoApiWrapper/ZertoApiWrapper.psd1 +++ b/ZertoApiWrapper/ZertoApiWrapper.psd1 @@ -9,7 +9,7 @@ @{ # Script module or binary module file associated with this manifest. - RootModule = 'ZertoApiWrapper.psm1' + RootModule = '.\ZertoApiWrapper.psm1' # Version number of this module. ModuleVersion = '0.0.1' @@ -69,16 +69,16 @@ # NestedModules = @() # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. - FunctionsToExport = '*' + FunctionsToExport = 'Add-ZertoPeerSite', 'Checkpoint-ZertoVpg', 'Connect-ZertoServer', 'Disconnect-ZertoServer', 'Edit-ZertoVra', 'Export-ZertoVpg', 'Get-ZertoAlert', 'Get-ZertoDatastore', 'Get-ZertoEvent', 'Get-ZertoLicense', 'Get-ZertoLocalSite', 'Get-ZertoPeerSite', 'Get-ZertoProtectedVm', 'Get-ZertoRecoveryReport', 'Get-ZertoResourcesReport', 'Get-ZertoServiceProfile', 'Get-ZertoTask', 'Get-ZertoUnprotectedVm', 'Get-ZertoVirtualizationSite', 'Get-ZertoVolume', 'Get-ZertoVpg', 'Get-ZertoVpgSetting', 'Get-ZertoVra', 'Get-ZertoZorg', 'Get-ZertoZsspSession', 'Import-ZertoVpg', 'Install-ZertoVra', 'Invoke-ZertoFailover', 'Invoke-ZertoFailoverCommit', 'Invoke-ZertoFailoverRollback', 'Invoke-ZertoForceSync', 'Invoke-ZertoMove', 'Invoke-ZertoMoveCommit', 'Invoke-ZertoMoveRollback', 'New-ZertoVpg', 'New-ZertoVpgSettingsIdentifier', 'Remove-ZertoPeerSite', 'Remove-ZertoVpg', 'Resume-ZertoVpg', 'Save-ZertoVpgSettings', 'Set-ZertoAlert', 'Set-ZertoLicense', 'Start-ZertoCloneVpg', 'Start-ZertoFailoverTest', 'Stop-ZertoCloneVpg', 'Stop-ZertoFailoverTest', 'Suspend-ZertoVpg', 'Uninstall-ZertoVra' # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. - CmdletsToExport = '*' + CmdletsToExport = @() # Variables to export from this module - VariablesToExport = '*' + VariablesToExport = @() # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. - AliasesToExport = '*' + AliasesToExport = @() # DSC resources to export from this module # DscResourcesToExport = @() diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..46201e1 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,93 @@ +# Starter pipeline +# Start with a minimal pipeline that you can customize to build and deploy your code. +# Add steps that build, run tests, deploy, and more: +# https://aka.ms/yaml + +name: $(TeamProject)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.rr) + +# Trigger CI on commit to master and develop branches +trigger: + branches: + include: + - master + - develop + - TestingBranch + +# Trigger CI on pull requests to master and develop branches +pr: + - master + - develop + - TestingBranch + +jobs: + # Windows Build Job + - job: Build_PS_Win2016 + timeoutInMinutes: 10 + cancelTimeoutInMinutes: 2 + pool: + vmImage: vs2017-win2016 + steps: + # Run build.ps1 script in PowerShell Core + - pwsh: | + .\build.ps1 -Verbose + displayName: 'Build and Test' + # Upload test results to Azure Pipeline + - task: PublishTestResults@2 + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/TestResults.xml' + testRunTitle: 'PS_Win2016' + displayName: 'Publish Test Results' + condition: always() + + # Linux Build Job + - job: Build_PSCore_Ubuntu1604 + timeoutInMinutes: 10 + cancelTimeoutInMinutes: 2 + pool: + vmImage: ubuntu-16.04 + steps: + # Run build.ps1 script in PowerShell Core + - pwsh: | + .\build.ps1 -verbose + displayName: 'Build and Test' + # Upload test results to Azure Pipeline + - task: PublishTestResults@2 + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/TestResults.xml' + testRunTitle: 'PSCore_Ubuntu1604' + displayName: 'Publish Test Results' + condition: always() + - task: PublishPipelineArtifact@0 + displayName: 'Publish compiled module Artifact' + inputs: + artifactName: 'ZertoApiWrapper' + targetPath: ./temp + condition: always() + - task: PublishPipelineArtifact@0 + displayName: 'Publish Data' + inputs: + artifactName: 'ReleaseData' + targetPath: ./publish + condition: always() + + # MacOS Build Job + - job: Build_PSCore_MacOS1013 + timeoutInMinutes: 10 + cancelTimeoutInMinutes: 2 + pool: + vmImage: xcode9-macos10.13 + steps: + # Run build.ps1 script in PowerShell Core + - pwsh: | + .\build.ps1 -verbose + displayName: 'Build and Test' + # Upload test results to Azure Pipeline + - task: PublishTestResults@2 + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/TestResults.xml' + testRunTitle: 'PSCore_MacOS1013' + displayName: 'Publish Test Results' + condition: always() diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..9ce90cf --- /dev/null +++ b/build.ps1 @@ -0,0 +1,16 @@ +# Bootstrap the environment +$null = Get-PackageProvider -Name NuGet -ForceBootstrap + +if (-not (Get-Module -Name PSDepend -ListAvailable)) { + Install-Module -Name PSDepend -Scope CurrentUser -Force -Confirm:$false +} + +Import-Module -Name PSDepend +Invoke-PSDepend ` + -Path $PSScriptRoot ` + -Force ` + -Import ` + -Install ` + -Tags 'Bootstrap' + +Invoke-Build . diff --git a/docs/Add-ZertoPeerSite.md b/docs/Add-ZertoPeerSite.md index 4d98d40..c05f0ef 100644 --- a/docs/Add-ZertoPeerSite.md +++ b/docs/Add-ZertoPeerSite.md @@ -93,7 +93,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Checkpoint-ZertoVpg.md b/docs/Checkpoint-ZertoVpg.md index 1b95cf0..3c08107 100644 --- a/docs/Checkpoint-ZertoVpg.md +++ b/docs/Checkpoint-ZertoVpg.md @@ -61,7 +61,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Connect-ZertoServer.md b/docs/Connect-ZertoServer.md index 3cd7c14..810bdb0 100644 --- a/docs/Connect-ZertoServer.md +++ b/docs/Connect-ZertoServer.md @@ -68,7 +68,7 @@ Default value is 9669. ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: port Required: False Position: 1 @@ -83,7 +83,7 @@ IP address or FQDN of your Zerto Management Server ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: server, zvm Required: True Position: 0 @@ -93,7 +93,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Disconnect-ZertoServer.md b/docs/Disconnect-ZertoServer.md index 4d56d90..814d8cc 100644 --- a/docs/Disconnect-ZertoServer.md +++ b/docs/Disconnect-ZertoServer.md @@ -31,7 +31,7 @@ Disconnects from the Zerto Server ## PARAMETERS ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Edit-ZertoVra.md b/docs/Edit-ZertoVra.md index bf40004..be40e81 100644 --- a/docs/Edit-ZertoVra.md +++ b/docs/Edit-ZertoVra.md @@ -110,7 +110,7 @@ Identifier of the VRA to be updated. ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: vraId Required: True Position: Named @@ -166,7 +166,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Export-ZertoVpg.md b/docs/Export-ZertoVpg.md index 9bd5be3..52e6dc5 100644 --- a/docs/Export-ZertoVpg.md +++ b/docs/Export-ZertoVpg.md @@ -1,105 +1,105 @@ ---- -external help file: ZertoApiWrapper-help.xml -Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/Master/docs/Export-ZertoVpg.md -schema: 2.0.0 ---- - -# Export-ZertoVpg - -## SYNOPSIS -Exports a VPG Settings Object to a JSON file. This file can be used to re-import the VPG at a later time. - -## SYNTAX - -### namedVpgs -``` -Export-ZertoVpg -outputFolder [-vpgName ] [] -``` - -### allVpgs -``` -Export-ZertoVpg -outputFolder [-allVpgs] [] -``` - -## DESCRIPTION -Exports a VPG Settings Object to a JSON file. This file can be used to re-import the VPG at a later time. - -## EXAMPLES - -### Example 1 -```powershell -PS C:> Export-ZertoVpg -outputFolder "C:\ZertoVPGs" -vpgName "My Vpg", "My Other Vpg" -``` - -Exports VPG settings for VPGs "My Vpg" and "My Other Vpg". Each settings object will be placed inside a JSON file at C:\ZertoVPGs\ with the name of the file being the name of the VPG. - -### Example 2 -```powershell -PS C:> Export-ZertoVpg -outputFolder "C:\ZertoVPGs" -allVpgs -``` - -Exports VPG settings for all Vpgs replicated to or from this site. Each settings object will be placed inside a JSON file at C:\ZertoVPGs\ with the name of the file being the name of the VPG. If a VPG is in an un-editable state, it cannot be exported. - -## PARAMETERS - -### -allVpgs -Export all VPGs at this site - -```yaml -Type: SwitchParameter -Parameter Sets: allVpgs -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False -``` - -### -outputFolder -Location where to dump the resulting JSON files containing the VPG Settings - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -vpgName -Name(s) of the VPG(s) to be exported - -```yaml -Type: String[] -Parameter Sets: namedVpgs -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Management.Automation.SwitchParameter - -## OUTPUTS - -### System.Object -## NOTES - -## RELATED LINKS - -[Zerto REST API VPG Settings End Point Documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/RestfulAPIs/StatusAPIs.5.108.html#) +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/wcarroll/ZertoApiWrapper/blob/Master/docs/Export-ZertoVpg.md +schema: 2.0.0 +--- + +# Export-ZertoVpg + +## SYNOPSIS +Exports a VPG Settings Object to a JSON file. This file can be used to re-import the VPG at a later time. + +## SYNTAX + +### namedVpgs +``` +Export-ZertoVpg -outputPath -vpgName [] +``` + +### allVpgs +``` +Export-ZertoVpg -outputPath [-allVpgs] [] +``` + +## DESCRIPTION +Exports a VPG Settings Object to a JSON file. This file can be used to re-import the VPG at a later time. + +## EXAMPLES + +### Example 1 +```powershell +PS C:> Export-ZertoVpg -outputPath "C:\ZertoVPGs" -vpgName "My Vpg", "My Other Vpg" +``` + +Exports VPG settings for VPGs "My Vpg" and "My Other Vpg". Each settings object will be placed inside a JSON file at C:\ZertoVPGs\ with the name of the file being the name of the VPG. + +### Example 2 +```powershell +PS C:> Export-ZertoVpg -outputPath "C:\ZertoVPGs" -allVpgs +``` + +Exports VPG settings for all Vpgs replicated to or from this site. Each settings object will be placed inside a JSON file at C:\ZertoVPGs\ with the name of the file being the name of the VPG. If a VPG is in an un-editable state, it cannot be exported. + +## PARAMETERS + +### -allVpgs +Export all VPGs at this site + +```yaml +Type: SwitchParameter +Parameter Sets: allVpgs +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName, ByValue) +Accept wildcard characters: False +``` + +### -outputPath +Location where to dump the resulting JSON files containing the VPG Settings + +```yaml +Type: String +Parameter Sets: (All) +Aliases: outputFolder + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgName +Name(s) of the VPG(s) to be exported + +```yaml +Type: String[] +Parameter Sets: namedVpgs +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.Management.Automation.SwitchParameter + +## OUTPUTS + +### System.Object +## NOTES + +## RELATED LINKS + +[Zerto REST API VPG Settings End Point Documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/RestfulAPIs/StatusAPIs.5.108.html#) diff --git a/docs/Get-ZertoAlert.md b/docs/Get-ZertoAlert.md index 905ba14..1dfd749 100644 --- a/docs/Get-ZertoAlert.md +++ b/docs/Get-ZertoAlert.md @@ -164,7 +164,7 @@ Returns alerts for the specified helpIdentifier ```yaml Type: String Parameter Sets: filter -Aliases: +Aliases: helpId Required: False Position: Named @@ -239,7 +239,7 @@ Returns alerts for the specified siteIdentifier ```yaml Type: String Parameter Sets: filter -Aliases: +Aliases: siteId Required: False Position: Named @@ -270,7 +270,7 @@ Returns alerts for the specified vraIdentifier ```yaml Type: String Parameter Sets: filter -Aliases: +Aliases: vpgId Required: False Position: Named @@ -285,7 +285,7 @@ Returns alerts for the specified zorgIdentifier ```yaml Type: String Parameter Sets: filter -Aliases: +Aliases: zorgId Required: False Position: Named @@ -295,7 +295,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Get-ZertoDatastore.md b/docs/Get-ZertoDatastore.md index 9c81382..8db8390 100644 --- a/docs/Get-ZertoDatastore.md +++ b/docs/Get-ZertoDatastore.md @@ -49,7 +49,7 @@ datastoreIdentifier or array of datastoreIdentifiers to be queried ```yaml Type: String[] Parameter Sets: datastoreIdentifier -Aliases: +Aliases: datastoreId Required: False Position: Named @@ -59,7 +59,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Get-ZertoEvent.md b/docs/Get-ZertoEvent.md index f512d16..3e0c546 100644 --- a/docs/Get-ZertoEvent.md +++ b/docs/Get-ZertoEvent.md @@ -81,7 +81,7 @@ The internal alert identifier for the Event ```yaml Type: String Parameter Sets: filter -Aliases: +Aliases: alertId Required: False Position: Named @@ -106,9 +106,7 @@ Accept wildcard characters: False ``` ### -category -The type of event to return. -This filter behaves in the same way as the eventCategory filter. -Possible Values are: Possible Values are: '0' or 'All', '1' or 'Events', '2' or 'Alerts' +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' ```yaml Type: String @@ -155,8 +153,7 @@ Accept wildcard characters: False ``` ### -entityType -The type of entity for which you wish to return results. -Possible Values are: '0' or 'VPG', '1' or 'VRA', '2' or 'Unknown', or '3' or 'Site' +The type of entity for which you wish to return results. Possible Values are: 'VPG', 'VRA', 'Unknown', or 'Site' ```yaml Type: String @@ -171,10 +168,7 @@ Accept wildcard characters: False ``` ### -eventCategory -This filter behaves in the same way as the category filter. -If both category and eventCategory filters are specified, only the category filter value is used and the eventCategory filter value is ignored. -The type of event to return. -Possible Values are: '0' or 'All', '1' or 'Events', '2' or 'Alerts' +This filter behaves in the same way as the category filter. If both category and eventCategory filters are specified, only the category filter value is used and the eventCategory filter value is ignored. The type of event to return. Possible Values are: 'All', 'Events', 'Alerts' ```yaml Type: String @@ -226,7 +220,7 @@ The internal site identifier for which you want to return events. ```yaml Type: String Parameter Sets: filter -Aliases: +Aliases: siteId Required: False Position: Named @@ -304,7 +298,7 @@ The name of the VPG for which you want to return events. ```yaml Type: String Parameter Sets: filter -Aliases: +Aliases: vpgName Required: False Position: Named @@ -319,7 +313,7 @@ The identifier of the VPG for which you want to return events. ```yaml Type: String Parameter Sets: filter -Aliases: +Aliases: vpgId Required: False Position: Named @@ -334,7 +328,7 @@ The identifier of the ZORG, Zerto organization, defined in the Zerto Cloud Manag ```yaml Type: String Parameter Sets: filter -Aliases: +Aliases: zorgId Required: False Position: Named @@ -344,7 +338,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Get-ZertoLicense.md b/docs/Get-ZertoLicense.md index 477b8f1..f864948 100644 --- a/docs/Get-ZertoLicense.md +++ b/docs/Get-ZertoLicense.md @@ -31,7 +31,7 @@ Retrieve information about a Zerto Virtual Replication license. ## PARAMETERS ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Get-ZertoLocalSite.md b/docs/Get-ZertoLocalSite.md index 6b0c6fa..ad0fdd9 100644 --- a/docs/Get-ZertoLocalSite.md +++ b/docs/Get-ZertoLocalSite.md @@ -46,7 +46,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Get-ZertoPeerSite.md b/docs/Get-ZertoPeerSite.md index 1e127de..9142de4 100644 --- a/docs/Get-ZertoPeerSite.md +++ b/docs/Get-ZertoPeerSite.md @@ -152,7 +152,7 @@ The identifier(s) of the peer site(s) for which information is to be returned. ```yaml Type: String[] Parameter Sets: siteIdentifier -Aliases: +Aliases: siteId Required: True Position: Named @@ -162,7 +162,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Get-ZertoProtectedVm.md b/docs/Get-ZertoProtectedVm.md index db23650..1d814ea 100644 --- a/docs/Get-ZertoProtectedVm.md +++ b/docs/Get-ZertoProtectedVm.md @@ -82,8 +82,7 @@ Accept wildcard characters: False ``` ### -priority -The priority specified for the VPG. -Possible values are: '0' or 'Low', '1' or 'Medium', '2' or 'High' +The priority specified for the VPG. Possible values are: 'Low', 'Medium', or 'High' ```yaml Type: String @@ -103,7 +102,7 @@ The identifier of the protected site where the VPG virtual machines are protecte ```yaml Type: String Parameter Sets: filter -Aliases: +Aliases: protectedSiteId Required: False Position: Named @@ -134,7 +133,7 @@ The identifier of the recovery site where the VPG virtual machines are recovered ```yaml Type: String Parameter Sets: filter -Aliases: +Aliases: recoverySiteId Required: False Position: Named @@ -198,7 +197,7 @@ vmIdentifier(s) for which to return information ```yaml Type: String[] Parameter Sets: vmIdentifier -Aliases: +Aliases: vmId Required: True Position: Named @@ -238,7 +237,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Get-ZertoRecoveryReport.md b/docs/Get-ZertoRecoveryReport.md index a8c2e32..0a586f7 100644 --- a/docs/Get-ZertoRecoveryReport.md +++ b/docs/Get-ZertoRecoveryReport.md @@ -175,7 +175,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Get-ZertoResourcesReport.md b/docs/Get-ZertoResourcesReport.md index 8e16b77..bf12822 100644 --- a/docs/Get-ZertoResourcesReport.md +++ b/docs/Get-ZertoResourcesReport.md @@ -304,7 +304,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Get-ZertoServiceProfile.md b/docs/Get-ZertoServiceProfile.md index 4b19813..98a0c97 100644 --- a/docs/Get-ZertoServiceProfile.md +++ b/docs/Get-ZertoServiceProfile.md @@ -47,7 +47,7 @@ The service profile ID for which information should be returned. ```yaml Type: String[] Parameter Sets: serviceProfileId -Aliases: +Aliases: serviceProfileIdentifier Required: False Position: Named @@ -62,7 +62,7 @@ The identifier of the site for which service profiles should be returned. ```yaml Type: String Parameter Sets: siteIdentifier -Aliases: +Aliases: siteId Required: False Position: Named @@ -72,7 +72,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Get-ZertoTask.md b/docs/Get-ZertoTask.md index 6229464..8e10bcd 100644 --- a/docs/Get-ZertoTask.md +++ b/docs/Get-ZertoTask.md @@ -123,8 +123,7 @@ Accept wildcard characters: False ``` ### -status -The status of the task. -Possible values are: '1' or 'InProgress', '3' or 'Paused', '4' or 'Failed', '6' or 'Completed', '7' or 'Cancelling' +The status of the task. Possible values are: 'InProgress', 'Paused', 'Failed', 'Completed', or 'Cancelling' ```yaml Type: String @@ -144,7 +143,7 @@ The identifier(s) for which task information is to be returned. ```yaml Type: String[] Parameter Sets: taskIdentifier -Aliases: +Aliases: taskId Required: False Position: Named @@ -186,7 +185,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Get-ZertoUnprotectedVm.md b/docs/Get-ZertoUnprotectedVm.md index b1d43bd..ba21f4f 100644 --- a/docs/Get-ZertoUnprotectedVm.md +++ b/docs/Get-ZertoUnprotectedVm.md @@ -31,7 +31,7 @@ Returns all virtual machines at the site not currently protected in a virtual pr ## PARAMETERS ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Get-ZertoVirtualizationSite.md b/docs/Get-ZertoVirtualizationSite.md index 59d46a0..88f78cf 100644 --- a/docs/Get-ZertoVirtualizationSite.md +++ b/docs/Get-ZertoVirtualizationSite.md @@ -8,7 +8,8 @@ schema: 2.0.0 # Get-ZertoVirtualizationSite ## SYNOPSIS -{{Fill in the Synopsis}} + +Returns information about the hypervisor site where the API is run and all the sites paired with this site. The information returned can be tailored to specific information about the resources managed at a specified site. ## SYNTAX @@ -68,16 +69,38 @@ Get-ZertoVirtualizationSite -siteIdentifier [] ``` ## DESCRIPTION -{{Fill in the Description}} + +Returns information about the hypervisor site where the API is run and all the sites paired with this site. The information returned can be tailored to specific information about the resources managed at a specified site. ## EXAMPLES ### Example 1 ```powershell -PS C:\> {{ Add example code here }} +PS C:\> Get-ZertoVirtualizationSite -siteIdentifier "MySiteIdentifier" ``` -{{ Add example description here }} +Returns information about the site with identifier "MySiteIdentifier" + +### Example 2 +```powershell +PS C:\> Get-ZertoVirtualizationSite -siteIdentifier "MySiteIdentifier" -datastoreClusters +``` + +Returns information about datastore clusters at site with site identifier "MySiteidentifier" + +### Example 3 +```powershell +PS C:\> Get-ZertoVirtualizationSite -siteIdentifier "MySiteIdentifier" -datastores +``` + +Returns information about datastores at site with site identifier "MySiteidentifier" + +### Example 4 +```powershell +PS C:\> Get-ZertoVirtualizationSite -siteIdentifier "MySiteIdentifier" -devices +``` + +Returns information about devices at site with site identifier "MySiteidentifier" ## PARAMETERS @@ -162,7 +185,7 @@ The identifier of the host at the selected site to return information for only o ```yaml Type: String Parameter Sets: devices, hosts -Aliases: +Aliases: hostId Required: False Position: Named @@ -223,7 +246,7 @@ The identifier of the Zerto Virtual Manager site. ```yaml Type: String Parameter Sets: folders, devices, vms, resourcePools, networks, hosts, hostClusters, datastores, datastoreClusters, siteIdentifier -Aliases: +Aliases: siteId Required: True Position: Named @@ -248,7 +271,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Get-ZertoVolume.md b/docs/Get-ZertoVolume.md index 91f3d52..5663b51 100644 --- a/docs/Get-ZertoVolume.md +++ b/docs/Get-ZertoVolume.md @@ -57,7 +57,7 @@ The identifier of the datastore. ```yaml Type: String Parameter Sets: filter -Aliases: +Aliases: datastoreId, dsId Required: False Position: Named @@ -72,7 +72,7 @@ The identifier of the owning virtual machine. ```yaml Type: String Parameter Sets: filter -Aliases: +Aliases: owningVmId Required: False Position: Named @@ -87,7 +87,7 @@ The identifier of the protected virtual machine. ```yaml Type: String Parameter Sets: filter -Aliases: +Aliases: protectedVmId Required: False Position: Named @@ -118,7 +118,7 @@ The identifier of the VPG. ```yaml Type: String Parameter Sets: filter -Aliases: +Aliases: vpgId Required: False Position: Named @@ -128,7 +128,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Get-ZertoVpg.md b/docs/Get-ZertoVpg.md index 737456a..d574889 100644 --- a/docs/Get-ZertoVpg.md +++ b/docs/Get-ZertoVpg.md @@ -265,8 +265,7 @@ Accept wildcard characters: False ### -priority -The VPG priority. -Possible values are: '0' or 'Low', '1' or 'Medium', '2' or 'High' +The VPG priority. Possible values are: 'Low', 'Medium', 'High' ```yaml Type: String @@ -321,7 +320,7 @@ The identifier(s) of the Virtual Protection Group to return ```yaml Type: String[] Parameter Sets: stats, checkpoints, protectionGroupIdentifier -Aliases: +Aliases: vpgId, protectionGroupId, pgId Required: True Position: Named @@ -497,7 +496,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Get-ZertoVpgSetting.md b/docs/Get-ZertoVpgSetting.md index 989e250..e9a05dd 100644 --- a/docs/Get-ZertoVpgSetting.md +++ b/docs/Get-ZertoVpgSetting.md @@ -19,94 +19,94 @@ Get-ZertoVpgSetting [] ### volumeIdentifier ``` -Get-ZertoVpgSetting -vpgSettingsIdentifier -vmIdentifier -volumeIdentifier +Get-ZertoVpgSetting -vpgSettingsIdentifier -vmIdentifier -volumeIdentifier [] ``` ### volumes ``` -Get-ZertoVpgSetting -vpgSettingsIdentifier -vmIdentifier [-volumes] [] +Get-ZertoVpgSetting -vpgSettingsIdentifier -vmIdentifier [-volumes] [] ``` ### nicIdentifier ``` -Get-ZertoVpgSetting -vpgSettingsIdentifier -vmIdentifier -nicIdentifier +Get-ZertoVpgSetting -vpgSettingsIdentifier -vmIdentifier -nicIdentifier [] ``` ### nics ``` -Get-ZertoVpgSetting -vpgSettingsIdentifier -vmIdentifier [-nics] [] +Get-ZertoVpgSetting -vpgSettingsIdentifier -vmIdentifier [-nics] [] ``` ### vmIdentifier ``` -Get-ZertoVpgSetting -vpgSettingsIdentifier -vmIdentifier [] +Get-ZertoVpgSetting -vpgSettingsIdentifier -vmIdentifier [] ``` ### vms ``` -Get-ZertoVpgSetting -vpgSettingsIdentifier [-vms] [] +Get-ZertoVpgSetting -vpgSettingsIdentifier [-vms] [] ``` ### scripting ``` -Get-ZertoVpgSetting -vpgSettingsIdentifier [-scripting] [] +Get-ZertoVpgSetting -vpgSettingsIdentifier [-scripting] [] ``` ### recovery ``` -Get-ZertoVpgSetting -vpgSettingsIdentifier [-rcovery] [] +Get-ZertoVpgSetting -vpgSettingsIdentifier [-rcovery] [] ``` ### priority ``` -Get-ZertoVpgSetting -vpgSettingsIdentifier [-priority] [] +Get-ZertoVpgSetting -vpgSettingsIdentifier [-priority] [] ``` ### networks ``` -Get-ZertoVpgSetting -vpgSettingsIdentifier [-networks] [] +Get-ZertoVpgSetting -vpgSettingsIdentifier [-networks] [] ``` ### journal ``` -Get-ZertoVpgSetting -vpgSettingsIdentifier [-journal] [] +Get-ZertoVpgSetting -vpgSettingsIdentifier [-journal] [] ``` ### bootGroup ``` -Get-ZertoVpgSetting -vpgSettingsIdentifier [-bootgroup] [] +Get-ZertoVpgSetting -vpgSettingsIdentifier [-bootgroup] [] ``` ### basic ``` -Get-ZertoVpgSetting -vpgSettingsIdentifier [-basic] [] +Get-ZertoVpgSetting -vpgSettingsIdentifier [-basic] [] ``` ### schedulerPeriod ``` -Get-ZertoVpgSetting -vpgSettingsIdentifier [-schedulerPeriod] [] +Get-ZertoVpgSetting -vpgSettingsIdentifier [-schedulerPeriod] [] ``` ### retentionPeriod ``` -Get-ZertoVpgSetting -vpgSettingsIdentifier [-retentionPeriod] [] +Get-ZertoVpgSetting -vpgSettingsIdentifier [-retentionPeriod] [] ``` ### dayOfWeek ``` -Get-ZertoVpgSetting -vpgSettingsIdentifier [-dayOfWeek] [] +Get-ZertoVpgSetting -vpgSettingsIdentifier [-dayOfWeek] [] ``` ### backup ``` -Get-ZertoVpgSetting -vpgSettingsIdentifier [-backup] [] +Get-ZertoVpgSetting -vpgSettingsIdentifier [-backup] [] ``` ### vpgSettingsIdentifier ``` -Get-ZertoVpgSetting -vpgSettingsIdentifier [] +Get-ZertoVpgSetting -vpgSettingsIdentifier [] ``` ## DESCRIPTION @@ -118,35 +118,35 @@ It is important to note that only once a VPG settings object has been created, w ### Example 1 ```powershell -PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" +PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" ``` Returns all current settings for vpgSettingsIdentifier "MySettingsIdentifier" ### Example 2 ```powershell -PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" +PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" ``` Returns all current vm level settings for the vmIdentifier "MyVmId" in vpgSettingsIdentifier "MySettingsIdentifier" ### Example 3 ```powershell -PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" -volumes +PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -vmIdentifier "MyVmId" -volumes ``` Returns current vm level settings for volumes for vmId "MyVmId" in vpgSettingsIdentifier "MySettingsIdentifier" ### Example 4 ```powershell -PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -nics +PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -nics ``` Returns current vm level settings for nics for vmId "MyVmId" in vpgSettingsIdentifier "MySettingsIdentifier" ### Example 5 ```powershell -PS C:\> Get-ZertoVpgSettings -vpgSettingsIdentifier "MySettingsIdentifier" -basic +PS C:\> Get-ZertoVpgSetting -vpgSettingsIdentifier "MySettingsIdentifier" -basic ``` Returns current basic settings for vpgSettingsIdentifier "MySettingsIdentifier" @@ -249,7 +249,7 @@ Return NIC information for specified NIC of the specified VM ```yaml Type: String Parameter Sets: nicIdentifier -Aliases: +Aliases: nicId Required: True Position: Named @@ -354,7 +354,7 @@ VM Identifier ```yaml Type: String Parameter Sets: volumeIdentifier, volumes, nicIdentifier, nics, vmIdentifier -Aliases: +Aliases: vmId Required: True Position: Named @@ -384,7 +384,7 @@ Return volume information for the specified volume of the specified VM ```yaml Type: String Parameter Sets: volumeIdentifier -Aliases: +Aliases: volumeId Required: True Position: Named @@ -412,31 +412,19 @@ Accept wildcard characters: False The identifier of the VPG settings object for which information is retrieved. ```yaml -Type: String -Parameter Sets: volumeIdentifier, volumes, nicIdentifier, nics, vmIdentifier, vms, scripting, recovery, priority, networks, journal, bootGroup -Aliases: +Type: String[] +Parameter Sets: volumeIdentifier, volumes, nicIdentifier, nics, vmIdentifier, vms, scripting, recovery, priority, networks, journal, bootGroup, basic, schedulerPeriod, retentionPeriod, dayOfWeek, backup, vpgSettingsIdentifier +Aliases: vpgSettingsId, settingsId Required: True Position: Named Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -```yaml -Type: String -Parameter Sets: basic, schedulerPeriod, retentionPeriod, dayOfWeek, backup, vpgSettingsIdentifier -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) +Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Get-ZertoVra.md b/docs/Get-ZertoVra.md index 1e3bf10..676e491 100644 --- a/docs/Get-ZertoVra.md +++ b/docs/Get-ZertoVra.md @@ -201,7 +201,7 @@ Returns information for provided VRA identifier(s) ```yaml Type: String[] Parameter Sets: vraIdentifier -Aliases: +Aliases: vraId Required: False Position: Named @@ -241,7 +241,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Get-ZertoZorg.md b/docs/Get-ZertoZorg.md index bb59509..5ddcd16 100644 --- a/docs/Get-ZertoZorg.md +++ b/docs/Get-ZertoZorg.md @@ -49,7 +49,7 @@ Identifier(s) of the ZORG. ```yaml Type: String[] Parameter Sets: zorgIdentifier -Aliases: +Aliases: zorgId Required: False Position: Named @@ -59,7 +59,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Get-ZertoZsspSession.md b/docs/Get-ZertoZsspSession.md index 1b356b6..09ce28b 100644 --- a/docs/Get-ZertoZsspSession.md +++ b/docs/Get-ZertoZsspSession.md @@ -42,7 +42,7 @@ ZSSP Session Id(s) to get information. ```yaml Type: String[] Parameter Sets: zsspSessionIdentifier -Aliases: +Aliases: zsspSessionId Required: False Position: Named @@ -52,7 +52,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Import-ZertoVpg.md b/docs/Import-ZertoVpg.md index 2649e3d..6d42d89 100644 --- a/docs/Import-ZertoVpg.md +++ b/docs/Import-ZertoVpg.md @@ -1,62 +1,62 @@ ---- -external help file: ZertoApiWrapper-help.xml -Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/Master/docs/Import-ZertoVpg.md -schema: 2.0.0 ---- - -# Import-ZertoVpg - -## SYNOPSIS -Reads in one or more JSON files and imports each one into a VPG. - -## SYNTAX - -``` -Import-ZertoVpg [-settingsFile] [] -``` - -## DESCRIPTION -Reads in one or several JSON files and imports each one into a VPG. Currently this method does not support using pre-seed volumes. We are working through a method to get this working, but it may be a while until this happens. - -## EXAMPLES - -### Example 1 -```powershell -PS C:> Import-ZertoVpg -settingsFile "C:\ZertoVpgs\My Vpg.json" -``` - -Reads in "My Vpg.json", creates a new VPG object, applies all the settings and saves the VPG. - -## PARAMETERS - -### -settingsFile -VPG settings JSON file(s) to import. - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: FullName - -Required: True -Position: 0 -Default value: None -Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String[] - -## OUTPUTS - -### System.Object -## NOTES - -## RELATED LINKS - -[Zerto REST API VPG Settings End Point Documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/RestfulAPIs/StatusAPIs.5.108.html#) +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/wcarroll/ZertoApiWrapper/blob/Master/docs/Import-ZertoVpg.md +schema: 2.0.0 +--- + +# Import-ZertoVpg + +## SYNOPSIS +Reads in one or more JSON files and imports each one into a VPG. + +## SYNTAX + +``` +Import-ZertoVpg [-settingsFile] [] +``` + +## DESCRIPTION +Reads in one or several JSON files and imports each one into a VPG. Currently this method does not support using pre-seed volumes. We are working through a method to get this working, but it may be a while until this happens. + +## EXAMPLES + +### Example 1 +```powershell +PS C:> Import-ZertoVpg -settingsFile "C:\ZertoVpgs\My Vpg.json" +``` + +Reads in "My Vpg.json", creates a new VPG object, applies all the settings and saves the VPG. + +## PARAMETERS + +### -settingsFile +VPG settings JSON file(s) to import. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: FullName + +Required: True +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName, ByValue) +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String[] + +## OUTPUTS + +### System.Object +## NOTES + +## RELATED LINKS + +[Zerto REST API VPG Settings End Point Documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/RestfulAPIs/StatusAPIs.5.108.html#) diff --git a/docs/Install-ZertoVra.md b/docs/Install-ZertoVra.md index c622f86..1e2527e 100644 --- a/docs/Install-ZertoVra.md +++ b/docs/Install-ZertoVra.md @@ -215,7 +215,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Invoke-ZertoFailover.md b/docs/Invoke-ZertoFailover.md index ac3aa84..41edbae 100644 --- a/docs/Invoke-ZertoFailover.md +++ b/docs/Invoke-ZertoFailover.md @@ -14,8 +14,8 @@ Start a failover of a VPG ``` Invoke-ZertoFailover [-vpgName] [[-checkpointIdentifier] ] [[-commitPolicy] ] - [[-commitValue] ] [[-shutdownPolicy] ] [[-timeToWaitBeforeShutdownInSec] ] - [[-reverseProtection] ] [[-vmName] ] [] + [[-shutdownPolicy] ] [[-timeToWaitBeforeShutdownInSec] ] [[-reverseProtection] ] + [[-vmName] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -30,6 +30,13 @@ PS C:\> Invoke-ZertoFailover -vpgName "MyVpg" Start a failover of VPG "MyVpg" with the latest checkpoint and site default policies. +### Example 2 +```powershell +PS C:\> Invoke-ZertoFailover -vpgName "MyVpg" -shutdownPolicy 2 -reverseProtection $false -commitPolicy 'Commit' -timeToWaitBeforeShutdownInSec 7200 +``` + +Start a failover of VPG "MyVpg" with the latest checkpoint. VMs will attempt to be gracefully shutdown and if unsuccessful will be forcibly powered off. After 2 hours, if the VPG has not been committed or rolled back, the VPG will auto commit. Reverse protection will not be enabled. + ## PARAMETERS ### -checkpointIdentifier @@ -38,7 +45,7 @@ Checkpoint Identifier to use as the Point-In-Time to rollback to. ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: checkpointId Required: False Position: 1 @@ -48,11 +55,11 @@ Accept wildcard characters: False ``` ### -commitPolicy -0: After the seconds specified in the commitValue setting have elapsed, the failover is rolled back. +'Rollback': After the seconds specified in the commitValue setting have elapsed, the failover is rolled back. -1: After the seconds specified in the commitValue setting have elapsed, the failover continues, committing the virtual machines in the recovery site. +'Commit': After the seconds specified in the commitValue setting have elapsed, the failover continues, committing the virtual machines in the recovery site. -2: The virtual machines in the VPG being failed over remain in the Before Commit state until either they are committed with Commit a failover, or rolled back with Roll back a failover. +'None': The virtual machines in the VPG being failed over remain in the Before Commit state until either they are committed with Commit a failover, or rolled back with Roll back a failover. Default is the Site Settings setting. @@ -68,22 +75,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -commitValue -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 - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 3 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -reverseProtection True: Enable reverse protection. The virtual machines are recovered on the recovery site and then protected using the default reverse protection settings. @@ -128,10 +119,10 @@ Accept wildcard characters: False ``` ### -timeToWaitBeforeShutdownInSec -Time, in seconds, before VMs are forcibly turned off if the Force Shutdown option is seclected after attempting to gracefully shut down the VMs +Time, in seconds, before the commitPolicy is invoked. Default setting is 3600 seconds (60 Minutes). Min value is 300 seconds (5 minutes). Max Value is 86,400 seconds (24 Hours). ```yaml -Type: Int64 +Type: Int32 Parameter Sets: (All) Aliases: @@ -143,7 +134,7 @@ Accept wildcard characters: False ``` ### -vmName -Name(s) of VMs in the +Name(s) of VMs in the VPG to failover ```yaml Type: String[] @@ -172,8 +163,38 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Invoke-ZertoFailoverCommit.md b/docs/Invoke-ZertoFailoverCommit.md index afdaa91..9f1b3d1 100644 --- a/docs/Invoke-ZertoFailoverCommit.md +++ b/docs/Invoke-ZertoFailoverCommit.md @@ -13,7 +13,7 @@ Commit a running VPG failover ## SYNTAX ``` -Invoke-ZertoFailoverCommit [-vpgName] [-reverseProtect] [] +Invoke-ZertoFailoverCommit [-vpgName] [-reverseProtection] [] ``` ## DESCRIPTION @@ -30,14 +30,14 @@ Commits VPG "MyVpg" without reverse protection ### Example 1 ```powershell -PS C:\> Invoke-ZertoFailoverCommit -vpgName "MyVpg" -reverseProtect +PS C:\> Invoke-ZertoFailoverCommit -vpgName "MyVpg" -reverseProtection ``` Commits a VPG with reverse protection ## PARAMETERS -### -reverseProtect +### -reverseProtection Use this switch to reverse protect the VPG(s) to the source site. ```yaml @@ -68,7 +68,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Invoke-ZertoFailoverRollback.md b/docs/Invoke-ZertoFailoverRollback.md index 6f11cf3..51c8a09 100644 --- a/docs/Invoke-ZertoFailoverRollback.md +++ b/docs/Invoke-ZertoFailoverRollback.md @@ -50,7 +50,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Invoke-ZertoForceSync.md b/docs/Invoke-ZertoForceSync.md index 9260de8..2d88313 100644 --- a/docs/Invoke-ZertoForceSync.md +++ b/docs/Invoke-ZertoForceSync.md @@ -46,7 +46,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Invoke-ZertoMove.md b/docs/Invoke-ZertoMove.md index fb989bf..6239eda 100644 --- a/docs/Invoke-ZertoMove.md +++ b/docs/Invoke-ZertoMove.md @@ -12,10 +12,23 @@ Start a move of a VPG. ## SYNTAX +### main (Default) ``` Invoke-ZertoMove [-vpgName] [[-commitPolicy] ] [[-commitPolicyTimeout] ] - [[-forceShutdown] ] [[-reverseProtection] ] [[-keepSourceVms] ] - [[-continueOnPreScriptFailure] ] [] + [-forceShutdown] [-ContinueOnPreScriptFailure] [-WhatIf] [-Confirm] [] +``` + +### disableReverseProtection +``` +Invoke-ZertoMove [-vpgName] [[-commitPolicy] ] [[-commitPolicyTimeout] ] + [-forceShutdown] [-disableReverseProtection] [-ContinueOnPreScriptFailure] [-WhatIf] [-Confirm] + [] +``` + +### keepSourceVms +``` +Invoke-ZertoMove [-vpgName] [[-commitPolicy] ] [[-commitPolicyTimeout] ] + [-forceShutdown] [-keepSourceVms] [-ContinueOnPreScriptFailure] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -33,10 +46,13 @@ Starts a move operation of VPG "MyVpg" ## PARAMETERS ### -commitPolicy -The policy to use after the move enters a 'Before Commit' state. -If omitted, the site settings default will be applied. -Valid values are: '0' or 'Rollback', '1' or 'Commit', '2' or 'None'. -Please see Zerto API Documentation for additional information. +'Rollback': After the seconds specified in the commitValue setting have elapsed, the failover is rolled back. + +'Commit': After the seconds specified in the commitValue setting have elapsed, the failover continues, committing the virtual machines in the recovery site. + +'None': The virtual machines in the VPG being failed over remain in the Before Commit state until either they are committed with Commit a failover, or rolled back with Roll back a failover. + +Default is the Site Settings setting. ```yaml Type: String @@ -66,15 +82,11 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -continueOnPreScriptFailure -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 +### -ContinueOnPreScriptFailure +Use this switch to continue the Move operation even if the Pre-Script fails to run properly. ```yaml -Type: Boolean +Type: SwitchParameter Parameter Sets: (All) Aliases: @@ -85,15 +97,26 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -forceShutdown -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 +### -disableReverseProtection +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. ```yaml -Type: Boolean +Type: SwitchParameter +Parameter Sets: disableReverseProtection +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -forceShutdown +By default all virtual machines will attempt to be gracefully shutdown. If a source VM is not running VMware tools or cannot be gracefully shutdown, use this switch to force shutdown the source VMs. + +```yaml +Type: SwitchParameter Parameter Sets: (All) Aliases: @@ -105,47 +128,20 @@ Accept wildcard characters: False ``` ### -keepSourceVms -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 +Use this switch to Prevent the protected virtual machines from being deleted in the protected site. Reverse protection is not automatic with this selection and should reverse protection be required, must be manually configured post commit. ```yaml -Type: Boolean -Parameter Sets: (All) +Type: SwitchParameter +Parameter Sets: keepSourceVms Aliases: -Required: False +Required: True Position: 5 Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -reverseProtection -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. - -```yaml -Type: Boolean -Parameter Sets: (All) -Aliases: - -Required: False -Position: 4 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -vpgName Name(s) of the VPG(s) you want to move. @@ -161,8 +157,38 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Invoke-ZertoMoveCommit.md b/docs/Invoke-ZertoMoveCommit.md index 584ee4c..08c6e92 100644 --- a/docs/Invoke-ZertoMoveCommit.md +++ b/docs/Invoke-ZertoMoveCommit.md @@ -13,7 +13,7 @@ Commit a VPG currently undergoing a move operation. ## SYNTAX ``` -Invoke-ZertoMoveCommit [-vpgName] [[-reverseProtect] ] [-keepSourceVms] +Invoke-ZertoMoveCommit [-vpgName] [-reverseProtection] [-keepSourceVms] [-WhatIf] [-Confirm] [] ``` @@ -47,18 +47,16 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -reverseProtect -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 +### -reverseProtection +Set this to True to reverse protect the VPG(s) to the source site. If not set, will use selection made during move initiation. True or False ```yaml -Type: Boolean +Type: SwitchParameter Parameter Sets: (All) Aliases: Required: False -Position: 1 +Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -79,8 +77,38 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Invoke-ZertoMoveRollback.md b/docs/Invoke-ZertoMoveRollback.md index 40b5501..4df0772 100644 --- a/docs/Invoke-ZertoMoveRollback.md +++ b/docs/Invoke-ZertoMoveRollback.md @@ -13,7 +13,7 @@ Rollback a VPG currently undergoing a Move operation ## SYNTAX ``` -Invoke-ZertoMoveRollback [-vpgName] [] +Invoke-ZertoMoveRollback [-vpgName] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -45,8 +45,38 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/New-ZertoVpg.md b/docs/New-ZertoVpg.md index 73d2536..cd68b3d 100644 --- a/docs/New-ZertoVpg.md +++ b/docs/New-ZertoVpg.md @@ -19,7 +19,7 @@ New-ZertoVpg -vpgName [-vpgPriority ] [-journalHistoryInHours < [-rpoInSeconds ] [-testIntervalInMinutes ] [-serviceProfile ] [-useWanCompression ] [-zorg ] -recoveryNetwork -testNetwork [-journalDatastore ] [-journalHardLimitInMb ] [-journalWarningThresholdInMb ] - [] + [-WhatIf] [-Confirm] [] ``` ### recoveryClusterDatastore @@ -29,7 +29,7 @@ New-ZertoVpg -vpgName [-vpgPriority ] [-journalHistoryInHours < [-rpoInSeconds ] [-testIntervalInMinutes ] [-serviceProfile ] [-useWanCompression ] [-zorg ] -recoveryNetwork -testNetwork [-journalDatastore ] [-journalHardLimitInMb ] [-journalWarningThresholdInMb ] - [] + [-WhatIf] [-Confirm] [] ``` ### recoveryHostDatastoreCluster @@ -39,7 +39,7 @@ New-ZertoVpg -vpgName [-vpgPriority ] [-journalHistoryInHours < [-rpoInSeconds ] [-testIntervalInMinutes ] [-serviceProfile ] [-useWanCompression ] [-zorg ] -recoveryNetwork -testNetwork [-journalDatastore ] [-journalHardLimitInMb ] [-journalWarningThresholdInMb ] - [] + [-WhatIf] [-Confirm] [] ``` ### recoveryHostDatastore @@ -49,7 +49,7 @@ New-ZertoVpg -vpgName [-vpgPriority ] [-journalHistoryInHours < [-rpoInSeconds ] [-testIntervalInMinutes ] [-serviceProfile ] [-useWanCompression ] [-zorg ] -recoveryNetwork -testNetwork [-journalDatastore ] [-journalHardLimitInMb ] [-journalWarningThresholdInMb ] - [] + [-WhatIf] [-Confirm] [] ``` ### recoveryResourcePoolDatastoreCluster @@ -59,7 +59,7 @@ New-ZertoVpg -vpgName [-vpgPriority ] [-journalHistoryInHours < [-rpoInSeconds ] [-testIntervalInMinutes ] [-serviceProfile ] [-useWanCompression ] [-zorg ] -recoveryNetwork -testNetwork [-journalDatastore ] [-journalHardLimitInMb ] [-journalWarningThresholdInMb ] - [] + [-WhatIf] [-Confirm] [] ``` ### recoveryResourcePoolDatastore @@ -69,7 +69,7 @@ New-ZertoVpg -vpgName [-vpgPriority ] [-journalHistoryInHours < [-rpoInSeconds ] [-testIntervalInMinutes ] [-serviceProfile ] [-useWanCompression ] [-zorg ] -recoveryNetwork -testNetwork [-journalDatastore ] [-journalHardLimitInMb ] [-journalWarningThresholdInMb ] - [] + [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -492,8 +492,38 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/New-ZertoVpgSettingsIdentifier.md b/docs/New-ZertoVpgSettingsIdentifier.md index abae8dd..f703f1b 100644 --- a/docs/New-ZertoVpgSettingsIdentifier.md +++ b/docs/New-ZertoVpgSettingsIdentifier.md @@ -1,92 +1,122 @@ ---- -external help file: ZertoApiWrapper-help.xml -Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/Master/docs/New-ZertoVpgSettingsIdentifier.md -schema: 2.0.0 ---- - -# New-ZertoVpgSettingsIdentifier - -## SYNOPSIS -Creates and returns a VPG Settings Identifier either for an existing VPG or a new VPG. - -## SYNTAX - -### existingVpg -``` -New-ZertoVpgSettingsIdentifier -vpgIdentifier [] -``` - -### newVpg -``` -New-ZertoVpgSettingsIdentifier [-newVpg] [] -``` - -## DESCRIPTION -Creates and returns a VPG Settings Identifier either for an existing VPG or a new VPG. - -## EXAMPLES - -### Example 1 -```powershell -PS C:> New-ZertoVpgSettingsIdentifier -newVpg -``` - -Creates a Vpg Settings Identifier for a new, blank VPG. - -### Example 2 -```powershell -PS C:> New-ZertoVpgSettingsIdentifier -vpgIdentifier "MyVpgIdentifier" -``` - -Creates a Vpg Settings Identifier for an existing VPG. This settings identifier points to a settings object that contains the current settings of the VPG. - -## PARAMETERS - -### -newVpg -Use this switch when creating a vpgSettingsIdentifier for a new VPG - -```yaml -Type: SwitchParameter -Parameter Sets: newVpg -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -vpgIdentifier -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. - -```yaml -Type: String -Parameter Sets: existingVpg -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -## OUTPUTS - -### System.Object -## NOTES - -## RELATED LINKS - -[Zerto REST API VPG Settings End Point Documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/RestfulAPIs/StatusAPIs.5.108.html#) +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/wcarroll/ZertoApiWrapper/blob/Master/docs/New-ZertoVpgSettingsIdentifier.md +schema: 2.0.0 +--- + +# New-ZertoVpgSettingsIdentifier + +## SYNOPSIS +Creates and returns a VPG Settings Identifier either for an existing VPG or a new VPG. + +## SYNTAX + +### newVpg (Default) +``` +New-ZertoVpgSettingsIdentifier [-newVpg] [-WhatIf] [-Confirm] [] +``` + +### existingVpg +``` +New-ZertoVpgSettingsIdentifier -vpgIdentifier [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Creates and returns a VPG Settings Identifier either for an existing VPG or a new VPG. + +## EXAMPLES + +### Example 1 +```powershell +PS C:> New-ZertoVpgSettingsIdentifier -newVpg +``` + +Creates a Vpg Settings Identifier for a new, blank VPG. + +### Example 2 +```powershell +PS C:> New-ZertoVpgSettingsIdentifier -vpgIdentifier "MyVpgIdentifier" +``` + +Creates a Vpg Settings Identifier for an existing VPG. This settings identifier points to a settings object that contains the current settings of the VPG. + +## PARAMETERS + +### -newVpg +Use this switch when creating a vpgSettingsIdentifier for a new VPG + +```yaml +Type: SwitchParameter +Parameter Sets: newVpg +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -vpgIdentifier +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. + +```yaml +Type: String[] +Parameter Sets: existingVpg +Aliases: vpgId + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName, ByValue) +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String + +## OUTPUTS + +### System.Object +## NOTES + +## RELATED LINKS + +[Zerto REST API VPG Settings End Point Documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/RestfulAPIs/StatusAPIs.5.108.html#) diff --git a/docs/Remove-ZertoPeerSite.md b/docs/Remove-ZertoPeerSite.md new file mode 100644 index 0000000..9475bdc --- /dev/null +++ b/docs/Remove-ZertoPeerSite.md @@ -0,0 +1,163 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Remove-ZertoPeerSite.md +schema: 2.0.0 +--- + +# Remove-ZertoPeerSite + +## SYNOPSIS + +Unpair the current site from another site paired to it. + +## SYNTAX + +### siteIdentifier (Default) +``` +Remove-ZertoPeerSite -siteIdentifier [-keepTargetDisks] [-WhatIf] [-Confirm] [] +``` + +### peerSiteName +``` +Remove-ZertoPeerSite -peerSiteName [-keepTargetDisks] [-WhatIf] [-Confirm] [] +``` + +### hostName +``` +Remove-ZertoPeerSite -hostName [-keepTargetDisks] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION + +Unpair the current site from another site paired to it. + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> Remove-ZertoPeerSite -siteIdentifier "MySiteIdentifier" +``` + +Unpairs the current site for the site with siteIdentifier "MySiteIdentifier" + +### Example 2 +```powershell +PS C:\> Remove-ZertoPeerSite -peerSiteName "Recovery Site" +``` + +Unpairs the current site for the site with site name "Recovery Site" + +### Example 1 +```powershell +PS C:\> Remove-ZertoPeerSite -hostName "192.168.1.100" +``` + +Unpairs the current site for the site with ip address "192.168.1.100" + +## PARAMETERS + +### -hostName +IP address of the peer site to be removed from the connected site + +```yaml +Type: String[] +Parameter Sets: hostName +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName, ByValue) +Accept wildcard characters: False +``` + +### -keepTargetDisks +Specify this switch to Keep the target replica disks for any VPGs replicating between the sites as the VPGs will be deleted by unpairing the sites. +If this switch is not used, the target replica disks will be deleted + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -peerSiteName +Name of the peer site to be removed from the connected site + +```yaml +Type: String[] +Parameter Sets: peerSiteName +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName, ByValue) +Accept wildcard characters: False +``` + +### -siteIdentifier +Identifier of the site to be removed from the connected site + +```yaml +Type: String[] +Parameter Sets: siteIdentifier +Aliases: siteId + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName, ByValue) +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Zerto REST API Peer Site End Point Documentation](http://s3.amazonaws.com/zertodownload_docs/Latest/Zerto%20Virtual%20Replication%20Zerto%20Virtual%20Manager%20%28ZVM%29%20-%20vSphere%20Online%20Help/index.html#page/RestfulAPIs%2FStatusAPIs.5.044.html%23) \ No newline at end of file diff --git a/docs/Remove-ZertoVpg.md b/docs/Remove-ZertoVpg.md index ec2bac7..86ef8db 100644 --- a/docs/Remove-ZertoVpg.md +++ b/docs/Remove-ZertoVpg.md @@ -103,7 +103,7 @@ vpgIdentifier(s) of the VPG(s) to delete. ```yaml Type: String[] Parameter Sets: vpgIdentifier -Aliases: +Aliases: vpgId Required: True Position: Named @@ -162,7 +162,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Resume-ZertoVpg.md b/docs/Resume-ZertoVpg.md index 20d4bb3..93e9f43 100644 --- a/docs/Resume-ZertoVpg.md +++ b/docs/Resume-ZertoVpg.md @@ -46,7 +46,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Save-ZertoVpgSettings.md b/docs/Save-ZertoVpgSetting.md similarity index 78% rename from docs/Save-ZertoVpgSettings.md rename to docs/Save-ZertoVpgSetting.md index 6a10f72..b0305e1 100644 --- a/docs/Save-ZertoVpgSettings.md +++ b/docs/Save-ZertoVpgSetting.md @@ -1,11 +1,11 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSettings.md +online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSetting.md schema: 2.0.0 --- -# Save-ZertoVpgSettings +# Save-ZertoVpgSetting ## SYNOPSIS Commits the updated Vpg Settings with the configured Vpg Settings Identifier @@ -13,7 +13,7 @@ Commits the updated Vpg Settings with the configured Vpg Settings Identifier ## SYNTAX ``` -Save-ZertoVpgSettings [-vpgSettingsIdentifier] [-WhatIf] [-Confirm] [] +Save-ZertoVpgSetting [-vpgSettingsIdentifier] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -23,7 +23,7 @@ Commits the updated Vpg Settings with the configured Vpg Settings Identifier ### Example 1 ```powershell -PS C:> Save-ZertoVpgSettings -vpgSettingsIdentifier "MyVpgSettingsIdentifier" +PS C:> Save-ZertoVpgSetting -vpgSettingsIdentifier "MyVpgSettingsIdentifier" ``` Commits vpg settings with vpg settings identifier "MyVpgSettingsIdentifier" @@ -36,10 +36,10 @@ VpgSettings Identifier to save ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: vpgSettingsId Required: True -Position: 0 +Position: 1 Default value: None Accept pipeline input: True (ByPropertyName, ByValue) Accept wildcard characters: False @@ -77,7 +77,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Set-ZertoAlert.md b/docs/Set-ZertoAlert.md index 6498a31..9a7cd65 100644 --- a/docs/Set-ZertoAlert.md +++ b/docs/Set-ZertoAlert.md @@ -49,7 +49,7 @@ Alert identifier(s) to be dismissed or undismissed. ```yaml Type: String[] Parameter Sets: (All) -Aliases: identifier +Aliases: alertIdentifier, identifier, id Required: True Position: Named @@ -120,7 +120,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Set-ZertoLicense.md b/docs/Set-ZertoLicense.md index 4a5df05..a604a13 100644 --- a/docs/Set-ZertoLicense.md +++ b/docs/Set-ZertoLicense.md @@ -77,7 +77,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Start-ZertoCloneVpg.md b/docs/Start-ZertoCloneVpg.md index 4f1a709..6c0cedb 100644 --- a/docs/Start-ZertoCloneVpg.md +++ b/docs/Start-ZertoCloneVpg.md @@ -14,7 +14,7 @@ Start a Virtual Protection Group Clone operation ``` Start-ZertoCloneVpg [-vpgName] [[-checkpointIdentifier] ] [[-datastoreName] ] - [[-vmName] ] [] + [[-vmName] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -38,7 +38,7 @@ If unspecified, the latest checkpoint will be used. ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: checkpointId Required: False Position: 1 @@ -94,8 +94,38 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Start-ZertoFailoverTest.md b/docs/Start-ZertoFailoverTest.md index a14fafb..7899454 100644 --- a/docs/Start-ZertoFailoverTest.md +++ b/docs/Start-ZertoFailoverTest.md @@ -13,8 +13,8 @@ Start a Test Failover of a specific Virtual Protection Group ## SYNTAX ``` -Start-ZertoFailoverTest [-vpgName] [[-checkpointIdentifier] ] [[-vmName] ] - [] +Start-ZertoFailoverTest [-vpgName] [[-checkpointIdentifier] ] [[-vmName] ] [-WhatIf] + [-Confirm] [] ``` ## DESCRIPTION @@ -38,7 +38,7 @@ If unspecified, the latest checkpoint will be used. ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: checkpointId Required: False Position: 1 @@ -78,8 +78,38 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Stop-ZertoCloneVpg.md b/docs/Stop-ZertoCloneVpg.md index f4905c6..5e96bd7 100644 --- a/docs/Stop-ZertoCloneVpg.md +++ b/docs/Stop-ZertoCloneVpg.md @@ -13,7 +13,7 @@ Stops a Virtual Protection Group Clone Operation currently running ## SYNTAX ``` -Stop-ZertoCloneVpg [-vpgName] [] +Stop-ZertoCloneVpg [-vpgName] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -45,8 +45,38 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Stop-ZertoFailoverTest.md b/docs/Stop-ZertoFailoverTest.md index 0a499dd..f4ab758 100644 --- a/docs/Stop-ZertoFailoverTest.md +++ b/docs/Stop-ZertoFailoverTest.md @@ -14,7 +14,7 @@ Stops a running Failover Test operation. ``` Stop-ZertoFailoverTest [-vpgName] [[-failoverTestSuccess] ] - [[-failoverTestSummary] ] [] + [[-failoverTestSummary] ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -78,8 +78,38 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Suspend-ZertoVpg.md b/docs/Suspend-ZertoVpg.md index b3cef31..d1336a2 100644 --- a/docs/Suspend-ZertoVpg.md +++ b/docs/Suspend-ZertoVpg.md @@ -46,7 +46,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/docs/Uninstall-ZertoVra.md b/docs/Uninstall-ZertoVra.md index 91e32ac..b19e8f1 100644 --- a/docs/Uninstall-ZertoVra.md +++ b/docs/Uninstall-ZertoVra.md @@ -46,7 +46,7 @@ Accept wildcard characters: False ``` ### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..6e8bf73 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.1.0