From ed225024a6f07664f4edd23b10a921dc9eb3d4d4 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Tue, 16 Apr 2019 16:18:33 -0400 Subject: [PATCH] Add Parameter Validations --- ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 | 2 ++ ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 | 3 ++- ZertoApiWrapper/Public/Invoke-ZertoFailoverRollback.ps1 | 1 + ZertoApiWrapper/Public/Invoke-ZertoForceSync.ps1 | 1 + ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 | 4 +++- ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 | 3 ++- ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 | 1 + 7 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 index 5db8223..5eb5500 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 @@ -33,6 +33,8 @@ function Invoke-ZertoFailover { [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 60 Minutes (3600 Seconds)" )] + # 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. diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 index 37db864..5f88c47 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 @@ -6,6 +6,7 @@ function Invoke-ZertoFailoverCommit { HelpMessage = "Name(s) of the VPG(s) to commit.", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string[]]$vpgName, [Parameter( HelpMessage = "Use this switch to reverse protect the VPG(s) to the source site." @@ -37,4 +38,4 @@ function Invoke-ZertoFailoverCommit { 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 7ff5c3d..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 ) diff --git a/ZertoApiWrapper/Public/Invoke-ZertoForceSync.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoForceSync.ps1 index 2e75c96..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 ) diff --git a/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 index 66d61f9..8c7a9a3 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 @@ -19,7 +19,9 @@ function Invoke-ZertoMove { [Parameter( HelpMessage = "The amount of time, in seconds, the Move is in a 'Before Commit' state, before performing the commitPolicy setting. If omitted, the site settings default will be applied." )] - [Int32]$commitPolicyTimeout, + # Min 5 Minutes, Max 24 Hours, Default 1 Hour. + [ValidateRange(300, 86400)] + [Int]$commitPolicyTimeout, [Parameter( HelpMessage = "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." )] diff --git a/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 index 4c229a4..f524af1 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 @@ -6,6 +6,7 @@ function Invoke-ZertoMoveCommit { 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" @@ -44,4 +45,4 @@ function Invoke-ZertoMoveCommit { 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 0450175..b1d7e24 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 @@ -6,6 +6,7 @@ function Invoke-ZertoMoveRollback { HelpMessage = "Name(s) of VPG(s) to roll back from failing over", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string[]]$vpgName )