From 76b228589e03332f5c50feed2ca5b2cc1523b08d Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Tue, 26 Mar 2019 14:28:00 -0400 Subject: [PATCH 001/147] Add Param Aliases --- ZertoApiWrapper/Public/Connect-ZertoServer.ps1 | 2 ++ ZertoApiWrapper/Public/Edit-ZertoVra.ps1 | 1 + ZertoApiWrapper/Public/Get-ZertoAlert.ps1 | 4 ++++ ZertoApiWrapper/Public/Get-ZertoDatastore.ps1 | 1 + ZertoApiWrapper/Public/Get-ZertoEvent.ps1 | 5 +++++ ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 | 1 + ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 | 3 +++ ZertoApiWrapper/Public/Get-ZertoServiceProfile.ps1 | 1 + ZertoApiWrapper/Public/Get-ZertoTask.ps1 | 1 + ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 | 2 ++ ZertoApiWrapper/Public/Get-ZertoVolume.ps1 | 4 ++++ ZertoApiWrapper/Public/Get-ZertoVpg.ps1 | 1 + ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 | 4 ++++ ZertoApiWrapper/Public/Get-ZertoVra.ps1 | 1 + ZertoApiWrapper/Public/Get-ZertoZorg.ps1 | 1 + ZertoApiWrapper/Public/Get-ZertoZsspSession.ps1 | 1 + ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 | 1 + ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 | 1 + ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 | 1 + ZertoApiWrapper/Public/Save-ZertoVpgSettings.ps1 | 3 ++- ZertoApiWrapper/Public/Set-ZertoAlert.ps1 | 3 ++- ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 | 1 + ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 | 1 + 23 files changed, 42 insertions(+), 2 deletions(-) diff --git a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 index 7cec66b..2b4e660 100644 --- a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 +++ b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 @@ -7,10 +7,12 @@ function Connect-ZertoServer { 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." )] + [Alias("port")] [string]$zertoPort = "9669", [Parameter( Mandatory = $true, diff --git a/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 b/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 index a0ca0c4..638f37c 100644 --- a/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 @@ -6,6 +6,7 @@ function Edit-ZertoVra { Mandatory = $true, HelpMessage = "Identifier of the VRA to be updated." )] + [Alias("vraId")] [string]$vraIdentifier, [Parameter( HelpMessage = "Bandwidth group to assign to the VRA. If unspecified will not modify current assignment" diff --git a/ZertoApiWrapper/Public/Get-ZertoAlert.ps1 b/ZertoApiWrapper/Public/Get-ZertoAlert.ps1 index d38dedb..1375ba5 100644 --- a/ZertoApiWrapper/Public/Get-ZertoAlert.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoAlert.ps1 @@ -42,16 +42,19 @@ function Get-ZertoAlert { ParameterSetName = "filter", HelpMessage = "Returns alerts for the specified vraIdentifier" )] + [Alias("vpgId")] [string]$vpgIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "Returns alerts for the specified siteIdentifier" )] + [Alias("siteId")] [string]$siteIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "Returns alerts for the specified zorgIdentifier" )] + [Alias("zorgId")] [string]$zorgIdentifier, [Parameter( ParameterSetName = "filter", @@ -62,6 +65,7 @@ function Get-ZertoAlert { ParameterSetName = "filter", HelpMessage = "Returns alerts for the specified helpIdentifier" )] + [Alias("helpId")] [string]$helpIdentifier, [Parameter( ParameterSetName = "filter", diff --git a/ZertoApiWrapper/Public/Get-ZertoDatastore.ps1 b/ZertoApiWrapper/Public/Get-ZertoDatastore.ps1 index fc62429..46f10ae 100644 --- a/ZertoApiWrapper/Public/Get-ZertoDatastore.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoDatastore.ps1 @@ -2,6 +2,7 @@ function Get-ZertoDatastore { [cmdletbinding( DefaultParameterSetName = "main" )] param( + [Alias("datastoreId")] [Parameter( ParameterSetName = "datastoreIdentifier", HelpMessage = "datastoreIdentifier or array of datastoreIdentifiers to be queried" diff --git a/ZertoApiWrapper/Public/Get-ZertoEvent.ps1 b/ZertoApiWrapper/Public/Get-ZertoEvent.ps1 index 87aa95c..1e79659 100644 --- a/ZertoApiWrapper/Public/Get-ZertoEvent.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoEvent.ps1 @@ -16,11 +16,13 @@ function Get-ZertoEvent { ParameterSetName = "filter", HelpMessage = "The name of the VPG for which you want to return events." )] + [Alias("vpgName")] [string]$vpg, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the VPG for which you want to return events." )] + [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." @@ -35,11 +37,13 @@ function Get-ZertoEvent { ParameterSetName = "filter", HelpMessage = "The internal site identifier for which you want to return events." )] + [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." )] + [Alias("zorgId")] [string]$zorgIdentifier, [Parameter( ParameterSetName = "filter", @@ -65,6 +69,7 @@ function Get-ZertoEvent { ParameterSetName = "filter", HelpMessage = "The internal alert identifier for the Event" )] + [Alias("alertId")] [string]$alertIdentifier, [Parameter( ParameterSetName = "eventId", diff --git a/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 b/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 index 9c25df1..3a8e0e9 100644 --- a/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 @@ -15,6 +15,7 @@ function Get-ZertoPeerSite { ValueFromPipelineByPropertyName = $true, HelpMessage = "The identifier(s) of the peer site(s) for which information is to be returned." )] + [Alias("siteId")] [string[]]$siteIdentifier, [Parameter( ParameterSetName = "filter", diff --git a/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 b/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 index db71c52..429a8cd 100644 --- a/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 @@ -9,6 +9,7 @@ function Get-ZertoProtectedVm { ValueFromPipelineByPropertyName = $true, HelpMessage = "vmIdentifier(s) for which to return information" )] + [Alias("vmId")] [string[]]$vmIdentifier, [Parameter( ParameterSetName = "filter", @@ -54,11 +55,13 @@ function Get-ZertoProtectedVm { ParameterSetName = "filter", HelpMessage = "The identifier of the protected site where the VPG virtual machines are protected." )] + [Alias("protectedSiteId")] [string]$protectedSiteIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the recovery site where the VPG virtual machines are recovered." )] + [Alias("recoverySiteId")] [string]$recoverySiteIdentifier ) diff --git a/ZertoApiWrapper/Public/Get-ZertoServiceProfile.ps1 b/ZertoApiWrapper/Public/Get-ZertoServiceProfile.ps1 index 2de7a8c..4081a9d 100644 --- a/ZertoApiWrapper/Public/Get-ZertoServiceProfile.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoServiceProfile.ps1 @@ -6,6 +6,7 @@ function Get-ZertoServiceProfile { ParameterSetName = "siteIdentifier", HelpMessage = "The identifier of the site for which service profiles should be returned." )] + [Alias("siteId")] [string]$siteIdentifier, [Parameter( ParameterSetName = "serviceProfileId", diff --git a/ZertoApiWrapper/Public/Get-ZertoTask.ps1 b/ZertoApiWrapper/Public/Get-ZertoTask.ps1 index cd8dd21..ce23e3c 100644 --- a/ZertoApiWrapper/Public/Get-ZertoTask.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoTask.ps1 @@ -6,6 +6,7 @@ function Get-ZertoTask { ParameterSetName = "taskIdentifier", HelpMessage = "The identifier(s) for which task information is to be returned." )] + [Alias("taskId")] [string[]]$taskIdentifier, [Parameter( ParameterSetName = "types", diff --git a/ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 b/ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 index 5063f96..a7e4e01 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 @@ -52,6 +52,7 @@ function Get-ZertoVirtualizationSite { Mandatory = $true, HelpMessage = "The identifier of the Zerto Virtual Manager site." )] + [Alias("siteId")] [string]$siteIdentifier, [Parameter( ParameterSetName = "datastoreClusters", @@ -81,6 +82,7 @@ function Get-ZertoVirtualizationSite { Mandatory = $false, HelpMessage = "The identifier of the host at the selected site to return information for only one host." )] + [Alias("hostId")] [string]$hostIdentifier, [Parameter( ParameterSetName = "folders", diff --git a/ZertoApiWrapper/Public/Get-ZertoVolume.ps1 b/ZertoApiWrapper/Public/Get-ZertoVolume.ps1 index 3855679..6f44002 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVolume.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVolume.ps1 @@ -11,21 +11,25 @@ function Get-ZertoVolume { ParameterSetName = "filter", HelpMessage = "The identifier of the VPG." )] + [Alias("vpgId")] [string]$vpgIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the datastore." )] + [Alias("datastoreId", "dsId")] [string]$datastoreIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the protected virtual machine." )] + [Alias("protectedVmId")] [string]$protectedVmIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the owning virtual machine." )] + [Alias("owningVmId")] [string]$owningVmIdentifier ) diff --git a/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 index f9750ef..3c4ef0c 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 @@ -17,6 +17,7 @@ function Get-ZertoVpg { Mandatory = $true, HelpMessage = "The identifier(s) of the Virtual Protection Group to return" )] + [Alias("vpgId", "protectionGroupId", "pgId")] [string[]]$protectionGroupIdentifier, [Parameter( ParameterSetName = "checkpoints", diff --git a/ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 b/ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 index 500e1af..5c68f54 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 @@ -131,6 +131,7 @@ function Get-ZertoVpgSetting { Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] + [Alias("vpgSettingsId", "settingsId")] [string]$vpgSettingsIdentifier, [Parameter( ParameterSetName = "backup", @@ -229,6 +230,7 @@ function Get-ZertoVpgSetting { Mandatory = $true, HelpMessage = "VM Identifier" )] + [Alias("vmId")] [string]$vmIdentifier, [Parameter( ParameterSetName = "nics", @@ -241,6 +243,7 @@ function Get-ZertoVpgSetting { Mandatory = $true, HelpMessage = "Return NIC information for specified NIC of the specified VM" )] + [Alias("nicId")] [string]$nicIdentifier, [Parameter( ParameterSetName = "volumes", @@ -253,6 +256,7 @@ function Get-ZertoVpgSetting { Mandatory = $true, HelpMessage = "Return volume information for the specified volume of the specified VM" )] + [Alias("volumeId")] [string]$volumeIdentifier ) diff --git a/ZertoApiWrapper/Public/Get-ZertoVra.ps1 b/ZertoApiWrapper/Public/Get-ZertoVra.ps1 index 6192848..5f80ea7 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVra.ps1 @@ -18,6 +18,7 @@ function Get-ZertoVra { ParameterSetName = "vraIdentifier", HelpMessage = "Returns information for provided VRA identifier(s)" )] + [Alias("vraId")] [string[]]$vraIdentifier, [Parameter( ParameterSetName = "filter", diff --git a/ZertoApiWrapper/Public/Get-ZertoZorg.ps1 b/ZertoApiWrapper/Public/Get-ZertoZorg.ps1 index 65a908f..5d17d29 100644 --- a/ZertoApiWrapper/Public/Get-ZertoZorg.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoZorg.ps1 @@ -6,6 +6,7 @@ function Get-ZertoZorg { ParameterSetName = "zorgIdentifier", HelpMessage = "Identifier(s) of the ZORG." )] + [Alias("zorgId")] [string[]]$zorgIdentifier ) diff --git a/ZertoApiWrapper/Public/Get-ZertoZsspSession.ps1 b/ZertoApiWrapper/Public/Get-ZertoZsspSession.ps1 index 3cd1743..2d6b293 100644 --- a/ZertoApiWrapper/Public/Get-ZertoZsspSession.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoZsspSession.ps1 @@ -6,6 +6,7 @@ function Get-ZertoZsspSession { ParameterSetName = "zsspSessionIdentifier", HelpMessage = "ZSSP Session Id(s) to get information." )] + [Alias("zsspSessionId")] [string[]]$zsspSessionIdentifier ) diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 index a307d5e..b96379a 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 @@ -10,6 +10,7 @@ function Invoke-ZertoFailover { [Parameter( HelpMessage = "Checkpoint Identifier to use as the Point-In-Time to rollback to." )] + [Alias("checkpointId")] [string]$checkpointIdentifier, [Parameter( HelpMessage = "0: After the seconds specified in the commitValue setting have elapsed, the failover is rolled back. diff --git a/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 b/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 index 1ae97dc..51eee76 100644 --- a/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 +++ b/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 @@ -8,6 +8,7 @@ function New-ZertoVpgSettingsIdentifier { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true )] + [Alias("vpgId")] [string]$vpgIdentifier, [Parameter( HelpMessage = "Use this switch when creating a vpgSettingsIdentifier for a new VPG", diff --git a/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 index 38ec249..7984a30 100644 --- a/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 @@ -17,6 +17,7 @@ function Remove-ZertoVpg { ValueFromPipelineByPropertyName = $true, HelpMessage = "vpgIdentifier(s) of the VPG(s) to delete." )] + [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" diff --git a/ZertoApiWrapper/Public/Save-ZertoVpgSettings.ps1 b/ZertoApiWrapper/Public/Save-ZertoVpgSettings.ps1 index 015a79e..24f5084 100644 --- a/ZertoApiWrapper/Public/Save-ZertoVpgSettings.ps1 +++ b/ZertoApiWrapper/Public/Save-ZertoVpgSettings.ps1 @@ -10,6 +10,7 @@ function Save-ZertoVpgSettings { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true )] + [Alias("vpgSettingsId")] [string]$vpgSettingsIdentifier ) @@ -17,4 +18,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..8724476 100644 --- a/ZertoApiWrapper/Public/Set-ZertoAlert.ps1 +++ b/ZertoApiWrapper/Public/Set-ZertoAlert.ps1 @@ -9,6 +9,7 @@ function Set-ZertoAlert { Mandatory = $true, HelpMessage = "Alert identifier(s) to be dismissed or undismissed." )] + [Alias("alertIdentifier")] [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/Start-ZertoCloneVpg.ps1 b/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 index 24cdc15..45ffd5b 100644 --- a/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 +++ b/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 @@ -10,6 +10,7 @@ function Start-ZertoCloneVpg { [Parameter( HelpMessage = "The identifier of the checkpoint to use for cloning. If unspecified, the latest checkpoint will be used." )] + [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." diff --git a/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 b/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 index 578f1d5..6e8ce11 100644 --- a/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 +++ b/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 @@ -10,6 +10,7 @@ function Start-ZertoFailoverTest { [Parameter( HelpMessage = "The identifier of the checkpoint to use for testing. If unspecified, the latest checkpoint will be used." )] + [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." From 5ce4bb056aa866f4a418f14890183c4e45c42691 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Tue, 26 Mar 2019 15:07:13 -0400 Subject: [PATCH 002/147] Configure Param Set Validations --- ZertoApiWrapper/Public/Get-ZertoEvent.ps1 | 9 ++++++--- ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 | 3 ++- ZertoApiWrapper/Public/Get-ZertoRecoveryReport.ps1 | 1 + ZertoApiWrapper/Public/Get-ZertoTask.ps1 | 3 ++- ZertoApiWrapper/Public/Get-ZertoVpg.ps1 | 3 ++- ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 | 10 ++++++---- ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 | 8 ++++++-- ZertoApiWrapper/Public/New-ZertoVpg.ps1 | 9 ++++++--- ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 | 4 ++-- 9 files changed, 33 insertions(+), 17 deletions(-) diff --git a/ZertoApiWrapper/Public/Get-ZertoEvent.ps1 b/ZertoApiWrapper/Public/Get-ZertoEvent.ps1 index 1e79659..c87cab7 100644 --- a/ZertoApiWrapper/Public/Get-ZertoEvent.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoEvent.ps1 @@ -47,8 +47,9 @@ function Get-ZertoEvent { [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", @@ -57,13 +58,15 @@ function Get-ZertoEvent { [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'" )] + [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", diff --git a/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 b/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 index 429a8cd..9dc58ae 100644 --- a/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 @@ -38,8 +38,9 @@ function Get-ZertoProtectedVm { [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", diff --git a/ZertoApiWrapper/Public/Get-ZertoRecoveryReport.ps1 b/ZertoApiWrapper/Public/Get-ZertoRecoveryReport.ps1 index 9f3b5ae..1e4997e 100644 --- a/ZertoApiWrapper/Public/Get-ZertoRecoveryReport.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoRecoveryReport.ps1 @@ -36,6 +36,7 @@ function Get-ZertoRecoveryReport { 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", diff --git a/ZertoApiWrapper/Public/Get-ZertoTask.ps1 b/ZertoApiWrapper/Public/Get-ZertoTask.ps1 index ce23e3c..fb670bc 100644 --- a/ZertoApiWrapper/Public/Get-ZertoTask.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoTask.ps1 @@ -40,8 +40,9 @@ function Get-ZertoTask { [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-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 index 3c4ef0c..b3d686a 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 @@ -130,8 +130,9 @@ function Get-ZertoVpg { [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", diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 index b96379a..75f70cc 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 @@ -13,11 +13,12 @@ function Invoke-ZertoFailover { [Alias("checkpointId")] [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." )] + [ValidateSet("Rollback", "Commit", "None")] [string]$commitPolicy, [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" @@ -28,6 +29,7 @@ function Invoke-ZertoFailover { 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." )] + [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" @@ -39,7 +41,7 @@ function Invoke-ZertoFailover { )] [bool]$reverseProtection, [Parameter( - HelpMessage = "Name(s) of VMs in the " + HelpMessage = "Name(s) of VMs in the VPG to failover" )] [string[]]$vmName ) diff --git a/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 index a245da9..1007b5d 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 @@ -8,8 +8,12 @@ function Invoke-ZertoMove { )] [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." @@ -76,4 +80,4 @@ function Invoke-ZertoMove { end { # Nothing to do. } -} \ No newline at end of file +} diff --git a/ZertoApiWrapper/Public/New-ZertoVpg.ps1 b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 index 753554a..020a309 100644 --- a/ZertoApiWrapper/Public/New-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 @@ -21,7 +21,8 @@ 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 @@ -100,11 +101,13 @@ function New-ZertoVpg { [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." )] diff --git a/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 index 7984a30..b3cedcf 100644 --- a/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 @@ -22,11 +22,11 @@ function Remove-ZertoVpg { [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 { From 23d0ffc6bae5b0af58354b4c73397d4db8a00452 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Tue, 26 Mar 2019 15:21:12 -0400 Subject: [PATCH 003/147] Update Help Files --- .../Public/en-us/ZertoApiWrapper-help.xml | 278 +++++++++--------- docs/Connect-ZertoServer.md | 4 +- docs/Edit-ZertoVra.md | 2 +- docs/Get-ZertoAlert.md | 8 +- docs/Get-ZertoDatastore.md | 2 +- docs/Get-ZertoEvent.md | 22 +- docs/Get-ZertoPeerSite.md | 2 +- docs/Get-ZertoProtectedVm.md | 9 +- docs/Get-ZertoServiceProfile.md | 2 +- docs/Get-ZertoTask.md | 5 +- docs/Get-ZertoVirtualizationSite.md | 4 +- docs/Get-ZertoVolume.md | 8 +- docs/Get-ZertoVpg.md | 5 +- docs/Get-ZertoVpgSetting.md | 10 +- docs/Get-ZertoVra.md | 2 +- docs/Get-ZertoZorg.md | 2 +- docs/Get-ZertoZsspSession.md | 2 +- docs/Invoke-ZertoFailover.md | 10 +- docs/Invoke-ZertoMove.md | 11 +- docs/New-ZertoVpgSettingsIdentifier.md | 2 +- docs/Remove-ZertoVpg.md | 2 +- docs/Save-ZertoVpgSettings.md | 2 +- docs/Set-ZertoAlert.md | 2 +- docs/Start-ZertoCloneVpg.md | 2 +- docs/Start-ZertoFailoverTest.md | 2 +- 25 files changed, 200 insertions(+), 200 deletions(-) diff --git a/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml b/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml index 39806eb..d47de4f 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. @@ -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 @@ -3437,7 +3437,7 @@ Get-ZertoServiceProfile - + siteIdentifier The identifier of the site for which service profiles 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. @@ -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. @@ -4334,7 +4334,7 @@ Get-ZertoVolume - + datastoreIdentifier The identifier of the datastore. @@ -4346,7 +4346,7 @@ None - + owningVmIdentifier The identifier of the owning virtual machine. @@ -4358,7 +4358,7 @@ None - + protectedVmIdentifier The identifier of the protected virtual machine. @@ -4382,7 +4382,7 @@ None - + vpgIdentifier The identifier of the VPG. @@ -4397,7 +4397,7 @@ - + datastoreIdentifier The identifier of the datastore. @@ -4409,7 +4409,7 @@ None - + owningVmIdentifier The identifier of the owning virtual machine. @@ -4421,7 +4421,7 @@ None - + protectedVmIdentifier The identifier of the protected virtual machine. @@ -4445,7 +4445,7 @@ None - + vpgIdentifier The identifier of the VPG. @@ -4570,7 +4570,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 +4701,7 @@ None - + protectionGroupIdentifier The identifier(s) of the Virtual Protection Group to return @@ -4739,7 +4739,7 @@ False - + protectionGroupIdentifier The identifier(s) of the Virtual Protection Group to return @@ -4810,7 +4810,7 @@ Get-ZertoVpg - + protectionGroupIdentifier The identifier(s) of the Virtual Protection Group to return @@ -4990,7 +4990,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 +5023,7 @@ None - + protectionGroupIdentifier The identifier(s) of the Virtual Protection Group to return @@ -5235,7 +5235,7 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. @@ -5261,7 +5261,7 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. @@ -5287,7 +5287,7 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. @@ -5313,7 +5313,7 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. @@ -5339,7 +5339,7 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. @@ -5365,7 +5365,7 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. @@ -5380,7 +5380,7 @@ Get-ZertoVpgSetting - + nicIdentifier Return NIC information for specified NIC of the specified VM @@ -5392,7 +5392,7 @@ None - + vmIdentifier VM Identifier @@ -5404,7 +5404,7 @@ None - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. @@ -5430,7 +5430,7 @@ False - + vmIdentifier VM Identifier @@ -5442,7 +5442,7 @@ None - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. @@ -5468,7 +5468,7 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. @@ -5494,7 +5494,7 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. @@ -5520,7 +5520,7 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. @@ -5546,7 +5546,7 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. @@ -5572,7 +5572,7 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. @@ -5587,7 +5587,7 @@ Get-ZertoVpgSetting - + vmIdentifier VM Identifier @@ -5599,7 +5599,7 @@ None - + volumeIdentifier Return volume information for the specified volume of the specified VM @@ -5611,7 +5611,7 @@ None - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. @@ -5626,7 +5626,7 @@ Get-ZertoVpgSetting - + vmIdentifier VM Identifier @@ -5649,7 +5649,7 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. @@ -5664,7 +5664,7 @@ Get-ZertoVpgSetting - + vmIdentifier VM Identifier @@ -5676,7 +5676,7 @@ None - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. @@ -5702,7 +5702,7 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. @@ -5717,7 +5717,7 @@ Get-ZertoVpgSetting - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. @@ -5804,7 +5804,7 @@ False - + nicIdentifier Return NIC information for specified NIC of the specified VM @@ -5888,7 +5888,7 @@ False - + vmIdentifier VM Identifier @@ -5912,7 +5912,7 @@ False - + volumeIdentifier Return volume information for the specified volume of the specified VM @@ -5936,7 +5936,7 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. @@ -6176,7 +6176,7 @@ Get-ZertoVra - + vraIdentifier Returns information for provided VRA identifier(s) @@ -6299,7 +6299,7 @@ None - + vraIdentifier Returns information for provided VRA identifier(s) @@ -6403,7 +6403,7 @@ Get-ZertoZorg - + zorgIdentifier Identifier(s) of the ZORG. @@ -6418,7 +6418,7 @@ - + zorgIdentifier Identifier(s) of the ZORG. @@ -6498,7 +6498,7 @@ Get-ZertoZsspSession - + zsspSessionIdentifier ZSSP Session Id(s) to get information. @@ -6513,7 +6513,7 @@ - + zsspSessionIdentifier ZSSP Session Id(s) to get information. @@ -7103,7 +7103,7 @@ None - + checkpointIdentifier Checkpoint Identifier to use as the Point-In-Time to rollback to. @@ -7118,9 +7118,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 @@ -7184,7 +7184,7 @@ vmName - Name(s) of VMs in the + Name(s) of VMs in the VPG to failover String[] @@ -7196,7 +7196,7 @@ - + checkpointIdentifier Checkpoint Identifier to use as the Point-In-Time to rollback to. @@ -7211,9 +7211,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 @@ -7277,7 +7277,7 @@ vmName - Name(s) of VMs in the + Name(s) of VMs in the VPG to failover String[] @@ -7668,7 +7668,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 @@ -7752,7 +7755,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 @@ -9923,7 +9929,7 @@ 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. @@ -9950,7 +9956,7 @@ 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. @@ -10052,7 +10058,7 @@ False - + vpgidentifier vpgIdentifier(s) of the VPG(s) to delete. @@ -10172,7 +10178,7 @@ False - + vpgidentifier vpgIdentifier(s) of the VPG(s) to delete. @@ -10390,7 +10396,7 @@ Save-ZertoVpgSettings - + vpgSettingsIdentifier VpgSettings Identifier to save @@ -10427,7 +10433,7 @@ - + vpgSettingsIdentifier VpgSettings Identifier to save @@ -10524,7 +10530,7 @@ Set-ZertoAlert - + alertId Alert identifier(s) to be dismissed or undismissed. @@ -10572,7 +10578,7 @@ Set-ZertoAlert - + alertId Alert identifier(s) to be dismissed or undismissed. @@ -10620,7 +10626,7 @@ - + alertId Alert identifier(s) to be dismissed or undismissed. @@ -10894,7 +10900,7 @@ None - + checkpointIdentifier The identifier of the checkpoint to use for cloning. If unspecified, the latest checkpoint will be used. @@ -10933,7 +10939,7 @@ - + checkpointIdentifier The identifier of the checkpoint to use for cloning. If unspecified, the latest checkpoint will be used. @@ -11054,7 +11060,7 @@ None - + checkpointIdentifier The identifier of the checkpoint to use for testing. If unspecified, the latest checkpoint will be used. @@ -11081,7 +11087,7 @@ - + checkpointIdentifier The identifier of the checkpoint to use for testing. If unspecified, the latest checkpoint will be used. diff --git a/docs/Connect-ZertoServer.md b/docs/Connect-ZertoServer.md index 3cd7c14..41d75e8 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 diff --git a/docs/Edit-ZertoVra.md b/docs/Edit-ZertoVra.md index bf40004..89b8866 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 diff --git a/docs/Get-ZertoAlert.md b/docs/Get-ZertoAlert.md index 905ba14..a9cefa0 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 diff --git a/docs/Get-ZertoDatastore.md b/docs/Get-ZertoDatastore.md index 9c81382..40adbe2 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 diff --git a/docs/Get-ZertoEvent.md b/docs/Get-ZertoEvent.md index f512d16..4e76263 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 diff --git a/docs/Get-ZertoPeerSite.md b/docs/Get-ZertoPeerSite.md index 1e127de..e5e2936 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 diff --git a/docs/Get-ZertoProtectedVm.md b/docs/Get-ZertoProtectedVm.md index db23650..daaa2c5 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 diff --git a/docs/Get-ZertoServiceProfile.md b/docs/Get-ZertoServiceProfile.md index 4b19813..21a381c 100644 --- a/docs/Get-ZertoServiceProfile.md +++ b/docs/Get-ZertoServiceProfile.md @@ -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 diff --git a/docs/Get-ZertoTask.md b/docs/Get-ZertoTask.md index 6229464..6ff80af 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 diff --git a/docs/Get-ZertoVirtualizationSite.md b/docs/Get-ZertoVirtualizationSite.md index 59d46a0..049d2e9 100644 --- a/docs/Get-ZertoVirtualizationSite.md +++ b/docs/Get-ZertoVirtualizationSite.md @@ -162,7 +162,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 +223,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 diff --git a/docs/Get-ZertoVolume.md b/docs/Get-ZertoVolume.md index 91f3d52..5b17799 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 diff --git a/docs/Get-ZertoVpg.md b/docs/Get-ZertoVpg.md index 737456a..4c8a3b5 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 diff --git a/docs/Get-ZertoVpgSetting.md b/docs/Get-ZertoVpgSetting.md index 989e250..d812532 100644 --- a/docs/Get-ZertoVpgSetting.md +++ b/docs/Get-ZertoVpgSetting.md @@ -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 @@ -414,7 +414,7 @@ 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: +Aliases: vpgSettingsId, settingsId Required: True Position: Named @@ -426,7 +426,7 @@ Accept wildcard characters: False ```yaml Type: String Parameter Sets: basic, schedulerPeriod, retentionPeriod, dayOfWeek, backup, vpgSettingsIdentifier -Aliases: +Aliases: vpgSettingsId, settingsId Required: True Position: Named diff --git a/docs/Get-ZertoVra.md b/docs/Get-ZertoVra.md index 1e3bf10..d44cd4e 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 diff --git a/docs/Get-ZertoZorg.md b/docs/Get-ZertoZorg.md index bb59509..fac0cfc 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 diff --git a/docs/Get-ZertoZsspSession.md b/docs/Get-ZertoZsspSession.md index 1b356b6..b6463df 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 diff --git a/docs/Invoke-ZertoFailover.md b/docs/Invoke-ZertoFailover.md index ac3aa84..ecc48e6 100644 --- a/docs/Invoke-ZertoFailover.md +++ b/docs/Invoke-ZertoFailover.md @@ -38,7 +38,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 +48,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. @@ -143,7 +143,7 @@ Accept wildcard characters: False ``` ### -vmName -Name(s) of VMs in the +Name(s) of VMs in the VPG to failover ```yaml Type: String[] diff --git a/docs/Invoke-ZertoMove.md b/docs/Invoke-ZertoMove.md index fb989bf..4cfd149 100644 --- a/docs/Invoke-ZertoMove.md +++ b/docs/Invoke-ZertoMove.md @@ -33,10 +33,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 diff --git a/docs/New-ZertoVpgSettingsIdentifier.md b/docs/New-ZertoVpgSettingsIdentifier.md index abae8dd..93f9beb 100644 --- a/docs/New-ZertoVpgSettingsIdentifier.md +++ b/docs/New-ZertoVpgSettingsIdentifier.md @@ -66,7 +66,7 @@ This would be used for creating a new VPG from scratch. ```yaml Type: String Parameter Sets: existingVpg -Aliases: +Aliases: vpgId Required: True Position: Named diff --git a/docs/Remove-ZertoVpg.md b/docs/Remove-ZertoVpg.md index ec2bac7..95af5db 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 diff --git a/docs/Save-ZertoVpgSettings.md b/docs/Save-ZertoVpgSettings.md index 6a10f72..16d9dda 100644 --- a/docs/Save-ZertoVpgSettings.md +++ b/docs/Save-ZertoVpgSettings.md @@ -36,7 +36,7 @@ VpgSettings Identifier to save ```yaml Type: String Parameter Sets: (All) -Aliases: +Aliases: vpgSettingsId Required: True Position: 0 diff --git a/docs/Set-ZertoAlert.md b/docs/Set-ZertoAlert.md index 6498a31..9e68770 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 Required: True Position: Named diff --git a/docs/Start-ZertoCloneVpg.md b/docs/Start-ZertoCloneVpg.md index 4f1a709..467068c 100644 --- a/docs/Start-ZertoCloneVpg.md +++ b/docs/Start-ZertoCloneVpg.md @@ -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 diff --git a/docs/Start-ZertoFailoverTest.md b/docs/Start-ZertoFailoverTest.md index a14fafb..c5622da 100644 --- a/docs/Start-ZertoFailoverTest.md +++ b/docs/Start-ZertoFailoverTest.md @@ -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 From e1e08f4d0595451557ac541980ec2a54d1f1d921 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Tue, 26 Mar 2019 15:39:17 -0400 Subject: [PATCH 004/147] Create External Help File Test --- Tests/Public/External-Help.Tests.ps1 | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Tests/Public/External-Help.Tests.ps1 diff --git a/Tests/Public/External-Help.Tests.ps1 b/Tests/Public/External-Help.Tests.ps1 new file mode 100644 index 0000000..363c91b --- /dev/null +++ b/Tests/Public/External-Help.Tests.ps1 @@ -0,0 +1,10 @@ +$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper' +$publicFiles = Get-ChildItem "$filePath" -File + +describe "External Help Present" { + foreach ($file in $publicFiles) { + it "External Help File Defined" { + Get-Content -Path $file.fullName -First 1 | should be "<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>" + } + } +} From 0a4581b0ab2d10092d7aebbace6f893c0a8828bb Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Tue, 26 Mar 2019 15:39:27 -0400 Subject: [PATCH 005/147] Add External Help File Def --- ZertoApiWrapper/Public/Export-ZertoVpg.ps1 | 1 + ZertoApiWrapper/Public/Import-ZertoVpg.ps1 | 1 + ZertoApiWrapper/Public/Install-ZertoVra.ps1 | 2 +- ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 index 90d0c73..72224e6 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( diff --git a/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 index f3e54ec..4c269d0 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( diff --git a/ZertoApiWrapper/Public/Install-ZertoVra.ps1 b/ZertoApiWrapper/Public/Install-ZertoVra.ps1 index d549457..719f6a4 100644 --- a/ZertoApiWrapper/Public/Install-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Install-ZertoVra.ps1 @@ -1,5 +1,5 @@ -#TODO - Add ability to installed with root password. <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> +#TODO - Add ability to installed with root password. function Install-ZertoVra { [cmdletbinding( SupportsShouldProcess = $true )] param( diff --git a/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 b/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 index 51eee76..401b85d 100644 --- a/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 +++ b/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 @@ -1,3 +1,4 @@ +<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function New-ZertoVpgSettingsIdentifier { [cmdletbinding()] param( From bc0f509870a21417a9d88d6961bf463169fa2fc2 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Tue, 26 Mar 2019 19:22:51 -0400 Subject: [PATCH 006/147] Consolidate Tests to One File --- Tests/Public/ZertoApiWrapper.Tests.ps1 | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Tests/Public/ZertoApiWrapper.Tests.ps1 b/Tests/Public/ZertoApiWrapper.Tests.ps1 index 529c086..f0e8485 100644 --- a/Tests/Public/ZertoApiWrapper.Tests.ps1 +++ b/Tests/Public/ZertoApiWrapper.Tests.ps1 @@ -1,9 +1,8 @@ +$moduleName = "ZertoApiWrapper" $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) @@ -12,12 +11,27 @@ $credential = New-Object -TypeName System.Management.Automation.PSCredential($us $zertoServer = "192.168.1.100" $zertoPort = "7669" +Import-Module $modulePath\$moduleFileName + Describe "File Tests" { - $commands = Get-Command -Module ZertoApiWrapper | Select-Object -ExpandProperty Name + Remove-Module $moduleName -Force + Import-Module $modulePath\$moduleFileName + $commands = Get-Command -Module $moduleName | 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 +} + +describe "External Help Defination Present" { + $publicFiles = Get-ChildItem "$filePath" -File + foreach ($file in $publicFiles) { + it "External Help File is Defined" { + Get-Content -Path $file.fullName -First 1 | should be "<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>" + } + } +} + +Describe "Connection Tests" \ No newline at end of file From 5c0066eaba5a875a21d360e1f47ce048622258ed Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Tue, 26 Mar 2019 20:43:48 -0400 Subject: [PATCH 007/147] Create Remove-ZertoPeerSite.ps1 --- .../Public/Remove-ZertoPeerSite.ps1 | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 ZertoApiWrapper/Public/Remove-ZertoPeerSite.ps1 diff --git a/ZertoApiWrapper/Public/Remove-ZertoPeerSite.ps1 b/ZertoApiWrapper/Public/Remove-ZertoPeerSite.ps1 new file mode 100644 index 0000000..6eb8740 --- /dev/null +++ b/ZertoApiWrapper/Public/Remove-ZertoPeerSite.ps1 @@ -0,0 +1,79 @@ +<# .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 + )] + [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 + )] + [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 From 9efce3dd18978aa0dffe9eafeba8af689f895e2a Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Tue, 26 Mar 2019 20:44:03 -0400 Subject: [PATCH 008/147] Create Remove-ZertoPeerSite.md --- docs/Remove-ZertoPeerSite.md | 145 +++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 docs/Remove-ZertoPeerSite.md diff --git a/docs/Remove-ZertoPeerSite.md b/docs/Remove-ZertoPeerSite.md new file mode 100644 index 0000000..8dd12d0 --- /dev/null +++ b/docs/Remove-ZertoPeerSite.md @@ -0,0 +1,145 @@ +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: +schema: 2.0.0 +--- + +# Remove-ZertoPeerSite + +## SYNOPSIS + +## SYNTAX + +### siteIdentifier (Default) +``` +Remove-ZertoPeerSite -siteIdentifier [-keepTargetDisks] [-WhatIf] [-Confirm] [] +``` + +### peerSiteName +``` +Remove-ZertoPeerSite -peerSiteName [-keepTargetDisks] [-WhatIf] [-Confirm] [] +``` + +### hostName +``` +Remove-ZertoPeerSite -hostName [-keepTargetDisks] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +{{Fill in the Description}} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## 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 From be44ad41c49a013ae9f81c7a216d2d184cedb569 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Tue, 26 Mar 2019 20:53:45 -0400 Subject: [PATCH 009/147] Update Help Files Remove-ZertoPeerSite --- .../Public/en-us/ZertoApiWrapper-help.xml | 273 ++++++++++++++++++ docs/Remove-ZertoPeerSite.md | 27 +- 2 files changed, 296 insertions(+), 4 deletions(-) diff --git a/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml b/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml index d47de4f..0ee3eb7 100644 --- a/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml +++ b/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml @@ -10021,6 +10021,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 diff --git a/docs/Remove-ZertoPeerSite.md b/docs/Remove-ZertoPeerSite.md index 8dd12d0..142d574 100644 --- a/docs/Remove-ZertoPeerSite.md +++ b/docs/Remove-ZertoPeerSite.md @@ -1,7 +1,7 @@ --- external help file: ZertoApiWrapper-help.xml Module Name: ZertoApiWrapper -online version: +online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Remove-ZertoPeerSite.md schema: 2.0.0 --- @@ -9,6 +9,8 @@ schema: 2.0.0 ## SYNOPSIS +Unpair the current site from another site paired to it. + ## SYNTAX ### siteIdentifier (Default) @@ -27,16 +29,31 @@ Remove-ZertoPeerSite -hostName [-keepTargetDisks] [-WhatIf] [-Confirm ``` ## DESCRIPTION -{{Fill in the Description}} + +Unpair the current site from another site paired to it. ## EXAMPLES ### Example 1 ```powershell -PS C:\> {{ Add example code here }} +PS C:\> Remove-ZertoPeerSite -siteIdentifier "MySiteIdentifier" ``` -{{ Add example description here }} +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 @@ -143,3 +160,5 @@ For more information, see about_CommonParameters (http://go.microsoft.com/fwlink ## 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 From bbcbb4a9706259967f195a1e9a5755b9e543bee9 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 27 Mar 2019 07:51:49 -0400 Subject: [PATCH 010/147] Streamline Tests and Builds --- Tests/Public/ZertoApiWrapper.Tests.ps1 | 24 ++++++++++++------------ ZertoApiWrapper.build.ps1 | 9 +++++++++ ZertoApiWrapper/ZertoApiWrapper.psd1 | 8 ++++---- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/Tests/Public/ZertoApiWrapper.Tests.ps1 b/Tests/Public/ZertoApiWrapper.Tests.ps1 index f0e8485..31ca21e 100644 --- a/Tests/Public/ZertoApiWrapper.Tests.ps1 +++ b/Tests/Public/ZertoApiWrapper.Tests.ps1 @@ -1,6 +1,7 @@ $moduleName = "ZertoApiWrapper" $moduleFileName = "ZertoApiWrapper.psm1" $filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper' +$docsPath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests/Public', 'docs' $fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.' $modulePath = $filePath -replace "Public", "" $userName = "zerto\build" @@ -18,20 +19,19 @@ Describe "File Tests" { Import-Module $modulePath\$moduleFileName $commands = Get-Command -Module $moduleName | Select-Object -ExpandProperty Name foreach ($command in $commands) { + $externalHelpFile = "{0}/{1}.md" -f $docsPath, $command $path = "{0}/{1}.ps1" -f $filePath, $command - it "$command is backed by a file with the same name" { - $path | should exist + context "$command File Tests" { + it "$command is backed by a file with the same name" { + $path | should exist + } + it "$command has an external help file" { + $externalHelpFile | should exist + } + it "$command has the External Help File Defined" { + Get-Content -Path $path -First 1 | should be "<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>" + } } } } -describe "External Help Defination Present" { - $publicFiles = Get-ChildItem "$filePath" -File - foreach ($file in $publicFiles) { - it "External Help File is Defined" { - Get-Content -Path $file.fullName -First 1 | should be "<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>" - } - } -} - -Describe "Connection Tests" \ No newline at end of file diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index d4f7348..4ae2195 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -21,3 +21,12 @@ task Analyze { } } +task FileTests { + Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" +} + +task BuildPsd1 { + $functionsToExportPath = "{0}\ZertoApiWrapper\Public\" -f $MyInvocation.MyCommand.PSPath + $functionsToExport = (Get-ChildItem -Path $functionsToExportPath -File).name.Replace('.ps1', '') + $functionsToExport +} diff --git a/ZertoApiWrapper/ZertoApiWrapper.psd1 b/ZertoApiWrapper/ZertoApiWrapper.psd1 index 58177f0..9c4c9a4 100644 --- a/ZertoApiWrapper/ZertoApiWrapper.psd1 +++ b/ZertoApiWrapper/ZertoApiWrapper.psd1 @@ -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 = @() From 9ff003bbe03de13254f3dfe72863494a12fcc023 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 27 Mar 2019 18:19:31 -0400 Subject: [PATCH 011/147] Test Updates --- Tests/Public/Connect-ZertoServer.Tests.ps1 | 2 +- Tests/Public/ZertoApiWrapper.Tests.ps1 | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Tests/Public/Connect-ZertoServer.Tests.ps1 b/Tests/Public/Connect-ZertoServer.Tests.ps1 index c55a46f..30d5784 100644 --- a/Tests/Public/Connect-ZertoServer.Tests.ps1 +++ b/Tests/Public/Connect-ZertoServer.Tests.ps1 @@ -9,7 +9,7 @@ $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" +$zertoServer = "192.168.1.100" $zertoPort = "7669" Describe "Connect-ZertoServer" { diff --git a/Tests/Public/ZertoApiWrapper.Tests.ps1 b/Tests/Public/ZertoApiWrapper.Tests.ps1 index 31ca21e..94d1e0e 100644 --- a/Tests/Public/ZertoApiWrapper.Tests.ps1 +++ b/Tests/Public/ZertoApiWrapper.Tests.ps1 @@ -1,7 +1,7 @@ $moduleName = "ZertoApiWrapper" $moduleFileName = "ZertoApiWrapper.psm1" $filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper' -$docsPath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests/Public', 'docs' +$docsPath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests[\\\/]Public', 'docs' $fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.' $modulePath = $filePath -replace "Public", "" $userName = "zerto\build" @@ -25,6 +25,17 @@ Describe "File Tests" { it "$command is backed by a file with the same name" { $path | should exist } + it "$command file has openbraces on the same line as the statement" { + $content = Get-Content -Path $path + $openingBracesExist = $content | Where-Object {$_.Trim() -eq '{'} + if ($openingBracesExist) { + Write-Warning "Found the following opening brances on their own line:" + foreach ($openingBrace in $openingBracesExist) { + Write-Warning "Opening Brace on it's own line - $openingBrace" + } + } + $openingBracesExist | should benullorempty + } it "$command has an external help file" { $externalHelpFile | should exist } From 2eaba753187ce26f7c0016b8ea790ca2fa76f025 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 27 Mar 2019 18:19:50 -0400 Subject: [PATCH 012/147] Working with Build Options --- ZertoApiWrapper.build.ps1 | 63 ++++++++++++++++++++++++------ ZertoApiWrapper.build.ps1.old | 32 +++++++++++++++ ZertoApiWrapper.settings.ps1 | 73 +++++++++++++++++++++++++++++++++++ version.txt | 1 + 4 files changed, 157 insertions(+), 12 deletions(-) create mode 100644 ZertoApiWrapper.build.ps1.old create mode 100644 version.txt diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 4ae2195..ebcc81e 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -1,17 +1,45 @@ -task . InstallDependencies, Analyze +#Requires -Modules 'InvokeBuild' -task InstallDependencies { - Install-Module Pester -Force - Install-Module PSScriptAnalyzer -Force +. '.\ZertoApiWrapper.settings.ps1' +import-module .\ZertoApiWrapper\ZertoApiWrapper.psd1 + +[CmdletBinding()] +param([switch]$Install, + [string]$Configuration = (property Configuration Release)) + +$targetDir = "temp/$Configuration/ZertoApiWrapper" + +task . Analyze + +<# 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 Analyze CheckPSScriptAnalyzerInstalled, CheckPesterInstalled, CheckPlatyPSInstalled, { $scriptAnalyzerParams = @{ Path = "$BuildRoot\ZertoApiWrapper\" Severity = @('Error', 'Warning') Recurse = $true Verbose = $false - ExcludeRule = 'PSUseDeclaredVarsMoreThanAssignments' + ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments', 'PSUseShouldProcessForStateChangingFunctions') } $saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams @@ -21,12 +49,23 @@ task Analyze { } } -task FileTests { - Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" +$buildMamlParams = @{ + Inputs = { Get-ChildItem docs/*.md } + Outputs = "$targetDir/en-us/ZertoApiWrapper-help.xml" } -task BuildPsd1 { - $functionsToExportPath = "{0}\ZertoApiWrapper\Public\" -f $MyInvocation.MyCommand.PSPath - $functionsToExport = (Get-ChildItem -Path $functionsToExportPath -File).name.Replace('.ps1', '') - $functionsToExport +task BuildMamlHelp @buildMamlParams { + platyPS\New-ExternalHelp .\docs -Force -OutputPath $buildMamlParams.Outputs +} + +task FileTests CheckPesterInstalled, { + Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -Show Fails +} + +task UpdateModuleManifest { + $functionsToExportPath = "$BuildRoot\ZertoApiWrapper\Public\" + $functionsToExport = (Get-ChildItem -Path $functionsToExportPath -File).name.Replace('.ps1', '') + $version = Get-Module -Name ZertoApiWrapper | select Version + $buildVersion = $version.Build + } diff --git a/ZertoApiWrapper.build.ps1.old b/ZertoApiWrapper.build.ps1.old new file mode 100644 index 0000000..39640d6 --- /dev/null +++ b/ZertoApiWrapper.build.ps1.old @@ -0,0 +1,32 @@ +task . FileTests, BuildPsd1, Analyze + +task InstallDependencies { + Install-Module Pester -Force + Install-Module PSScriptAnalyzer -Force +} + +task Analyze { + $scriptAnalyzerParams = @{ + Path = "$BuildRoot\ZertoApiWrapper\" + Severity = @('Error', 'Warning') + Recurse = $true + Verbose = $false + ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments','PSUseShouldProcessForStateChangingFunctions') + } + $saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams + + if ($saResults) { + $saResults | Format-Table + throw "One or more PSScriptAnalyzer errors/warnings were found" + } +} + +task FileTests { + Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" +} + +task BuildPsd1 { + $functionsToExportPath = "$BuildRoot\ZertoApiWrapper\Public\" + $functionsToExport = (Get-ChildItem -Path $functionsToExportPath -File).name.Replace('.ps1', '') + $functionsToExport +} diff --git a/ZertoApiWrapper.settings.ps1 b/ZertoApiWrapper.settings.ps1 index e69de29..f18f9da 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/version.txt b/version.txt new file mode 100644 index 0000000..6e8bf73 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.1.0 From e1c5c6d21264bc6e6dae3669ea073fca25594a5d Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 27 Mar 2019 21:46:06 -0400 Subject: [PATCH 013/147] More Build Testing --- ZertoApiWrapper.build.ps1 | 35 +++++++++++++++++++++++++++-------- ZertoApiWrapper.settings.ps1 | 2 +- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index ebcc81e..d37dca3 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -1,13 +1,13 @@ #Requires -Modules 'InvokeBuild' . '.\ZertoApiWrapper.settings.ps1' -import-module .\ZertoApiWrapper\ZertoApiWrapper.psd1 +# import-module "$BuildRoot\ZertoApiWrapper\ZertoApiWrapper.psd1" -Verbose -Force -[CmdletBinding()] +<# [CmdletBinding()] param([switch]$Install, [string]$Configuration = (property Configuration Release)) -$targetDir = "temp/$Configuration/ZertoApiWrapper" +$targetDir = "temp/$Configuration/ZertoApiWrapper" #> task . Analyze @@ -62,10 +62,29 @@ task FileTests CheckPesterInstalled, { Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -Show Fails } -task UpdateModuleManifest { +task UpdateModuleFunctions { $functionsToExportPath = "$BuildRoot\ZertoApiWrapper\Public\" - $functionsToExport = (Get-ChildItem -Path $functionsToExportPath -File).name.Replace('.ps1', '') - $version = Get-Module -Name ZertoApiWrapper | select Version - $buildVersion = $version.Build - + Update-ModuleManifest -Path "$BuildRoot\ZertoApiWrapper\ZertoApiWrapper.psd1" -FunctionsToExport $(Get-ChildItem -Path $functionsToExportPath -File).name.Replace('.ps1', '') +} + +task UpdateVersion { + try { + $moduleManifestFile = "$BuildRoot\ZertoApiWrapper\ZertoApiWrapper.psd1" + $manifestContent = Get-Content $moduleManifestFile -Raw + [version]$version = [regex]::matches($manifestContent, "ModuleVersion\s=\s\'(?(\d+\.)?(\d+\.)?(\*|\d+))") | ForEach-Object {$_.groups['version'].value} + $newVersion = "{0}.{1}.{2}" -f $version.Major, $version.Minor, ($version.Build + 1) + + $replacements = @{ + "ModuleVersion = '.*'" = "ModuleVersion = '$newVersion'" + } + + $replacements.GetEnumerator() | ForEach-Object { + $manifestContent = $manifestContent -replace $_.Key, $_.Value + } + + $manifestContent | Set-Content -Path "$moduleManifestFile" + } catch { + Write-Error -Message $_.Exception.Message + $host.SetShouldExit($LastExitCode) + } } diff --git a/ZertoApiWrapper.settings.ps1 b/ZertoApiWrapper.settings.ps1 index f18f9da..2d56eae 100644 --- a/ZertoApiWrapper.settings.ps1 +++ b/ZertoApiWrapper.settings.ps1 @@ -13,7 +13,7 @@ $Settings = @{ UnitTestParams = @{ Script = '.\Tests\Unit' - CodeCoverage = (Get-ChildItem -Path '.\PSCodeHealth\' -File -Filter "*.ps1" -Recurse).FullName | Where-Object { $_ -Match "Public|Private" } + #CodeCoverage = (Get-ChildItem -Path '.\PSCodeHealth\' -File -Filter "*.ps1" -Recurse).FullName | Where-Object { $_ -Match "Public|Private" } OutputFile = "$PSScriptRoot\BuildOutput\UnitTestsResult.xml" PassThru = $True } From dbc6086fee201ca1c787963abd575fdeca04d2bc Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 08:58:09 -0400 Subject: [PATCH 014/147] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 64 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..bf898f5 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,64 @@ +# 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 + +jobs: + - job: Build_PS_Win2016 + pool: + vmImage: vs2017-win2016 + steps: + - powershell: | + .\build.ps1 -Verbose + displayName: 'Build and Test' + - task: PublishTestResults@2 + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/TestResults.xml' + testRunTitle: 'PS_Win2016' + displayName: 'Publish Test Results' + + - job: Build_PSCore_Ubuntu1604 + + pool: + vmImage: ubuntu-16.04 + + steps: + - script: | + curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - + curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list + sudo apt-get update + sudo apt-get install -y powershell + displayName: 'Install PowerShell Core' + + - script: | + pwsh -c '.\build.ps1' + displayName: 'Build and Test' + + - task: PublishTestResults@2 + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/TestResults.xml' + testRunTitle: 'PSCore_Ubuntu1604' + displayName: 'Publish Test Results' + + - job: Build_PSCore_MacOS1013 + pool: + vmImage: xcode9-macos10.13 + steps: + - script: | + brew update + brew tap caskroom/cask + brew cask install powershell + displayName: 'Install PowerShell Core' + + - script: | + pwsh -c '.\build.ps1' + displayName: 'Build and Test' + + - task: PublishTestResults@2 + inputs: + testRunner: 'NUnit' + testResultsFiles: '**/TestResults.xml' + testRunTitle: 'PSCore_MacOS1013' + displayName: 'Publish Test Results' \ No newline at end of file From 830f5633b50f3d9acd4d6da25a7278f80d714419 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 09:13:38 -0400 Subject: [PATCH 015/147] Building Out Build Items --- ZertoApiWrapper.Depend.psd1 | 50 +++++++++++++++++++++++++++++++++++++ ZertoApiWrapper.build.ps1 | 42 ++++++++++++++++++++++++++----- build.ps1 | 16 ++++++++++++ 3 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 ZertoApiWrapper.Depend.psd1 create mode 100644 build.ps1 diff --git a/ZertoApiWrapper.Depend.psd1 b/ZertoApiWrapper.Depend.psd1 new file mode 100644 index 0000000..e0e013c --- /dev/null +++ b/ZertoApiWrapper.Depend.psd1 @@ -0,0 +1,50 @@ +@{ + psake = @{ + Name = 'InvokeBuild' + DependencyType = 'PSGalleryModule' + Parameters = @{ + Repository = 'PSGallery' + SkipPublisherCheck = $true + } + Target = 'CurrentUser' + Version = '5.4.3' + Tags = 'Bootstrap' + } + + Pester = @{ + Name = 'Pester' + DependencyType = 'PSGalleryModule' + Parameters = @{ + Repository = 'PSGallery' + SkipPublisherCheck = $true + } + Target = 'CurrentUser' + Version = '4.6.0' + Tags = 'Test' + } + + PSScriptAnalyzer = @{ + Name = 'PSScriptAnalyzer' + DependencyType = 'PSGalleryModule' + Parameters = @{ + Repository = 'PSGallery' + SkipPublisherCheck = $true + } + Target = 'CurrentUser' + Version = '1.17.1' + Tags = 'Test' + } + + Platyps = @{ + Name = 'Platyps' + DependencyType = 'PSGalleryModule' + Parameters = @{ + Repository = 'PSGallery' + SkipPublisherCheck = $true + } + Target = 'CurrentUser' + Version = '0.12.0' + Tags = 'Build' + } + +} diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index d4f7348..a8df4ca 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -1,17 +1,44 @@ -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" #> + +task . Analyze, FileTests + +<# 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 Analyze CheckPSScriptAnalyzerInstalled, CheckPesterInstalled, CheckPlatyPSInstalled, { $scriptAnalyzerParams = @{ Path = "$BuildRoot\ZertoApiWrapper\" Severity = @('Error', 'Warning') Recurse = $true Verbose = $false - ExcludeRule = 'PSUseDeclaredVarsMoreThanAssignments' + ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments', 'PSUseShouldProcessForStateChangingFunctions') } $saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams @@ -21,3 +48,6 @@ task Analyze { } } +task FileTests CheckPesterInstalled, { + Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -Show Fails +} \ No newline at end of file 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 . From 973143314e8c4dfca0900f06db41287e0cdb8479 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 09:19:06 -0400 Subject: [PATCH 016/147] Move Module Installs to Bootstrap Tag --- ZertoApiWrapper.Depend.psd1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ZertoApiWrapper.Depend.psd1 b/ZertoApiWrapper.Depend.psd1 index e0e013c..9b60641 100644 --- a/ZertoApiWrapper.Depend.psd1 +++ b/ZertoApiWrapper.Depend.psd1 @@ -20,7 +20,7 @@ } Target = 'CurrentUser' Version = '4.6.0' - Tags = 'Test' + Tags = 'Bootstrap' } PSScriptAnalyzer = @{ @@ -32,7 +32,7 @@ } Target = 'CurrentUser' Version = '1.17.1' - Tags = 'Test' + Tags = 'Bootstrap' } Platyps = @{ @@ -44,7 +44,7 @@ } Target = 'CurrentUser' Version = '0.12.0' - Tags = 'Build' + Tags = 'Bootstrap' } } From d67eb6530f36c7a90bafec61bf3d8f22c70bf0fa Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 09:24:17 -0400 Subject: [PATCH 017/147] Ignore PSUseToExportFieldsInManifest Checks --- ZertoApiWrapper.build.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index a8df4ca..272353d 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -38,7 +38,7 @@ task Analyze CheckPSScriptAnalyzerInstalled, CheckPesterInstalled, CheckPlatyPSI Severity = @('Error', 'Warning') Recurse = $true Verbose = $false - ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments', 'PSUseShouldProcessForStateChangingFunctions') + ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments', 'PSUseShouldProcessForStateChangingFunctions', 'PSUseToExportFieldsInManifest') } $saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams @@ -50,4 +50,4 @@ task Analyze CheckPSScriptAnalyzerInstalled, CheckPesterInstalled, CheckPlatyPSI task FileTests CheckPesterInstalled, { Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -Show Fails -} \ No newline at end of file +} From 6b8587a30eac09fde3eadcd2718447b4b870b94e Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 09:29:24 -0400 Subject: [PATCH 018/147] Update Generic Tests --- Tests/Public/ZertoApiWrapper.Tests.ps1 | 42 ++++++++++++++++++-------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/Tests/Public/ZertoApiWrapper.Tests.ps1 b/Tests/Public/ZertoApiWrapper.Tests.ps1 index 529c086..b9f88f4 100644 --- a/Tests/Public/ZertoApiWrapper.Tests.ps1 +++ b/Tests/Public/ZertoApiWrapper.Tests.ps1 @@ -1,23 +1,39 @@ +$moduleName = "ZertoApiWrapper" $moduleFileName = "ZertoApiWrapper.psm1" $filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper' -$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.' +$docsPath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests[\\\/]Public', 'docs' $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" +Import-Module $modulePath\$moduleFileName Describe "File Tests" { - $commands = Get-Command -Module ZertoApiWrapper | Select-Object -ExpandProperty Name + Remove-Module $moduleName -Force + Import-Module $modulePath\$moduleFileName + $commands = Get-Command -Module $moduleName | Select-Object -ExpandProperty Name foreach ($command in $commands) { + $externalHelpFile = "{0}/{1}.md" -f $docsPath, $command $path = "{0}/{1}.ps1" -f $filePath, $command - it "$command is backed by a file with the same name" { - $path | should exist + context "$command File Tests" { + it "$command is backed by a file with the same name" { + $path | should exist + } + it "$command file has openbraces on the same line as the statement" { + $content = Get-Content -Path $path + $openingBracesExist = $content | Where-Object {$_.Trim() -eq '{'} + if ($openingBracesExist) { + Write-Warning "Found the following opening brances on their own line:" + foreach ($openingBrace in $openingBracesExist) { + Write-Warning "Opening Brace on it's own line - $openingBrace" + } + } + $openingBracesExist | should benullorempty + } + it "$command has an external help file" { + $externalHelpFile | should exist + } + it "$command has the External Help File Defined" { + Get-Content -Path $path -First 1 | should be "<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>" + } } } -} \ No newline at end of file +} From f99c95c6c46d464a458389b8aa422593c9286197 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 09:53:11 -0400 Subject: [PATCH 019/147] Rename to remove plural noun --- ZertoApiWrapper/Public/Import-ZertoVpg.ps1 | 2 +- ...gSettings.ps1 => Save-ZertoVpgSetting.ps1} | 2 +- ...VpgSettings.md => Save-ZertoVpgSetting.md} | 184 +++++++++--------- 3 files changed, 94 insertions(+), 94 deletions(-) rename ZertoApiWrapper/Public/{Save-ZertoVpgSettings.ps1 => Save-ZertoVpgSetting.ps1} (95%) rename docs/{Save-ZertoVpgSettings.md => Save-ZertoVpgSetting.md} (85%) diff --git a/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 index 4c269d0..bbc45ef 100644 --- a/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 @@ -24,7 +24,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/Save-ZertoVpgSettings.ps1 b/ZertoApiWrapper/Public/Save-ZertoVpgSetting.ps1 similarity index 95% rename from ZertoApiWrapper/Public/Save-ZertoVpgSettings.ps1 rename to ZertoApiWrapper/Public/Save-ZertoVpgSetting.ps1 index 24f5084..8e06784 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 )] diff --git a/docs/Save-ZertoVpgSettings.md b/docs/Save-ZertoVpgSetting.md similarity index 85% rename from docs/Save-ZertoVpgSettings.md rename to docs/Save-ZertoVpgSetting.md index 16d9dda..2e2efaf 100644 --- a/docs/Save-ZertoVpgSettings.md +++ b/docs/Save-ZertoVpgSetting.md @@ -1,92 +1,92 @@ ---- -external help file: ZertoApiWrapper-help.xml -Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSettings.md -schema: 2.0.0 ---- - -# Save-ZertoVpgSettings - -## SYNOPSIS -Commits the updated Vpg Settings with the configured Vpg Settings Identifier - -## SYNTAX - -``` -Save-ZertoVpgSettings [-vpgSettingsIdentifier] [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -Commits the updated Vpg Settings with the configured Vpg Settings Identifier - -## EXAMPLES - -### Example 1 -```powershell -PS C:> Save-ZertoVpgSettings -vpgSettingsIdentifier "MyVpgSettingsIdentifier" -``` - -Commits vpg settings with vpg settings identifier "MyVpgSettingsIdentifier" - -## PARAMETERS - -### -vpgSettingsIdentifier -VpgSettings Identifier to save - -```yaml -Type: String -Parameter Sets: (All) -Aliases: vpgSettingsId - -Required: True -Position: 0 -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#) +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSetting.md +schema: 2.0.0 +--- + +# Save-ZertoVpgSetting + +## SYNOPSIS +Commits the updated Vpg Settings with the configured Vpg Settings Identifier + +## SYNTAX + +``` +Save-ZertoVpgSetting [-vpgSettingsIdentifier] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Commits the updated Vpg Settings with the configured Vpg Settings Identifier + +## EXAMPLES + +### Example 1 +```powershell +PS C:> Save-ZertoVpgSetting -vpgSettingsIdentifier "MyVpgSettingsIdentifier" +``` + +Commits vpg settings with vpg settings identifier "MyVpgSettingsIdentifier" + +## PARAMETERS + +### -vpgSettingsIdentifier +VpgSettings Identifier to save + +```yaml +Type: String +Parameter Sets: (All) +Aliases: vpgSettingsId + +Required: True +Position: 1 +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#) From 3098566c890d8a733d67f6c46ef9726b749a11e3 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 09:53:48 -0400 Subject: [PATCH 020/147] Update Markdown Help --- docs/Remove-ZertoPeerSite.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/Remove-ZertoPeerSite.md b/docs/Remove-ZertoPeerSite.md index 142d574..6bb3816 100644 --- a/docs/Remove-ZertoPeerSite.md +++ b/docs/Remove-ZertoPeerSite.md @@ -150,8 +150,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 From deae94227217ce790e94224029826e967725a5c1 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 10:13:10 -0400 Subject: [PATCH 021/147] Update examples to single noun --- .../Public/en-us/ZertoApiWrapper-help.xml | 24 +++++++++---------- docs/Get-ZertoVpgSetting.md | 10 ++++---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml b/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml index 0ee3eb7..03653be 100644 --- a/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml +++ b/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml @@ -5977,35 +5977,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" @@ -10656,9 +10656,9 @@ - Save-ZertoVpgSettings + Save-ZertoVpgSetting Save - ZertoVpgSettings + ZertoVpgSetting Commits the updated Vpg Settings with the configured Vpg Settings Identifier @@ -10668,8 +10668,8 @@ - Save-ZertoVpgSettings - + Save-ZertoVpgSetting + vpgSettingsIdentifier VpgSettings Identifier to save @@ -10706,7 +10706,7 @@ - + vpgSettingsIdentifier VpgSettings Identifier to save @@ -10771,7 +10771,7 @@ -------------------------- Example 1 -------------------------- - PS C:> Save-ZertoVpgSettings -vpgSettingsIdentifier "MyVpgSettingsIdentifier" + PS C:> Save-ZertoVpgSetting -vpgSettingsIdentifier "MyVpgSettingsIdentifier" Commits vpg settings with vpg settings identifier "MyVpgSettingsIdentifier" @@ -10780,7 +10780,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 diff --git a/docs/Get-ZertoVpgSetting.md b/docs/Get-ZertoVpgSetting.md index d812532..8c97811 100644 --- a/docs/Get-ZertoVpgSetting.md +++ b/docs/Get-ZertoVpgSetting.md @@ -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" From 5a10669403d96ed42036598c511ab764df6d58b3 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 10:14:11 -0400 Subject: [PATCH 022/147] Add Build Tasks for Help System --- ZertoApiWrapper.build.ps1 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 272353d..00e604a 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -51,3 +51,21 @@ task Analyze CheckPSScriptAnalyzerInstalled, CheckPesterInstalled, CheckPlatyPSI task FileTests CheckPesterInstalled, { Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -Show Fails } + +$buildMamlParams = @{ + Inputs = { Get-ChildItem docs\*.md } + Outputs = ".\ZertoApiWrapper\Public\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 +} From 3e9f450208775091b32692baed99ee6ca38bae3a Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 10:32:23 -0400 Subject: [PATCH 023/147] Fix Test Publishing --- ZertoApiWrapper.build.ps1 | 3 ++- azure-pipelines.yml | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 00e604a..e469509 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -49,7 +49,8 @@ task Analyze CheckPSScriptAnalyzerInstalled, CheckPesterInstalled, CheckPlatyPSI } task FileTests CheckPesterInstalled, { - Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -Show Fails + $testResultsFile = "$BuildRoot\Tests\Public\TestResults.xml" + Invoke-Pester -Script "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -OutputFile $testResultsFile -PassThru } $buildMamlParams = @{ diff --git a/azure-pipelines.yml b/azure-pipelines.yml index bf898f5..afbd413 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -14,15 +14,15 @@ jobs: - task: PublishTestResults@2 inputs: testRunner: 'NUnit' - testResultsFiles: '**/TestResults.xml' + testResultsFiles: '**/Public/TestResults.xml' testRunTitle: 'PS_Win2016' displayName: 'Publish Test Results' - + - job: Build_PSCore_Ubuntu1604 - + pool: vmImage: ubuntu-16.04 - + steps: - script: | curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - @@ -30,18 +30,18 @@ jobs: sudo apt-get update sudo apt-get install -y powershell displayName: 'Install PowerShell Core' - + - script: | pwsh -c '.\build.ps1' displayName: 'Build and Test' - + - task: PublishTestResults@2 inputs: testRunner: 'NUnit' - testResultsFiles: '**/TestResults.xml' + testResultsFiles: '**/Public/TestResults.xml' testRunTitle: 'PSCore_Ubuntu1604' displayName: 'Publish Test Results' - + - job: Build_PSCore_MacOS1013 pool: vmImage: xcode9-macos10.13 @@ -51,14 +51,14 @@ jobs: brew tap caskroom/cask brew cask install powershell displayName: 'Install PowerShell Core' - + - script: | pwsh -c '.\build.ps1' displayName: 'Build and Test' - + - task: PublishTestResults@2 inputs: testRunner: 'NUnit' - testResultsFiles: '**/TestResults.xml' + testResultsFiles: '**/Public/TestResults.xml' testRunTitle: 'PSCore_MacOS1013' - displayName: 'Publish Test Results' \ No newline at end of file + displayName: 'Publish Test Results' From b460e87702081e5bb8ddd1e6d59f06a8989d0122 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 10:38:31 -0400 Subject: [PATCH 024/147] Add Build Status to README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 6508ec2..15ad3b6 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,10 @@ PowerShell Core wrapper for Zerto Virtual Manager API +## Current Build Status + +[![Build Status](https://dev.azure.com/wescarroll/wescarroll/_apis/build/status/wcarroll.ZertoApiWrapper?branchName=master)](https://dev.azure.com/wescarroll/wescarroll/_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. From f085a8e5e021692bac3ef6cc0cfa8909b529cea4 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 11:01:32 -0400 Subject: [PATCH 025/147] Force Windows Test to PwSh --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index afbd413..633d063 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -9,7 +9,7 @@ jobs: vmImage: vs2017-win2016 steps: - powershell: | - .\build.ps1 -Verbose + pwsh -c '.\build.ps1 -Verbose' displayName: 'Build and Test' - task: PublishTestResults@2 inputs: From 5b56a0c15b7ade9f0ac44aeb5c1410ed0a823588 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 13:22:53 -0400 Subject: [PATCH 026/147] Update Build Process Remove unnecessary install calls, set timeouts for each job, and specify job name. --- azure-pipelines.yml | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 633d063..77f1202 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,12 +3,16 @@ # Add steps that build, run tests, deploy, and more: # https://aka.ms/yaml +name: $(TeamProject)_$(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.rr) + jobs: - job: Build_PS_Win2016 + timeoutInMinutes: 10 + cancelTimeoutInMinutes: 2 pool: vmImage: vs2017-win2016 steps: - - powershell: | + - script: | pwsh -c '.\build.ps1 -Verbose' displayName: 'Build and Test' - task: PublishTestResults@2 @@ -19,22 +23,14 @@ jobs: displayName: 'Publish Test Results' - job: Build_PSCore_Ubuntu1604 - + timeoutInMinutes: 10 + cancelTimeoutInMinutes: 2 pool: vmImage: ubuntu-16.04 - steps: - script: | - curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - - curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list - sudo apt-get update - sudo apt-get install -y powershell - displayName: 'Install PowerShell Core' - - - script: | - pwsh -c '.\build.ps1' + pwsh -c '.\build.ps1 -verbose' displayName: 'Build and Test' - - task: PublishTestResults@2 inputs: testRunner: 'NUnit' @@ -43,19 +39,14 @@ jobs: displayName: 'Publish Test Results' - job: Build_PSCore_MacOS1013 + timeoutInMinutes: 10 + cancelTimeoutInMinutes: 2 pool: vmImage: xcode9-macos10.13 steps: - script: | - brew update - brew tap caskroom/cask - brew cask install powershell - displayName: 'Install PowerShell Core' - - - script: | - pwsh -c '.\build.ps1' + pwsh -c '.\build.ps1 -verbose' displayName: 'Build and Test' - - task: PublishTestResults@2 inputs: testRunner: 'NUnit' From 90e06a6dc580dfecb7188b283271b6dac5ebc910 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 13:52:03 -0400 Subject: [PATCH 027/147] Update az pipeline Windows Script Using single quotes will not execute the script. Changing to double quotes should actually run the build process on the Windows Host --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 77f1202..882dc54 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -13,7 +13,7 @@ jobs: vmImage: vs2017-win2016 steps: - script: | - pwsh -c '.\build.ps1 -Verbose' + pwsh -c ".\build.ps1 -Verbose" displayName: 'Build and Test' - task: PublishTestResults@2 inputs: From b8cccd02dcc0b1895ca2238839062c5b80f5a112 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 28 Mar 2019 16:48:21 -0400 Subject: [PATCH 028/147] Ignore all files in Temp directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 03a576d..eece103 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.zip +temp/* From f6e0ffa6db0fe19ce1437712aa9db7810b86218f Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 08:27:13 -0400 Subject: [PATCH 029/147] Add MarkDown Help File Content Test --- Tests/Public/ZertoApiWrapper.Tests.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Tests/Public/ZertoApiWrapper.Tests.ps1 b/Tests/Public/ZertoApiWrapper.Tests.ps1 index b9f88f4..734c23f 100644 --- a/Tests/Public/ZertoApiWrapper.Tests.ps1 +++ b/Tests/Public/ZertoApiWrapper.Tests.ps1 @@ -34,6 +34,14 @@ Describe "File Tests" { it "$command has the External Help File Defined" { Get-Content -Path $path -First 1 | should be "<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>" } + it "$command external Help file is filled out" { + $stubExist = Get-Content -Path $externalHelpFile | Where-Object {$_.Trim() -like '*{{*}}*'} + if ($stubExist) { + Write-Warning "Found a stub in the Markdown File $externalHelpFile" + Write-Warning "$stubExist" + } + $stubExist | should benullorempty + } } } } From 5f42804c0bcc902568c71bd5303b7c2538a242ce Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 08:27:44 -0400 Subject: [PATCH 030/147] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index eece103..e4bc748 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.zip temp/* +Tests/Public/TestResults.xml From 47bc3be463dcf2894dc15258e414f8395dfb8cfc Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 08:27:50 -0400 Subject: [PATCH 031/147] Update LICENSE --- LICENSE | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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. From 802eef60673d8aeb992afba5b82d35eed2bc517b Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 10:19:23 -0400 Subject: [PATCH 032/147] Update Build to Fail on Pester Failure This is expected to fail the build test as one pester test will fail --- ZertoApiWrapper.build.ps1 | 86 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 4 deletions(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index e469509..76a18ca 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -8,7 +8,11 @@ param([switch]$Install, [string]$Configuration = (property Configuration Release)) $targetDir = "temp/$Configuration/ZertoApiWrapper" #> -task . Analyze, FileTests +$versionMajor = '0' +$versionMinor = '1' +$versionBuild = "{0}.{1}" -f $(get-date -format 'yyyyMMdd'), $env:Rev + +task . AnalyzeSourceFiles, CreateModule <# Synopsis: Ensure platyPS is installed #> task CheckPlatyPSInstalled { @@ -32,7 +36,7 @@ task CheckPSScriptAnalyzerInstalled { } <# Synopsis: Analyze ZertoApiWrapper functions for Code Violations #> -task Analyze CheckPSScriptAnalyzerInstalled, CheckPesterInstalled, CheckPlatyPSInstalled, { +task AnalyzeSourceFiles CheckPSScriptAnalyzerInstalled, { $scriptAnalyzerParams = @{ Path = "$BuildRoot\ZertoApiWrapper\" Severity = @('Error', 'Warning') @@ -41,6 +45,21 @@ task Analyze CheckPSScriptAnalyzerInstalled, CheckPesterInstalled, CheckPlatyPSI 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, { + $scriptAnalyzerParams = @{ + Path = "$BuildRoot\Temp\" + Severity = @('Error', 'Warning') + Recurse = $true + Verbose = $false + ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments', 'PSUseShouldProcessForStateChangingFunctions', 'PSUseToExportFieldsInManifest') + } + $saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams if ($saResults) { $saResults | Format-Table @@ -50,12 +69,14 @@ task Analyze CheckPSScriptAnalyzerInstalled, CheckPesterInstalled, CheckPlatyPSI task FileTests CheckPesterInstalled, { $testResultsFile = "$BuildRoot\Tests\Public\TestResults.xml" - Invoke-Pester -Script "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -OutputFile $testResultsFile -PassThru + $results = Invoke-Pester -Script "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -OutputFile $testResultsFile -OutputFormat NUnitXML -EnableExit -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 = ".\ZertoApiWrapper\Public\en-us\ZertoApiWrapper-help.xml" + Outputs = "temp\en-us\ZertoApiWrapper-help.xml" } task BuildMamlHelp CheckPlatyPSInstalled, { @@ -70,3 +91,60 @@ task UpdateMarkdownHelp CheckPlatyPSInstalled, { Import-Module .\ZertoApiWrapper\ZertoApiWrapper.psm1 -Force Update-MarkDownHelp -Path docs -AlphabeticParamsOrder } + +task CreatePsd1ForRelease CleanTemp, { + $functionsToExport = Get-ChildItem -Path 'ZertoApiWrapper\Public\*.ps1' | ForEach-Object { $_.BaseName } + $ManifestParams = @{ + Path = "temp\ZertoApiWrapper.psd1" + RootModule = 'ZertoApiWrapper.psm1' + ModuleVersion = '{0}.{1}.{2}' -f $versionMajor, $versionMinor, $versionBuild + 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 = @() + } + Write-Output $ManifestParams.ModuleVersion + New-ModuleManifest @ManifestParams +} + +task CleanTemp { + Remove-Item -Recurse -Path 'temp\*' +} + +task CreatePsm1ForRelease CreatePsd1ForRelease, { + $emptyLine = "" + $psm1Path = "temp\ZertoApiWrapper.psm1" + $lines = '#------------------------------------------------------------#' + $Public = @( Get-ChildItem -Path $PSScriptRoot\ZertoApiWrapper\Public\*.ps1 -ErrorAction SilentlyContinue ) + $Private = @( Get-ChildItem -Path $PSScriptRoot\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 + } +} + +task CreateModule CleanTemp, FileTests, CreatePsd1ForRelease, CreatePsm1ForRelease, AnalyzeBuiltFiles, BuildMamlHelp, { + +} + From 1fc7bf697e3dd69bd5668b3a49132c5778cd2fd7 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 10:25:46 -0400 Subject: [PATCH 033/147] Create temp folder if it doesn't exist --- ZertoApiWrapper.build.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 76a18ca..751f4bb 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -117,6 +117,9 @@ task CreatePsd1ForRelease CleanTemp, { } task CleanTemp { + if (-not $(Test-Path "$BuildRoot\temp")) { + New-Item -Path $BuildRoot -Name "temp" -ItemType "Directory" + } Remove-Item -Recurse -Path 'temp\*' } From 3c1cdef3a58082cfc3c272cf0bc9282aef4914f3 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 10:51:45 -0400 Subject: [PATCH 034/147] Set Tests to Always Publish --- ZertoApiWrapper.build.ps1 | 2 +- azure-pipelines.yml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 751f4bb..b433623 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -69,7 +69,7 @@ task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, { task FileTests CheckPesterInstalled, { $testResultsFile = "$BuildRoot\Tests\Public\TestResults.xml" - $results = Invoke-Pester -Script "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -OutputFile $testResultsFile -OutputFormat NUnitXML -EnableExit -PassThru + $script:results = Invoke-Pester -Script "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -OutputFile $testResultsFile -PassThru $FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount assert ($results.FailedCount -eq 0) $FailureMessage } diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 882dc54..3baef72 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -21,6 +21,7 @@ jobs: testResultsFiles: '**/Public/TestResults.xml' testRunTitle: 'PS_Win2016' displayName: 'Publish Test Results' + condition: always() - job: Build_PSCore_Ubuntu1604 timeoutInMinutes: 10 @@ -37,6 +38,7 @@ jobs: testResultsFiles: '**/Public/TestResults.xml' testRunTitle: 'PSCore_Ubuntu1604' displayName: 'Publish Test Results' + condition: always() - job: Build_PSCore_MacOS1013 timeoutInMinutes: 10 @@ -53,3 +55,4 @@ jobs: testResultsFiles: '**/Public/TestResults.xml' testRunTitle: 'PSCore_MacOS1013' displayName: 'Publish Test Results' + condition: always() From ef39b549371d1ab043a5acf5273f4b91e6a26c34 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 11:10:16 -0400 Subject: [PATCH 035/147] Update Get-ZertoVirtualizationSite Help --- .../Public/en-us/ZertoApiWrapper-help.xml | 29 ++++++++++++++--- docs/Get-ZertoVirtualizationSite.md | 31 ++++++++++++++++--- 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml b/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml index 03653be..98cacd1 100644 --- a/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml +++ b/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml @@ -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. @@ -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" diff --git a/docs/Get-ZertoVirtualizationSite.md b/docs/Get-ZertoVirtualizationSite.md index 049d2e9..7f44405 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 From 91cd6a2de5aa084f3ab17bd18fe38aba7786d0bb Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 11:22:14 -0400 Subject: [PATCH 036/147] Update Build to show Env Var --- ZertoApiWrapper.build.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index b433623..83ea8c5 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -10,7 +10,7 @@ $targetDir = "temp/$Configuration/ZertoApiWrapper" #> $versionMajor = '0' $versionMinor = '1' -$versionBuild = "{0}.{1}" -f $(get-date -format 'yyyyMMdd'), $env:Rev +$versionBuild = "{0}.{1}" -f $(get-date -format 'yyyyMMdd'), "$env:Rev:.r" task . AnalyzeSourceFiles, CreateModule @@ -112,6 +112,8 @@ task CreatePsd1ForRelease CleanTemp, { VariablesToExport = @() AliasesToExport = @() } + $myEnv = Get-Item Env: + Write-Output $myEnv Write-Output $ManifestParams.ModuleVersion New-ModuleManifest @ManifestParams } From 6899ded49e17c33bf461a18e45bd5aca929ef36e Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 11:37:54 -0400 Subject: [PATCH 037/147] Update Build Version Methodology --- ZertoApiWrapper.build.ps1 | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 83ea8c5..911780f 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -10,7 +10,7 @@ $targetDir = "temp/$Configuration/ZertoApiWrapper" #> $versionMajor = '0' $versionMinor = '1' -$versionBuild = "{0}.{1}" -f $(get-date -format 'yyyyMMdd'), "$env:Rev:.r" +$versionBuild = "{0}" -f $(get-date -format 'yyyyMMdd') task . AnalyzeSourceFiles, CreateModule @@ -112,9 +112,6 @@ task CreatePsd1ForRelease CleanTemp, { VariablesToExport = @() AliasesToExport = @() } - $myEnv = Get-Item Env: - Write-Output $myEnv - Write-Output $ManifestParams.ModuleVersion New-ModuleManifest @ManifestParams } From a6446c084979020b523e7381af0acb7d3442761f Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 11:45:55 -0400 Subject: [PATCH 038/147] Update temp for case-sensitive environments --- ZertoApiWrapper.build.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 911780f..b21dd4f 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -53,7 +53,7 @@ task AnalyzeSourceFiles CheckPSScriptAnalyzerInstalled, { task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, { $scriptAnalyzerParams = @{ - Path = "$BuildRoot\Temp\" + Path = "$BuildRoot\temp\" Severity = @('Error', 'Warning') Recurse = $true Verbose = $false @@ -76,7 +76,7 @@ task FileTests CheckPesterInstalled, { $buildMamlParams = @{ Inputs = { Get-ChildItem docs\*.md } - Outputs = "temp\en-us\ZertoApiWrapper-help.xml" + Outputs = "$BuildRoot\temp\en-us\ZertoApiWrapper-help.xml" } task BuildMamlHelp CheckPlatyPSInstalled, { @@ -95,7 +95,7 @@ task UpdateMarkdownHelp CheckPlatyPSInstalled, { task CreatePsd1ForRelease CleanTemp, { $functionsToExport = Get-ChildItem -Path 'ZertoApiWrapper\Public\*.ps1' | ForEach-Object { $_.BaseName } $ManifestParams = @{ - Path = "temp\ZertoApiWrapper.psd1" + Path = "$BuildRoot\temp\ZertoApiWrapper.psd1" RootModule = 'ZertoApiWrapper.psm1' ModuleVersion = '{0}.{1}.{2}' -f $versionMajor, $versionMinor, $versionBuild GUID = '4c0b9e17-141b-4dd5-8549-fb21cccaa325' @@ -119,12 +119,12 @@ task CleanTemp { if (-not $(Test-Path "$BuildRoot\temp")) { New-Item -Path $BuildRoot -Name "temp" -ItemType "Directory" } - Remove-Item -Recurse -Path 'temp\*' + Remove-Item -Recurse -Path "$BuildRoot\temp\*" } task CreatePsm1ForRelease CreatePsd1ForRelease, { $emptyLine = "" - $psm1Path = "temp\ZertoApiWrapper.psm1" + $psm1Path = "$BuildRoot\temp\ZertoApiWrapper.psm1" $lines = '#------------------------------------------------------------#' $Public = @( Get-ChildItem -Path $PSScriptRoot\ZertoApiWrapper\Public\*.ps1 -ErrorAction SilentlyContinue ) $Private = @( Get-ChildItem -Path $PSScriptRoot\ZertoApiWrapper\Private\*.ps1 -ErrorAction SilentlyContinue ) From 64c089f3ec59af7ed5cd16cdb065b30ae3a340c3 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 11:46:21 -0400 Subject: [PATCH 039/147] Update README.md Azure Pipeline Badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 15ad3b6..e2f76cc 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ PowerShell Core wrapper for Zerto Virtual Manager API ## Current Build Status -[![Build Status](https://dev.azure.com/wescarroll/wescarroll/_apis/build/status/wcarroll.ZertoApiWrapper?branchName=master)](https://dev.azure.com/wescarroll/wescarroll/_build/latest?definitionId=1&branchName=master) +[![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 From 8e4a5f7e9981dc9bae7d264030c9924a4288583b Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 17:48:04 -0400 Subject: [PATCH 040/147] Move Module Tests to Mirror Module Directory --- Tests/Public/ZertoApiWrapper.Tests.ps1 | 49 ----------- Tests/ZertoApiWrapper.Tests.ps1 | 111 +++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 49 deletions(-) delete mode 100644 Tests/Public/ZertoApiWrapper.Tests.ps1 create mode 100644 Tests/ZertoApiWrapper.Tests.ps1 diff --git a/Tests/Public/ZertoApiWrapper.Tests.ps1 b/Tests/Public/ZertoApiWrapper.Tests.ps1 deleted file mode 100644 index 4657824..0000000 --- a/Tests/Public/ZertoApiWrapper.Tests.ps1 +++ /dev/null @@ -1,49 +0,0 @@ -$moduleName = "ZertoApiWrapper" -$moduleFileName = "ZertoApiWrapper.psm1" -$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper' -$docsPath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests[\\\/]Public', 'docs' -$modulePath = $filePath -replace "Public", "" - -Import-Module $modulePath\$moduleFileName - -Import-Module $modulePath\$moduleFileName - -Describe "File Tests" { - Remove-Module $moduleName -Force - Import-Module $modulePath\$moduleFileName - $commands = Get-Command -Module $moduleName | Select-Object -ExpandProperty Name - foreach ($command in $commands) { - $externalHelpFile = "{0}/{1}.md" -f $docsPath, $command - $path = "{0}/{1}.ps1" -f $filePath, $command - context "$command File Tests" { - it "$command is backed by a file with the same name" { - $path | should exist - } - it "$command file has openbraces on the same line as the statement" { - $content = Get-Content -Path $path - $openingBracesExist = $content | Where-Object {$_.Trim() -eq '{'} - if ($openingBracesExist) { - Write-Warning "Found the following opening brances on their own line:" - foreach ($openingBrace in $openingBracesExist) { - Write-Warning "Opening Brace on it's own line - $openingBrace" - } - } - $openingBracesExist | should benullorempty - } - it "$command has an external help file" { - $externalHelpFile | should exist - } - it "$command has the External Help File Defined" { - Get-Content -Path $path -First 1 | should be "<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>" - } - it "$command external Help file is filled out" { - $stubExist = Get-Content -Path $externalHelpFile | Where-Object {$_.Trim() -like '*{{*}}*'} - if ($stubExist) { - Write-Warning "Found a stub in the Markdown File $externalHelpFile" - Write-Warning "$stubExist" - } - $stubExist | should benullorempty - } - } - } -} diff --git a/Tests/ZertoApiWrapper.Tests.ps1 b/Tests/ZertoApiWrapper.Tests.ps1 new file mode 100644 index 0000000..c102e2d --- /dev/null +++ b/Tests/ZertoApiWrapper.Tests.ps1 @@ -0,0 +1,111 @@ +$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 rood 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 + } + } + } +} From a8986c2a4bcb9769ea48088e18253e2b0ca2e676 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 17:48:54 -0400 Subject: [PATCH 041/147] Create Stub Test files for all functions --- Tests/Private/Invoke-ZertoRestRequest.Tests.ps1 | 0 Tests/Public/Export-ZertoVpg.Tests.ps1 | 0 Tests/Public/Get-ZertoUnprotectedVm.Tests.ps1 | 0 Tests/Public/Import-ZertoVpg.Tests.ps1 | 0 Tests/Public/New-ZertoVpg.Tests.ps1 | 0 Tests/Public/New-ZertoVpgSettingsIdentifier.Tests.ps1 | 0 Tests/Public/Remove-ZertoPeerSite.Tests.ps1 | 0 Tests/Public/Save-ZertoVpgSetting.Tests.ps1 | 0 Tests/Public/Save-ZertoVpgSettings.Tests.ps1 | 0 9 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 Tests/Private/Invoke-ZertoRestRequest.Tests.ps1 create mode 100644 Tests/Public/Export-ZertoVpg.Tests.ps1 create mode 100644 Tests/Public/Get-ZertoUnprotectedVm.Tests.ps1 create mode 100644 Tests/Public/Import-ZertoVpg.Tests.ps1 create mode 100644 Tests/Public/New-ZertoVpg.Tests.ps1 create mode 100644 Tests/Public/New-ZertoVpgSettingsIdentifier.Tests.ps1 create mode 100644 Tests/Public/Remove-ZertoPeerSite.Tests.ps1 create mode 100644 Tests/Public/Save-ZertoVpgSetting.Tests.ps1 create mode 100644 Tests/Public/Save-ZertoVpgSettings.Tests.ps1 diff --git a/Tests/Private/Invoke-ZertoRestRequest.Tests.ps1 b/Tests/Private/Invoke-ZertoRestRequest.Tests.ps1 new file mode 100644 index 0000000..e69de29 diff --git a/Tests/Public/Export-ZertoVpg.Tests.ps1 b/Tests/Public/Export-ZertoVpg.Tests.ps1 new file mode 100644 index 0000000..e69de29 diff --git a/Tests/Public/Get-ZertoUnprotectedVm.Tests.ps1 b/Tests/Public/Get-ZertoUnprotectedVm.Tests.ps1 new file mode 100644 index 0000000..e69de29 diff --git a/Tests/Public/Import-ZertoVpg.Tests.ps1 b/Tests/Public/Import-ZertoVpg.Tests.ps1 new file mode 100644 index 0000000..e69de29 diff --git a/Tests/Public/New-ZertoVpg.Tests.ps1 b/Tests/Public/New-ZertoVpg.Tests.ps1 new file mode 100644 index 0000000..e69de29 diff --git a/Tests/Public/New-ZertoVpgSettingsIdentifier.Tests.ps1 b/Tests/Public/New-ZertoVpgSettingsIdentifier.Tests.ps1 new file mode 100644 index 0000000..e69de29 diff --git a/Tests/Public/Remove-ZertoPeerSite.Tests.ps1 b/Tests/Public/Remove-ZertoPeerSite.Tests.ps1 new file mode 100644 index 0000000..e69de29 diff --git a/Tests/Public/Save-ZertoVpgSetting.Tests.ps1 b/Tests/Public/Save-ZertoVpgSetting.Tests.ps1 new file mode 100644 index 0000000..e69de29 diff --git a/Tests/Public/Save-ZertoVpgSettings.Tests.ps1 b/Tests/Public/Save-ZertoVpgSettings.Tests.ps1 new file mode 100644 index 0000000..e69de29 From 99cbe967054d2778a5ca7a98a3b9f062a8084904 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 17:49:09 -0400 Subject: [PATCH 042/147] Update Add-ZertoPeerSite.Tests.ps1 --- Tests/Public/Add-ZertoPeerSite.Tests.ps1 | 62 ++++++++++++++++-------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/Tests/Public/Add-ZertoPeerSite.Tests.ps1 b/Tests/Public/Add-ZertoPeerSite.Tests.ps1 index 2d8dbc5..28a1e43 100644 --- a/Tests/Public/Add-ZertoPeerSite.Tests.ps1 +++ b/Tests/Public/Add-ZertoPeerSite.Tests.ps1 @@ -1,23 +1,45 @@ -$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 +$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") +$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") +$file = Get-ChildItem "$here\$sut" +#$moduleFileName = "ZertoApiWrapper.psd1" +#$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper' +#$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.' +#$commandName = $fileName -replace '.ps1', '' +#Get-Module -Name ZertoApiWrapper | Remove-Module -Force +#Import-Module D:\GitHub\ZertoApiWrapper\ZertoApiWrapper\ZertoApiWrapper.psd1 -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' { + Context "Basic Features" { + Mock -ModuleName ZertoApiWrapper Invoke-ZertoRestRequest { + return "9a49f42e-2bbd-4bf8-b571-77908a2e5e98.928a122b-1763-4664-ad37-cc00bb883f2f" + } + 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 + } -# $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 "Should be return a string value" { + $results = Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort '9081' + $results | should not benullorempty + $results.gettype().name | should -be "String" + } + it "Should not take a non-int as a port" { + {Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 'string'} | should -Throw + } + it "Should 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 + } + it "Should not require a target port to be defined" { + Add-ZertoPeerSite -targetHost '192.168.1.100' + } + it "Should support '-whatif'" { + {Add-ZertoPeerSite -targetHost '192.168.1.100' -WhatIf | out-null} | Should -Not -Throw + } } - it "module should have a function called $commandName" { - get-command $commandName | should be $true - } -} \ No newline at end of file +} + From 11a3395bdbdc9c651d1b4a8ae55fd2e04dc07e7d Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 17:50:16 -0400 Subject: [PATCH 043/147] Add Validation for targetHost --- ZertoApiWrapper/Public/Add-ZertoPeerSite.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ZertoApiWrapper/Public/Add-ZertoPeerSite.ps1 b/ZertoApiWrapper/Public/Add-ZertoPeerSite.ps1 index 272fb2a..8cd00d0 100644 --- a/ZertoApiWrapper/Public/Add-ZertoPeerSite.ps1 +++ b/ZertoApiWrapper/Public/Add-ZertoPeerSite.ps1 @@ -6,6 +6,7 @@ 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" @@ -27,4 +28,4 @@ function Add-ZertoPeerSite { end { # Nothing to do } -} \ No newline at end of file +} From c72c354f38d0bc240e85376e0db795003e890802 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 17:50:42 -0400 Subject: [PATCH 044/147] Add advanced function params --- ZertoApiWrapper/Public/Disconnect-ZertoServer.ps1 | 1 + ZertoApiWrapper/Public/Get-ZertoLicense.ps1 | 1 + ZertoApiWrapper/Public/Get-ZertoUnprotectedVm.ps1 | 1 + ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 | 1 + 4 files changed, 4 insertions(+) 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/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-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/Stop-ZertoCloneVpg.ps1 b/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 index 8e797d7..892c167 100644 --- a/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 +++ b/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 @@ -1,5 +1,6 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Stop-ZertoCloneVpg { + [cmdletbinding()] param( [Parameter( HelpMessage = "Name of the VPG to stop cloning", From 4c67c2f070f6b6274e4d987d50d3edfb4e7ade5e Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 17:50:50 -0400 Subject: [PATCH 045/147] Update ZertoApiWrapper.psd1 --- ZertoApiWrapper/ZertoApiWrapper.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZertoApiWrapper/ZertoApiWrapper.psd1 b/ZertoApiWrapper/ZertoApiWrapper.psd1 index 9c4c9a4..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' From f4c4c3982dd34346f3f1617e3029aca0b2e94963 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 17:51:16 -0400 Subject: [PATCH 046/147] Update Build Tasks --- ZertoApiWrapper.build.ps1 | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index b21dd4f..0296e0f 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -51,7 +51,7 @@ task AnalyzeSourceFiles CheckPSScriptAnalyzerInstalled, { } } -task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, { +task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, CreatePsm1ForRelease, { $scriptAnalyzerParams = @{ Path = "$BuildRoot\temp\" Severity = @('Error', 'Warning') @@ -126,8 +126,20 @@ task CreatePsm1ForRelease CreatePsd1ForRelease, { $emptyLine = "" $psm1Path = "$BuildRoot\temp\ZertoApiWrapper.psm1" $lines = '#------------------------------------------------------------#' - $Public = @( Get-ChildItem -Path $PSScriptRoot\ZertoApiWrapper\Public\*.ps1 -ErrorAction SilentlyContinue ) - $Private = @( Get-ChildItem -Path $PSScriptRoot\ZertoApiWrapper\Private\*.ps1 -ErrorAction SilentlyContinue ) + $Public = @( Get-ChildItem -Path $BuildRoot\ZertoApiWrapper\Public\*.ps1 -ErrorAction SilentlyContinue ) + $functionCount = 0 + $exportString = "" + foreach ($file in $Public) { + if ($functionCount -eq 0) { + $functionCount++ + $exportString = "{0}" -f $file.BaseName + } else { + $functionCount++ + $exportString = "{0}, {1}" -f $exportString, $file.BaseName + } + } + $export = "Export-ModuleMember -Function $exportString" + $Private = @( Get-ChildItem -Path $BuildRoot\ZertoApiWrapper\Private\*.ps1 -ErrorAction SilentlyContinue ) Add-Content -Path $psm1Path -Value $lines Add-Content -Path $psm1Path -Value "#---------------------Private Functions----------------------#" Add-Content -Path $psm1Path -Value $lines @@ -144,9 +156,10 @@ task CreatePsm1ForRelease CreatePsd1ForRelease, { Add-Content -Path $psm1Path -Value $(Get-Content -Path $file.Fullname -Raw) Add-Content -Path $psm1Path -Value $emptyLine } + Add-Content -Path $psm1Path -Value $emptyLine + Add-Content -Path $psm1Path -Value "Export-ModuleMember -Function $exportString" } -task CreateModule CleanTemp, FileTests, CreatePsd1ForRelease, CreatePsm1ForRelease, AnalyzeBuiltFiles, BuildMamlHelp, { +task CreateModule CleanTemp, FileTests, AnalyzeBuiltFiles, BuildMamlHelp, { } - From 2328e7f868df739306733326d9f866e9e7e55bad Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 19:27:09 -0400 Subject: [PATCH 047/147] Delete External-Help.Tests.ps1 --- Tests/Public/External-Help.Tests.ps1 | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 Tests/Public/External-Help.Tests.ps1 diff --git a/Tests/Public/External-Help.Tests.ps1 b/Tests/Public/External-Help.Tests.ps1 deleted file mode 100644 index 363c91b..0000000 --- a/Tests/Public/External-Help.Tests.ps1 +++ /dev/null @@ -1,10 +0,0 @@ -$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper' -$publicFiles = Get-ChildItem "$filePath" -File - -describe "External Help Present" { - foreach ($file in $publicFiles) { - it "External Help File Defined" { - Get-Content -Path $file.fullName -First 1 | should be "<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>" - } - } -} From c37dd193344f8705333a3228326f92aa5b6dd6bc Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 19:27:24 -0400 Subject: [PATCH 048/147] Delete Get-ZertoUnprotectedVm.Test.ps1 --- Tests/Public/Get-ZertoUnprotectedVm.Test.ps1 | 23 -------------------- 1 file changed, 23 deletions(-) delete mode 100644 Tests/Public/Get-ZertoUnprotectedVm.Test.ps1 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 From daecae1f5958bb4bf42548cd3c5c24a7e0b93f6c Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 19:27:27 -0400 Subject: [PATCH 049/147] Delete Save-ZertoVpgSettings.Tests.ps1 --- Tests/Public/Save-ZertoVpgSettings.Tests.ps1 | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Tests/Public/Save-ZertoVpgSettings.Tests.ps1 diff --git a/Tests/Public/Save-ZertoVpgSettings.Tests.ps1 b/Tests/Public/Save-ZertoVpgSettings.Tests.ps1 deleted file mode 100644 index e69de29..0000000 From 911e81c8cc6cea063237e5fdd764996a8df17dc9 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 19:27:59 -0400 Subject: [PATCH 050/147] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e4bc748..ab7904e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.zip temp/* Tests/Public/TestResults.xml +Tests/TestResults.xml From 2c215dd1807ce7b69aea615e5991a0bb841b29bc Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 19:28:57 -0400 Subject: [PATCH 051/147] Update Pester Test Location --- azure-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3baef72..c76ac4b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -18,7 +18,7 @@ jobs: - task: PublishTestResults@2 inputs: testRunner: 'NUnit' - testResultsFiles: '**/Public/TestResults.xml' + testResultsFiles: '**/TestResults.xml' testRunTitle: 'PS_Win2016' displayName: 'Publish Test Results' condition: always() @@ -35,7 +35,7 @@ jobs: - task: PublishTestResults@2 inputs: testRunner: 'NUnit' - testResultsFiles: '**/Public/TestResults.xml' + testResultsFiles: '**/TestResults.xml' testRunTitle: 'PSCore_Ubuntu1604' displayName: 'Publish Test Results' condition: always() @@ -52,7 +52,7 @@ jobs: - task: PublishTestResults@2 inputs: testRunner: 'NUnit' - testResultsFiles: '**/Public/TestResults.xml' + testResultsFiles: '**/TestResults.xml' testRunTitle: 'PSCore_MacOS1013' displayName: 'Publish Test Results' condition: always() From 7a90bad1e047417d200416a5af57861885b97f63 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 19:29:19 -0400 Subject: [PATCH 052/147] Run all Unit Tests when building FileTests --- ZertoApiWrapper.build.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 0296e0f..d0cdecd 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -68,8 +68,8 @@ task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, CreatePsm1ForRelease, { } task FileTests CheckPesterInstalled, { - $testResultsFile = "$BuildRoot\Tests\Public\TestResults.xml" - $script:results = Invoke-Pester -Script "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -OutputFile $testResultsFile -PassThru + $testResultsFile = "$BuildRoot\Tests\TestResults.xml" + $script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru $FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount assert ($results.FailedCount -eq 0) $FailureMessage } From 7db1a32399f1d31cd621836a0e190c992cdb18de Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 19:30:14 -0400 Subject: [PATCH 053/147] All basic unit tests --- Tests/Private/Get-ZertoApiFilter.Tests.ps1 | 33 +++++++++++------- .../Private/Invoke-ZertoRestRequest.Tests.ps1 | 17 ++++++++++ Tests/Public/Add-ZertoPeerSite.Tests.ps1 | 19 +++++++---- Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 | 34 ++++++++----------- Tests/Public/Disconnect-ZertoServer.Tests.ps1 | 34 ++++++++----------- Tests/Public/Edit-ZertoVra.Tests.ps1 | 34 ++++++++----------- Tests/Public/Export-ZertoVpg.Tests.ps1 | 19 +++++++++++ Tests/Public/Get-ZertoAlert.Tests.ps1 | 34 ++++++++----------- Tests/Public/Get-ZertoDatastore.Tests.ps1 | 34 ++++++++----------- Tests/Public/Get-ZertoEvent.Tests.ps1 | 34 ++++++++----------- Tests/Public/Get-ZertoLicense.Tests.ps1 | 34 ++++++++----------- Tests/Public/Get-ZertoLocalSite.Tests.ps1 | 34 ++++++++----------- Tests/Public/Get-ZertoPeerSite.Tests.ps1 | 34 ++++++++----------- Tests/Public/Get-ZertoProtectedVm.Tests.ps1 | 34 ++++++++----------- .../Public/Get-ZertoRecoveryReport.Tests.ps1 | 34 ++++++++----------- .../Public/Get-ZertoResourcesReport.Tests.ps1 | 34 ++++++++----------- .../Public/Get-ZertoServiceProfile.Tests.ps1 | 34 ++++++++----------- Tests/Public/Get-ZertoTask.Tests.ps1 | 34 ++++++++----------- Tests/Public/Get-ZertoUnprotectedVm.Tests.ps1 | 19 +++++++++++ .../Get-ZertoVirtualizationSite.Tests.ps1 | 34 ++++++++----------- Tests/Public/Get-ZertoVolume.Tests.ps1 | 34 ++++++++----------- Tests/Public/Get-ZertoVpg.Tests.ps1 | 34 ++++++++----------- Tests/Public/Get-ZertoVpgSetting.Tests.ps1 | 34 ++++++++----------- Tests/Public/Get-ZertoVra.Tests.ps1 | 34 ++++++++----------- Tests/Public/Get-ZertoZorg.Tests.ps1 | 34 ++++++++----------- Tests/Public/Get-ZertoZsspSession.Tests.ps1 | 34 ++++++++----------- Tests/Public/Import-ZertoVpg.Tests.ps1 | 19 +++++++++++ Tests/Public/Install-ZertoVra.Tests.ps1 | 34 ++++++++----------- Tests/Public/Invoke-ZertoFailover.Tests.ps1 | 34 ++++++++----------- .../Invoke-ZertoFailoverCommit.Tests.ps1 | 34 ++++++++----------- .../Invoke-ZertoFailoverRollback.Tests.ps1 | 34 ++++++++----------- Tests/Public/Invoke-ZertoForceSync.Tests.ps1 | 34 ++++++++----------- Tests/Public/Invoke-ZertoMove.Tests.ps1 | 34 ++++++++----------- Tests/Public/Invoke-ZertoMoveCommit.Tests.ps1 | 34 ++++++++----------- .../Public/Invoke-ZertoMoveRollback.Tests.ps1 | 34 ++++++++----------- Tests/Public/New-ZertoVpg.Tests.ps1 | 19 +++++++++++ .../New-ZertoVpgSettingsIdentifier.Tests.ps1 | 19 +++++++++++ Tests/Public/Remove-ZertoPeerSite.Tests.ps1 | 19 +++++++++++ Tests/Public/Remove-ZertoVpg.Tests.ps1 | 34 ++++++++----------- Tests/Public/Resume-ZertoVpg.Tests.ps1 | 34 ++++++++----------- Tests/Public/Save-ZertoVpgSetting.Tests.ps1 | 19 +++++++++++ Tests/Public/Set-ZertoAlert.Tests.ps1 | 34 ++++++++----------- Tests/Public/Set-ZertoLicense.Tests.ps1 | 34 ++++++++----------- Tests/Public/Start-ZertoCloneVpg.Tests.ps1 | 34 ++++++++----------- .../Public/Start-ZertoFailoverTest.Tests.ps1 | 34 ++++++++----------- Tests/Public/Stop-ZertoCloneVpg.Tests.ps1 | 34 ++++++++----------- Tests/Public/Stop-ZertoFailoverTest.Tests.ps1 | 34 ++++++++----------- Tests/Public/Suspend-ZertoVpg.Tests.ps1 | 34 ++++++++----------- Tests/Public/Uninstall-ZertoVra.Tests.ps1 | 34 ++++++++----------- 49 files changed, 767 insertions(+), 761 deletions(-) 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 index e69de29..984d682 100644 --- a/Tests/Private/Invoke-ZertoRestRequest.Tests.ps1 +++ 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 28a1e43..1a900da 100644 --- a/Tests/Public/Add-ZertoPeerSite.Tests.ps1 +++ b/Tests/Public/Add-ZertoPeerSite.Tests.ps1 @@ -1,19 +1,20 @@ #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" -#$moduleFileName = "ZertoApiWrapper.psd1" -#$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper' -#$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.' -#$commandName = $fileName -replace '.ps1', '' -#Get-Module -Name ZertoApiWrapper | Remove-Module -Force -#Import-Module D:\GitHub\ZertoApiWrapper\ZertoApiWrapper\ZertoApiWrapper.psd1 -force +$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' { Context "Basic Features" { + Mock -ModuleName ZertoApiWrapper Invoke-ZertoRestRequest { return "9a49f42e-2bbd-4bf8-b571-77908a2e5e98.928a122b-1763-4664-ad37-cc00bb883f2f" } + It "is valid Powershell (Has no script errors)" { $contents = Get-Content -Path $file -ErrorAction Stop $errors = $null @@ -26,19 +27,23 @@ Describe $file.BaseName -Tag 'Unit' { $results | should not benullorempty $results.gettype().name | should -be "String" } + it "Should not take a non-int as a port" { {Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 'string'} | should -Throw } + it "Should 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 } + it "Should not require a target port to be defined" { Add-ZertoPeerSite -targetHost '192.168.1.100' } + it "Should support '-whatif'" { - {Add-ZertoPeerSite -targetHost '192.168.1.100' -WhatIf | out-null} | Should -Not -Throw + {Add-ZertoPeerSite -targetHost '192.168.1.100' -WhatIf| out-null} | Should -Not -Throw } } } diff --git a/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 b/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Checkpoint-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/Disconnect-ZertoServer.Tests.ps1 b/Tests/Public/Disconnect-ZertoServer.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Disconnect-ZertoServer.Tests.ps1 +++ b/Tests/Public/Disconnect-ZertoServer.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/Edit-ZertoVra.Tests.ps1 b/Tests/Public/Edit-ZertoVra.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Edit-ZertoVra.Tests.ps1 +++ b/Tests/Public/Edit-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/Export-ZertoVpg.Tests.ps1 b/Tests/Public/Export-ZertoVpg.Tests.ps1 index e69de29..50d2f9d 100644 --- a/Tests/Public/Export-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Export-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/Get-ZertoAlert.Tests.ps1 b/Tests/Public/Get-ZertoAlert.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Get-ZertoAlert.Tests.ps1 +++ b/Tests/Public/Get-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/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.Tests.ps1 b/Tests/Public/Get-ZertoUnprotectedVm.Tests.ps1 index e69de29..50d2f9d 100644 --- a/Tests/Public/Get-ZertoUnprotectedVm.Tests.ps1 +++ 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 index e69de29..50d2f9d 100644 --- a/Tests/Public/Import-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Import-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/Install-ZertoVra.Tests.ps1 b/Tests/Public/Install-ZertoVra.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Install-ZertoVra.Tests.ps1 +++ b/Tests/Public/Install-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/Invoke-ZertoFailover.Tests.ps1 b/Tests/Public/Invoke-ZertoFailover.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Invoke-ZertoFailover.Tests.ps1 +++ b/Tests/Public/Invoke-ZertoFailover.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-ZertoFailoverCommit.Tests.ps1 b/Tests/Public/Invoke-ZertoFailoverCommit.Tests.ps1 index 2d8dbc5..50d2f9d 100644 --- a/Tests/Public/Invoke-ZertoFailoverCommit.Tests.ps1 +++ b/Tests/Public/Invoke-ZertoFailoverCommit.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-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 index e69de29..50d2f9d 100644 --- a/Tests/Public/New-ZertoVpg.Tests.ps1 +++ 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 index e69de29..50d2f9d 100644 --- a/Tests/Public/New-ZertoVpgSettingsIdentifier.Tests.ps1 +++ 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 index e69de29..50d2f9d 100644 --- a/Tests/Public/Remove-ZertoPeerSite.Tests.ps1 +++ 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 index e69de29..50d2f9d 100644 --- a/Tests/Public/Save-ZertoVpgSetting.Tests.ps1 +++ 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 From b2ab6362f7dd787de940a5937939d182b1a6ad52 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 19:30:27 -0400 Subject: [PATCH 054/147] Require Pester Module --- Tests/ZertoApiWrapper.Tests.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/ZertoApiWrapper.Tests.ps1 b/Tests/ZertoApiWrapper.Tests.ps1 index c102e2d..a71c28e 100644 --- a/Tests/ZertoApiWrapper.Tests.ps1 +++ b/Tests/ZertoApiWrapper.Tests.ps1 @@ -1,3 +1,4 @@ +#Requires -Modules Pester $testPath = Split-Path -Parent $MyInvocation.MyCommand.Path $docsPath = $testPath -replace 'Tests', 'docs' $modulePath = $testPath -replace 'Tests', 'ZertoApiWrapper' From 7f3a9fc5df7087089638e1b3d6ef9565a147ed93 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 21:54:01 -0400 Subject: [PATCH 055/147] Fix case issues with linux tests --- Tests/ZertoApiWrapper.Tests.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/ZertoApiWrapper.Tests.ps1 b/Tests/ZertoApiWrapper.Tests.ps1 index a71c28e..b2300af 100644 --- a/Tests/ZertoApiWrapper.Tests.ps1 +++ b/Tests/ZertoApiWrapper.Tests.ps1 @@ -32,22 +32,22 @@ Describe "Module: $module" -Tags 'Unit' { It "Has a public functions folder" { - "$modulePath\public" | Should -Exist + "$modulePath\Public" | Should -Exist } It "Has functions in the public functions folder" { - "$modulePath\public\*.ps1" | Should -Exist + "$modulePath\Public\*.ps1" | Should -Exist } It "Has a private functions folder" { - "$modulePath\private" | Should -Exist + "$modulePath\Private" | Should -Exist } It "Has functions in the private functions folder" { - "$modulePath\private\*.ps1" | Should -Exist + "$modulePath\Private\*.ps1" | Should -Exist } } From 49798b190d35c74bfeff48918f55258848fc9ed4 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 21:54:19 -0400 Subject: [PATCH 056/147] Update Add-ZertoPeerSite.Tests.ps1 --- Tests/Public/Add-ZertoPeerSite.Tests.ps1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Tests/Public/Add-ZertoPeerSite.Tests.ps1 b/Tests/Public/Add-ZertoPeerSite.Tests.ps1 index 1a900da..f567411 100644 --- a/Tests/Public/Add-ZertoPeerSite.Tests.ps1 +++ b/Tests/Public/Add-ZertoPeerSite.Tests.ps1 @@ -22,14 +22,16 @@ Describe $file.BaseName -Tag 'Unit' { $errors | Should -HaveCount 0 } - it "Should be return a string value" { + it "Should return a string value" { $results = Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort '9081' $results | should not benullorempty - $results.gettype().name | should -be "String" + $results | should -BeOfType "String" + $results | Should -BeExactly "9a49f42e-2bbd-4bf8-b571-77908a2e5e98.928a122b-1763-4664-ad37-cc00bb883f2f" } it "Should 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 } it "Should not take a non-ip address as a 'TargetHost'" { @@ -43,8 +45,10 @@ Describe $file.BaseName -Tag 'Unit' { } it "Should support '-whatif'" { - {Add-ZertoPeerSite -targetHost '192.168.1.100' -WhatIf| out-null} | Should -Not -Throw + {Add-ZertoPeerSite -targetHost '192.168.1.100' -WhatIf} | Should -Not -Throw } + + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest } } From 0114c73706499f91d14568c0f77017cf44cfe4ed Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 21:54:24 -0400 Subject: [PATCH 057/147] Update Checkpoint-ZertoVpg.Tests.ps1 --- Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 b/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 index 50d2f9d..206bfaa 100644 --- a/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 @@ -9,11 +9,34 @@ Get-Module -Name ZertoApiWrapper | Remove-Module -Force Import-Module $moduleFile -Force Describe $file.BaseName -Tag 'Unit' { - + 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"} + } 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 "should return a 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" + } + + it "should require a tag name" { + {Checkpoint-ZertoVpg -vpgName "MyVpg" -checkpointName ""} | Should -Throw + } + + it "should NOT support '-WhatIf'" { + {Checkpoint-ZertoVpg -vpgName "MyVpg" -checkpointName "Checkers" -whatif} | Should -Throw + } + + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpg } \ No newline at end of file From a8a0b5a6e875390b693ba4c9f16649e83ce36c4a Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 21:54:46 -0400 Subject: [PATCH 058/147] Add Port Range Validation --- ZertoApiWrapper/Public/Add-ZertoPeerSite.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/ZertoApiWrapper/Public/Add-ZertoPeerSite.ps1 b/ZertoApiWrapper/Public/Add-ZertoPeerSite.ps1 index 8cd00d0..ecf104e 100644 --- a/ZertoApiWrapper/Public/Add-ZertoPeerSite.ps1 +++ b/ZertoApiWrapper/Public/Add-ZertoPeerSite.ps1 @@ -11,6 +11,7 @@ function Add-ZertoPeerSite { [Parameter( HelpMessage = "Target communication port. Default is 9081" )] + [ValidateRange(1024, 65535)] [int]$targetPort = 9081 ) From 4fba918ae53b302d0f3b18391b844a50db4dbdbb Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 21:55:01 -0400 Subject: [PATCH 059/147] Add checkpointName validation --- ZertoApiWrapper/Public/Checkpoint-ZertoVpg.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/ZertoApiWrapper/Public/Checkpoint-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Checkpoint-ZertoVpg.ps1 index 83515b9..2b1a371 100644 --- a/ZertoApiWrapper/Public/Checkpoint-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Checkpoint-ZertoVpg.ps1 @@ -11,6 +11,7 @@ function Checkpoint-ZertoVpg { Mandatory = $true, HelpMessage = "Text to tag the checkpoint with." )] + [ValidateNotNullOrEmpty()] [string]$checkpointName ) From e9465f819417a41778b30f071714af237ab31e87 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 22:15:44 -0400 Subject: [PATCH 060/147] Update Connect-ZertoServer.Tests.ps1 --- Tests/Public/Connect-ZertoServer.Tests.ps1 | 76 +++++++++++++++++++--- 1 file changed, 67 insertions(+), 9 deletions(-) diff --git a/Tests/Public/Connect-ZertoServer.Tests.ps1 b/Tests/Public/Connect-ZertoServer.Tests.ps1 index 30d5784..5c20b35 100644 --- a/Tests/Public/Connect-ZertoServer.Tests.ps1 +++ b/Tests/Public/Connect-ZertoServer.Tests.ps1 @@ -1,18 +1,75 @@ -$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 = "192.168.1.100" $zertoPort = "7669" -Describe "Connect-ZertoServer" { +Describe $file.BaseName -Tag Unit { + Context "Basic Features" { + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest { + $xZertoSession = @("7ecf544d-e7ed-4108-86f3-fb355c51cdfa") + $Headers = @{'x-zerto-session' = $xZertoSession} + $results = @{'Headers' = $Headers} + return $results + } + + 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 "returns null when -ReturnHeaders is not used" { + Connect-ZertoServer -zertoServer $zertoServer -zertoPort $zertoPort -credential $credential | Should -BeNullOrEmpty + } + + $headers = Connect-ZertoServer -zertoServer $zertoServer -zertoPort $zertoPort -credential $credential -returnHeaders + it "returns a Hashtable with 2 keys" { + $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 $zertoServer -credential $credential + } + + 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 + } + + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest + } +} +<# +Describe "Connect-ZertoServer" -Tag Integration { it "file should exist" { "$filePath\$fileName" | should exist } @@ -37,3 +94,4 @@ Describe "Connect-ZertoServer" { } Disconnect-ZertoServer } + #> \ No newline at end of file From 7bd878615d399d534088d5c973d05fa780b81b15 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 29 Mar 2019 22:59:03 -0400 Subject: [PATCH 061/147] Update Disconnect-ZertoServer.Tests.ps1 --- Tests/Public/Disconnect-ZertoServer.Tests.ps1 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Tests/Public/Disconnect-ZertoServer.Tests.ps1 b/Tests/Public/Disconnect-ZertoServer.Tests.ps1 index 50d2f9d..a2238f8 100644 --- a/Tests/Public/Disconnect-ZertoServer.Tests.ps1 +++ b/Tests/Public/Disconnect-ZertoServer.Tests.ps1 @@ -9,11 +9,24 @@ Get-Module -Name ZertoApiWrapper | Remove-Module -Force Import-Module $moduleFile -Force Describe $file.BaseName -Tag 'Unit' { + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest { + $null + } + Mock -ModuleName ZertoApiWrapper -CommandName Remove-Variable { + } It "is valid Powershell (Has no script errors)" { $contents = Get-Content -Path $file -ErrorAction Stop $errors = $null $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) $errors | Should -HaveCount 0 } + + it "Does not return anything" { + Disconnect-ZertoServer | Should -BeNullOrEmpty + } + + it "Does not take any parameters" { + (get-command disconnect-zertoserver).parameters.count | Should -BeExactly 11 + } } \ No newline at end of file From 031e31addda22eedd86007e691a598e832d9fae2 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sat, 30 Mar 2019 09:42:45 -0400 Subject: [PATCH 062/147] Update az pipeline triggers Update triggers and call powershell core directly instead of calling the shell ==> pwsh. --- azure-pipelines.yml | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c76ac4b..5d60123 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -4,6 +4,15 @@ # https://aka.ms/yaml name: $(TeamProject)_$(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.rr) +trigger: + branches: + include: + - master + - develop + - TestingBranch +pr: + - master + - develop jobs: - job: Build_PS_Win2016 @@ -12,8 +21,8 @@ jobs: pool: vmImage: vs2017-win2016 steps: - - script: | - pwsh -c ".\build.ps1 -Verbose" + - pwsh: | + .\build.ps1 -Verbose displayName: 'Build and Test' - task: PublishTestResults@2 inputs: @@ -29,8 +38,8 @@ jobs: pool: vmImage: ubuntu-16.04 steps: - - script: | - pwsh -c '.\build.ps1 -verbose' + - pwsh: | + .\build.ps1 -verbose displayName: 'Build and Test' - task: PublishTestResults@2 inputs: @@ -46,8 +55,8 @@ jobs: pool: vmImage: xcode9-macos10.13 steps: - - script: | - pwsh -c '.\build.ps1 -verbose' + - pwsh: | + .\build.ps1 -verbose displayName: 'Build and Test' - task: PublishTestResults@2 inputs: From ffba4a59816f4e347e64e91119c4f0cf0c65031b Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sat, 30 Mar 2019 16:50:19 -0400 Subject: [PATCH 063/147] Update az pipelines to only build on master and develop branches --- azure-pipelines.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5d60123..334cbdb 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -4,26 +4,32 @@ # https://aka.ms/yaml name: $(TeamProject)_$(BuildDefinitionName)_$(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 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' @@ -32,15 +38,18 @@ jobs: 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' @@ -49,15 +58,18 @@ jobs: displayName: 'Publish Test Results' 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' From c68225c45894e1c3e5f1e505c2008cf280574d2c Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sat, 30 Mar 2019 23:19:54 -0400 Subject: [PATCH 064/147] Correct vraIdentifier Switch Case --- ZertoApiWrapper/Public/Get-ZertoVra.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZertoApiWrapper/Public/Get-ZertoVra.ps1 b/ZertoApiWrapper/Public/Get-ZertoVra.ps1 index 5f80ea7..410ff7e 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVra.ps1 @@ -84,7 +84,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 From 22d1151c66f503d4b7447d3d89b59c0b9ffe1166 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sat, 30 Mar 2019 23:20:35 -0400 Subject: [PATCH 065/147] Provide minimal information when updating group-name --- ZertoApiWrapper/Public/Edit-ZertoVra.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 b/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 index 638f37c..83a2672 100644 --- a/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 @@ -6,11 +6,13 @@ function Edit-ZertoVra { Mandatory = $true, HelpMessage = "Identifier of the VRA to be updated." )] + [ValidateNotNullOrEmpty()] [Alias("vraId")] [string]$vraIdentifier, [Parameter( HelpMessage = "Bandwidth group to assign to the VRA. If unspecified will not modify current assignment" )] + [ValidateNotNullOrEmpty()] [string]$groupName, [Parameter( ParameterSetName = "StaticIp", @@ -49,7 +51,7 @@ function Edit-ZertoVra { $vraUpdate['GroupName'] = $vra.VraGroup } # If ParameterSetName StaticIp is used, update the parameters submitted - if ( $PSCmdlet.ParameterSetName -eq 'StaticIp' ) { + if ( $PSCmdlet.ParameterSetName -eq 'StaticIp' -or $vra.VraNetworkDataApi.VraIPConfigurationTypeApi -eq "Static" ) { if ( $PSBoundParameters.ContainsKey('defaultGateway') ) { $vraNetwork['DefaultGateway'] = $defaultGateway } else { @@ -68,6 +70,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)")) { From 5139f79366795bcd59ae472864bfb0f62da74e34 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sat, 30 Mar 2019 23:21:00 -0400 Subject: [PATCH 066/147] Updating Tests --- Tests/Public/Add-ZertoPeerSite.Tests.ps1 | 22 ++++-- Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 | 23 +++++- Tests/Public/Connect-ZertoServer.Tests.ps1 | 13 ++++ Tests/Public/Edit-ZertoVra.Tests.ps1 | 77 +++++++++++++++++++ .../Public/Checkpoint-ZertoVpg.ps1 | 1 + 5 files changed, 125 insertions(+), 11 deletions(-) diff --git a/Tests/Public/Add-ZertoPeerSite.Tests.ps1 b/Tests/Public/Add-ZertoPeerSite.Tests.ps1 index f567411..7e63c76 100644 --- a/Tests/Public/Add-ZertoPeerSite.Tests.ps1 +++ b/Tests/Public/Add-ZertoPeerSite.Tests.ps1 @@ -15,37 +15,45 @@ Describe $file.BaseName -Tag 'Unit' { return "9a49f42e-2bbd-4bf8-b571-77908a2e5e98.928a122b-1763-4664-ad37-cc00bb883f2f" } - It "is valid Powershell (Has no script errors)" { + 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 "Should return a string value" { + it "Has proper parameters defined" { + Get-Command $file.BaseName | Should -HaveParameter TargetHost -Mandatory -Type String + Get-Command $file.BaseName | Should -HaveParameter TargetPort -Not -Mandatory -Type String + } + + 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" } - it "Should not take a non-int as a port" { + 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 } - it "Should not take a non-ip address as a 'TargetHost'" { + 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 } - it "Should not require a target port to be defined" { + it "Will not require a target port to be defined" { Add-ZertoPeerSite -targetHost '192.168.1.100' } - it "Should support '-whatif'" { - {Add-ZertoPeerSite -targetHost '192.168.1.100' -WhatIf} | Should -Not -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\(.+\)' } Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest diff --git a/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 b/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 index 206bfaa..ade31c3 100644 --- a/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 @@ -22,19 +22,34 @@ Describe $file.BaseName -Tag 'Unit' { $errors | Should -HaveCount 0 } - it "should return a string" { + 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 "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" } - it "should require a tag name" { + it "Throws and error when an empty checkpointName is specified" { {Checkpoint-ZertoVpg -vpgName "MyVpg" -checkpointName ""} | Should -Throw } - it "should NOT support '-WhatIf'" { - {Checkpoint-ZertoVpg -vpgName "MyVpg" -checkpointName "Checkers" -whatif} | Should -Throw + it "Throws an error when an empty vpgName is specified" { + {Checkpoint-ZertoVpg -vpgName "" -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\(.+\)' } Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest diff --git a/Tests/Public/Connect-ZertoServer.Tests.ps1 b/Tests/Public/Connect-ZertoServer.Tests.ps1 index 5c20b35..ced2602 100644 --- a/Tests/Public/Connect-ZertoServer.Tests.ps1 +++ b/Tests/Public/Connect-ZertoServer.Tests.ps1 @@ -29,6 +29,19 @@ Describe $file.BaseName -Tag Unit { $errors | Should -HaveCount 0 } + it "has a mandatory String parameter for the server vairable" { + Get-Command $file.BaseName | Should -HaveParameter zertoserver -Mandatory -Type String + } + + it "has a non-mandatory String parameter for the port variable" { + Get-Command $file.BaseName | Should -HaveParameter zertoPort -Not -Mandatory + Get-Command $file.BaseName | Should -HaveParameter zertoPort -Type String + } + + it "has a mandatory PSCredential parameter for the credential vairable" { + Get-Command $file.BaseName | Should -HaveParameter credential -Mandatory -Type PSCredential + } + it "returns null when -ReturnHeaders is not used" { Connect-ZertoServer -zertoServer $zertoServer -zertoPort $zertoPort -credential $credential | Should -BeNullOrEmpty } diff --git a/Tests/Public/Edit-ZertoVra.Tests.ps1 b/Tests/Public/Edit-ZertoVra.Tests.ps1 index 50d2f9d..b2ee556 100644 --- a/Tests/Public/Edit-ZertoVra.Tests.ps1 +++ b/Tests/Public/Edit-ZertoVra.Tests.ps1 @@ -10,10 +10,87 @@ Import-Module $moduleFile -Force Describe $file.BaseName -Tag 'Unit' { + Mock -ModuleName ZertoApiWrapper Invoke-ZertoRestRequest { + return "8dcfdc8e-e5d2-4ba4-9885-f9eb57d92b14.928a122b-1763-4664-ad37-cc00bb883f2f" + } + + 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 + } + } + 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 "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 default gateway" { + Get-Command $file.BaseName | Should -HaveParameter subnetMask -Not -Mandatory + Get-Command $file.BaseName | Should -HaveParameter subnetMask -Type String + } } \ No newline at end of file diff --git a/ZertoApiWrapper/Public/Checkpoint-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Checkpoint-ZertoVpg.ps1 index 2b1a371..e8d94b7 100644 --- a/ZertoApiWrapper/Public/Checkpoint-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Checkpoint-ZertoVpg.ps1 @@ -6,6 +6,7 @@ function Checkpoint-ZertoVpg { Mandatory = $true, HelpMessage = "Name of the VPG to tag." )] + [ValidateNotNullOrEmpty()] [string]$vpgName, [Parameter( Mandatory = $true, From 831e1562b5500ab3992e026a8b608622d566959e Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 31 Mar 2019 16:37:02 -0400 Subject: [PATCH 067/147] Update Edit Vra Tests --- Tests/Public/Edit-ZertoVra.Tests.ps1 | 123 +++++++++++++++++++---- ZertoApiWrapper/Public/Edit-ZertoVra.ps1 | 1 + 2 files changed, 104 insertions(+), 20 deletions(-) diff --git a/Tests/Public/Edit-ZertoVra.Tests.ps1 b/Tests/Public/Edit-ZertoVra.Tests.ps1 index b2ee556..c48f099 100644 --- a/Tests/Public/Edit-ZertoVra.Tests.ps1 +++ b/Tests/Public/Edit-ZertoVra.Tests.ps1 @@ -1,6 +1,6 @@ #Requires -Modules Pester $moduleFileName = "ZertoApiWrapper.psd1" -$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") +$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", "" @@ -15,7 +15,7 @@ Describe $file.BaseName -Tag 'Unit' { } Mock -ModuleName ZertoApiWrapper Get-ZertoVra { - vraInformation = @{ + $vraInformation = @{ DatastoreClusterIdentifier = $null DatastoreClusterName = $null DatastoreIdentifier = "840f99fb-4689-2f8b-ea10-2a47a5bb00cc.Prod_Datastore" @@ -60,6 +60,7 @@ Describe $file.BaseName -Tag 'Unit' { } VraVersion = 7.0 } + return $vraInformation } It "is valid Powershell (Has no script errors)" { @@ -69,28 +70,110 @@ Describe $file.BaseName -Tag 'Unit' { $errors | Should -HaveCount 0 } - It "has a mandatory String variable for the vraIdentifier" { - Get-Command $file.BaseName | Should -HaveParameter vraIdentifier -Mandatory -Type String - {Edit-ZertoVra} + Context "$($File.BaseName)::Parameter 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 = ""} + 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 = ""} + 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 = ""} + 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 = "MyVraIdentifier"; paramName = "groupName"; paramValue = ""}, ` + @{vraIdentifier = "MyVraIdentifier"; paramName = "vraIpAddress"; paramValue = ""}, ` + @{vraIdentifier = "MyVraIdentifier"; paramName = "subnetMask"; paramValue = ""}, ` + @{vraIdentifier = "MyVraIdentifier"; paramName = "defaultGateway"; paramValue = ""} + + It " does not take empty strings" -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 + } + } } - 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 - } + Context "$($File.BaseName)::Function Tests" { - 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 "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 "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 "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\(.+\)' + } - it "has a non-mandatory String variable for the default gateway" { - Get-Command $file.BaseName | Should -HaveParameter subnetMask -Not -Mandatory - Get-Command $file.BaseName | Should -HaveParameter subnetMask -Type String } + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoVra } \ No newline at end of file diff --git a/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 b/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 index 83a2672..0b5ef84 100644 --- a/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 @@ -84,3 +84,4 @@ function Edit-ZertoVra { # Nothing to Do } } +#TODO: Refactor \ No newline at end of file From 6e2cb1ea310269f56eb31de9436857b8e27adf9b Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 31 Mar 2019 19:28:24 -0400 Subject: [PATCH 068/147] Add zertoPort validations --- ZertoApiWrapper/Public/Connect-ZertoServer.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 index 2b4e660..232e420 100644 --- a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 +++ b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 @@ -12,6 +12,8 @@ function Connect-ZertoServer { [Parameter( HelpMessage = "Zerto Virtual Manager management port. Default value is 9669." )] + [ValidateNotNullOrEmpty()] + [ValidateRange(1024, 65535)] [Alias("port")] [string]$zertoPort = "9669", [Parameter( From 9828ccd28b5bf083e93592a1c025c805f86e2bd6 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 31 Mar 2019 19:29:09 -0400 Subject: [PATCH 069/147] Formatting correction --- Tests/Public/Add-ZertoPeerSite.Tests.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tests/Public/Add-ZertoPeerSite.Tests.ps1 b/Tests/Public/Add-ZertoPeerSite.Tests.ps1 index 7e63c76..3e56027 100644 --- a/Tests/Public/Add-ZertoPeerSite.Tests.ps1 +++ b/Tests/Public/Add-ZertoPeerSite.Tests.ps1 @@ -29,7 +29,7 @@ Describe $file.BaseName -Tag 'Unit' { it "Returns a string value" { $results = Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort '9081' - $results | should not benullorempty + $results | should -Not -BeNullOrEmpty $results | should -BeOfType "String" $results | Should -BeExactly "9a49f42e-2bbd-4bf8-b571-77908a2e5e98.928a122b-1763-4664-ad37-cc00bb883f2f" } @@ -37,12 +37,14 @@ Describe $file.BaseName -Tag 'Unit' { 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 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 "Will not require a target port to be defined" { From 82cca7ba96479b98cd6b8e2f451483007eff9eb6 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 31 Mar 2019 19:31:35 -0400 Subject: [PATCH 070/147] Add '$null' Tests --- Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 b/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 index ade31c3..0519df4 100644 --- a/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 @@ -37,12 +37,14 @@ Describe $file.BaseName -Tag 'Unit' { $results | should -BeExactly "3b687246-ac63-40da-9a59-b99863769eb0.928a122b-1763-4664-ad37-cc00bb883f2f" } - it "Throws and error when an empty checkpointName is specified" { + 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 vpgName is specified" { + 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'" { From 135e698731f29c4418d7c71d2f454f928ac5325c Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 31 Mar 2019 20:06:05 -0400 Subject: [PATCH 071/147] Specify ErrorAction:Stop for connection errors --- ZertoApiWrapper/Public/Connect-ZertoServer.ps1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 index 232e420..3ce5e49 100644 --- a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 +++ b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 @@ -20,8 +20,7 @@ function Connect-ZertoServer { Mandatory = $true, HelpMessage = "Valid credentials to connect to the Zerto Management Server" )] - [System.Management.Automation.PSCredential] - $credential, + [System.Management.Automation.PSCredential]$credential, [switch]$returnHeaders ) @@ -39,7 +38,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 { From 2b441614f0eb19ad543c3049616332ededf434c5 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 31 Mar 2019 21:02:17 -0400 Subject: [PATCH 072/147] Additional Tests --- Tests/Public/Connect-ZertoServer.Tests.ps1 | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Tests/Public/Connect-ZertoServer.Tests.ps1 b/Tests/Public/Connect-ZertoServer.Tests.ps1 index ced2602..5dadc5a 100644 --- a/Tests/Public/Connect-ZertoServer.Tests.ps1 +++ b/Tests/Public/Connect-ZertoServer.Tests.ps1 @@ -29,15 +29,30 @@ Describe $file.BaseName -Tag Unit { $errors | Should -HaveCount 0 } - it "has a mandatory String parameter for the server vairable" { + it "server vairable has a mandatory String parameter" { Get-Command $file.BaseName | Should -HaveParameter zertoserver -Mandatory -Type String } - it "has a non-mandatory String parameter for the port variable" { + 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 } + 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 $zertoServer -zertoPort 1023 -credential $credential} | Should -Throw + {Connect-ZertoServer -zertoServer $zertoServer -zertoPort 65536 -credential $credential} | Should -Throw + } + it "has a mandatory PSCredential parameter for the credential vairable" { Get-Command $file.BaseName | Should -HaveParameter credential -Mandatory -Type PSCredential } @@ -48,6 +63,7 @@ Describe $file.BaseName -Tag Unit { $headers = Connect-ZertoServer -zertoServer $zertoServer -zertoPort $zertoPort -credential $credential -returnHeaders it "returns a Hashtable with 2 keys" { + $headers | Should -BeOfType Hashtable $headers.keys.count | should be 2 } From a7839b24d9ad0aaf6649d9aed67c85bb37a2d71b Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 31 Mar 2019 21:20:47 -0400 Subject: [PATCH 073/147] OutputFolder variable renamed to OutputPath --- ZertoApiWrapper/Public/Export-ZertoVpg.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 index 72224e6..df3035e 100644 --- a/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 @@ -6,7 +6,9 @@ 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" @@ -31,7 +33,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 } } From c28257ee3a600ae3898b21af3391f4abf6200238 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 31 Mar 2019 21:46:58 -0400 Subject: [PATCH 074/147] Add Default Value Test --- Tests/Public/Connect-ZertoServer.Tests.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/Public/Connect-ZertoServer.Tests.ps1 b/Tests/Public/Connect-ZertoServer.Tests.ps1 index 5dadc5a..493b660 100644 --- a/Tests/Public/Connect-ZertoServer.Tests.ps1 +++ b/Tests/Public/Connect-ZertoServer.Tests.ps1 @@ -41,6 +41,7 @@ Describe $file.BaseName -Tag Unit { 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" { From 3fa53349a593baedd7b0742c465c8b40e8fc4b11 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 31 Mar 2019 21:51:21 -0400 Subject: [PATCH 075/147] Set Parameters to Mandatory --- ZertoApiWrapper/Public/Export-ZertoVpg.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 index df3035e..f44a48a 100644 --- a/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 @@ -11,14 +11,16 @@ function Export-ZertoVpg { [string]$outputPath, [parameter( HelpMessage = "Name(s) of the VPG(s) to be exported", - ParameterSetName = "namedVpgs" + ParameterSetName = "namedVpgs", + Mandatory = $true )] [string[]]$vpgName, [parameter( HelpMessage = "Export all VPGs at this site", ParameterSetName = "allVpgs", valuefrompipeline = $true, - ValueFromPipelineByPropertyName = $true + ValueFromPipelineByPropertyName = $true, + Mandatory = $true )] [switch]$allVpgs ) From d2a574d440bc9bb0382a9166838925b3c1d7f022 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 31 Mar 2019 21:51:36 -0400 Subject: [PATCH 076/147] Add parameter tests --- Tests/Public/Export-ZertoVpg.Tests.ps1 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Tests/Public/Export-ZertoVpg.Tests.ps1 b/Tests/Public/Export-ZertoVpg.Tests.ps1 index 50d2f9d..308f909 100644 --- a/Tests/Public/Export-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Export-ZertoVpg.Tests.ps1 @@ -16,4 +16,20 @@ Describe $file.BaseName -Tag 'Unit' { $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) $errors | Should -HaveCount 0 } + + it "has a mantatory string parameter for the output path" { + Get-Command $file.BaseName | Should -HaveParameter outputPath -Mandatory -Type String + } + + 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 + } } \ No newline at end of file From 46e29dc8c0af16e0d0b7c7f932ba60401c06921e Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 1 Apr 2019 17:32:39 -0400 Subject: [PATCH 077/147] Add InModuleScope Tests --- Tests/Public/Connect-ZertoServer.Tests.ps1 | 115 +++++++++++++++++++-- 1 file changed, 107 insertions(+), 8 deletions(-) diff --git a/Tests/Public/Connect-ZertoServer.Tests.ps1 b/Tests/Public/Connect-ZertoServer.Tests.ps1 index 493b660..0e28fcc 100644 --- a/Tests/Public/Connect-ZertoServer.Tests.ps1 +++ b/Tests/Public/Connect-ZertoServer.Tests.ps1 @@ -10,7 +10,7 @@ Import-Module $moduleFile -Force $userName = "zerto\build" $password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force $credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password) -$zertoServer = "192.168.1.100" +$Server = "192.168.1.100" $zertoPort = "7669" Describe $file.BaseName -Tag Unit { @@ -22,6 +22,30 @@ Describe $file.BaseName -Tag Unit { 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 + } + It "is valid Powershell (Has no script errors)" { $contents = Get-Content -Path $file -ErrorAction Stop $errors = $null @@ -50,8 +74,8 @@ Describe $file.BaseName -Tag Unit { } it "port variable should fall between 1024 and 65535" { - {Connect-ZertoServer -zertoServer $zertoServer -zertoPort 1023 -credential $credential} | Should -Throw - {Connect-ZertoServer -zertoServer $zertoServer -zertoPort 65536 -credential $credential} | Should -Throw + {Connect-ZertoServer -zertoServer $Server -zertoPort 1023 -credential $credential} | Should -Throw + {Connect-ZertoServer -zertoServer $Server -zertoPort 65536 -credential $credential} | Should -Throw } it "has a mandatory PSCredential parameter for the credential vairable" { @@ -59,10 +83,10 @@ Describe $file.BaseName -Tag Unit { } it "returns null when -ReturnHeaders is not used" { - Connect-ZertoServer -zertoServer $zertoServer -zertoPort $zertoPort -credential $credential | Should -BeNullOrEmpty + Connect-ZertoServer -zertoServer $Server -zertoPort $zertoPort -credential $credential | Should -BeNullOrEmpty } - $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 | Should -BeOfType Hashtable $headers.keys.count | should be 2 @@ -86,7 +110,7 @@ Describe $file.BaseName -Tag Unit { } it "should not require a port to be specified" { - Connect-ZertoServer -zertoServer $zertoServer -credential $credential + Connect-ZertoServer -zertoServer $Server -credential $credential } it "should require a PSCredentialObject for the credentials" { @@ -96,6 +120,81 @@ Describe $file.BaseName -Tag Unit { } Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoLocalSite + } + + InModuleScope ZertoApiWrapper { + Context "InModuleScope Tests" { + 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 '192.168.1.100' -credential $credential + + it "Module Scope zvmServer variable tests" { + $script:zvmServer | Should -Not -BeNullOrEmpty + $script:zvmServer | Should -Be '192.168.1.100' + } + + 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 + } + + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoLocalSite + } } } <# @@ -106,7 +205,7 @@ Describe "Connect-ZertoServer" -Tag Integration { 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 } @@ -124,4 +223,4 @@ Describe "Connect-ZertoServer" -Tag Integration { } Disconnect-ZertoServer } - #> \ No newline at end of file + #> From 7bd8e5c7ee46985d932b23135cd7d4505c1f4a9e Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 1 Apr 2019 17:33:37 -0400 Subject: [PATCH 078/147] Validate NullorEmpty VpgName --- ZertoApiWrapper/Public/Export-ZertoVpg.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 index f44a48a..3f5efb8 100644 --- a/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Export-ZertoVpg.ps1 @@ -14,6 +14,7 @@ function Export-ZertoVpg { ParameterSetName = "namedVpgs", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string[]]$vpgName, [parameter( HelpMessage = "Export all VPGs at this site", From bc0bb337a6d383c27a3fc9fcbe714ac53ca86366 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 1 Apr 2019 17:37:18 -0400 Subject: [PATCH 079/147] Add null or empty assertions --- Tests/Public/Export-ZertoVpg.Tests.ps1 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Tests/Public/Export-ZertoVpg.Tests.ps1 b/Tests/Public/Export-ZertoVpg.Tests.ps1 index 308f909..2b0e2de 100644 --- a/Tests/Public/Export-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Export-ZertoVpg.Tests.ps1 @@ -1,4 +1,5 @@ #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.", ".") @@ -7,6 +8,7 @@ $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' { @@ -18,7 +20,7 @@ Describe $file.BaseName -Tag 'Unit' { } it "has a mantatory string parameter for the output path" { - Get-Command $file.BaseName | Should -HaveParameter outputPath -Mandatory -Type String + Get-Command $file.BaseName | Should -HaveParameter outputPath -Type String -Mandatory } it "has a non-mandatory string array parameter for vpgName(s) to export" { @@ -32,4 +34,14 @@ Describe $file.BaseName -Tag 'Unit' { it "No defined vpgName or AllVpg switch should throw an error" { {Export-ZertoVpg -outputPath "."} | Should -Throw } -} \ No newline at end of file + + 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 + } +} From a3aa0c47a61fb6829634ae8b88a33af79c4255e9 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 1 Apr 2019 17:37:46 -0400 Subject: [PATCH 080/147] Provide credentials for InModuleScope Tests --- Tests/Public/Connect-ZertoServer.Tests.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Tests/Public/Connect-ZertoServer.Tests.ps1 b/Tests/Public/Connect-ZertoServer.Tests.ps1 index 0e28fcc..5ade506 100644 --- a/Tests/Public/Connect-ZertoServer.Tests.ps1 +++ b/Tests/Public/Connect-ZertoServer.Tests.ps1 @@ -125,6 +125,12 @@ Describe $file.BaseName -Tag Unit { InModuleScope ZertoApiWrapper { Context "InModuleScope Tests" { + + $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} From 28fb62f737a1f907a121a3a53034228180eaf30e Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 1 Apr 2019 21:10:41 -0400 Subject: [PATCH 081/147] Clean Test Organization --- Tests/Public/Add-ZertoPeerSite.Tests.ps1 | 66 ++++++---- Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 | 73 ++++++----- Tests/Public/Connect-ZertoServer.Tests.ps1 | 117 +++++++----------- Tests/Public/Disconnect-ZertoServer.Tests.ps1 | 15 ++- Tests/Public/Edit-ZertoVra.Tests.ps1 | 22 ++-- Tests/Public/Export-ZertoVpg.Tests.ps1 | 48 +++---- 6 files changed, 175 insertions(+), 166 deletions(-) diff --git a/Tests/Public/Add-ZertoPeerSite.Tests.ps1 b/Tests/Public/Add-ZertoPeerSite.Tests.ps1 index 3e56027..a55ee59 100644 --- a/Tests/Public/Add-ZertoPeerSite.Tests.ps1 +++ b/Tests/Public/Add-ZertoPeerSite.Tests.ps1 @@ -9,35 +9,18 @@ Get-Module -Name ZertoApiWrapper | Remove-Module -Force Import-Module $moduleFile -Force Describe $file.BaseName -Tag 'Unit' { - Context "Basic Features" { - Mock -ModuleName ZertoApiWrapper Invoke-ZertoRestRequest { - return "9a49f42e-2bbd-4bf8-b571-77908a2e5e98.928a122b-1763-4664-ad37-cc00bb883f2f" - } + 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 "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 proper parameters defined" { + it "Has a mandatory string parameter for the target host" { Get-Command $file.BaseName | Should -HaveParameter TargetHost -Mandatory -Type String - Get-Command $file.BaseName | Should -HaveParameter TargetPort -Not -Mandatory -Type String - } - - 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" - } - - 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 not take a non-ip address as a 'TargetHost'" { @@ -47,8 +30,23 @@ Describe $file.BaseName -Tag 'Unit' { {Add-ZertoPeerSite -targetHost $null -targetPort '9081'} | should -Throw } - it "Will not require a target port to be defined" { - Add-ZertoPeerSite -targetHost '192.168.1.100' + 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'" { @@ -57,6 +55,20 @@ Describe $file.BaseName -Tag 'Unit' { $file | Should -FileContentMatch 'SupportsShouldProcess' $file | Should -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)' } + } + + Context "$($file.BaseName)::Function Unit Tests" { + + Mock -ModuleName ZertoApiWrapper Invoke-ZertoRestRequest { + return "9a49f42e-2bbd-4bf8-b571-77908a2e5e98.928a122b-1763-4664-ad37-cc00bb883f2f" + } + + it "Returns a string value" { + $results = Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort '9081' + $results | should -Not -BeNullOrEmpty + $results | should -BeOfType "String" + $results | Should -BeExactly "9a49f42e-2bbd-4bf8-b571-77908a2e5e98.928a122b-1763-4664-ad37-cc00bb883f2f" + } Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest } diff --git a/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 b/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 index 0519df4..f07f347 100644 --- a/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Checkpoint-ZertoVpg.Tests.ps1 @@ -9,12 +9,7 @@ Get-Module -Name ZertoApiWrapper | Remove-Module -Force Import-Module $moduleFile -Force Describe $file.BaseName -Tag 'Unit' { - 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"} - } + It "is valid Powershell (Has no script errors)" { $contents = Get-Content -Path $file -ErrorAction Stop $errors = $null @@ -22,38 +17,50 @@ Describe $file.BaseName -Tag 'Unit' { $errors | Should -HaveCount 0 } - it "Has a parameter for the VpgName that is Mandatory" { - Get-Command $file.BaseName | Should -HaveParameter vpgName -Mandatory -Type String + 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"} } - it "Has a parameter for the CheckpointName that is Mandatory" { - Get-Command $file.BaseName | Should -HaveParameter CheckpointName -Mandatory -Type String + 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\(.+\)' + } } - 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" - } + Context "$($file.BaseName)::Function Unit Tests" { - 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 "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" + } - 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 + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest + Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpg } - - 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\(.+\)' - } - - 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 5ade506..59c5e8b 100644 --- a/Tests/Public/Connect-ZertoServer.Tests.ps1 +++ b/Tests/Public/Connect-ZertoServer.Tests.ps1 @@ -14,44 +14,15 @@ $Server = "192.168.1.100" $zertoPort = "7669" Describe $file.BaseName -Tag Unit { - Context "Basic Features" { - 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 - } + 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 "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 @@ -76,56 +47,25 @@ Describe $file.BaseName -Tag Unit { 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 "returns null when -ReturnHeaders is not used" { - Connect-ZertoServer -zertoServer $Server -zertoPort $zertoPort -credential $credential | Should -BeNullOrEmpty - } - - $headers = Connect-ZertoServer -zertoServer $Server -zertoPort $zertoPort -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 "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 } - - Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest - Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoLocalSite } InModuleScope ZertoApiWrapper { - Context "InModuleScope Tests" { + 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) @@ -163,11 +103,11 @@ Describe $file.BaseName -Tag Unit { } $now = $(Get-Date).ticks - Connect-ZertoServer -zertoServer '192.168.1.100' -credential $credential + Connect-ZertoServer -zertoServer $server -credential $credential it "Module Scope zvmServer variable tests" { $script:zvmServer | Should -Not -BeNullOrEmpty - $script:zvmServer | Should -Be '192.168.1.100' + $script:zvmServer | Should -Be $server } it "Module Scope zvmPort variable tests" { @@ -198,6 +138,37 @@ Describe $file.BaseName -Tag Unit { $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 } diff --git a/Tests/Public/Disconnect-ZertoServer.Tests.ps1 b/Tests/Public/Disconnect-ZertoServer.Tests.ps1 index a2238f8..5be178d 100644 --- a/Tests/Public/Disconnect-ZertoServer.Tests.ps1 +++ b/Tests/Public/Disconnect-ZertoServer.Tests.ps1 @@ -15,6 +15,7 @@ Describe $file.BaseName -Tag 'Unit' { Mock -ModuleName ZertoApiWrapper -CommandName Remove-Variable { } + It "is valid Powershell (Has no script errors)" { $contents = Get-Content -Path $file -ErrorAction Stop $errors = $null @@ -22,11 +23,15 @@ Describe $file.BaseName -Tag 'Unit' { $errors | Should -HaveCount 0 } - it "Does not return anything" { - Disconnect-ZertoServer | Should -BeNullOrEmpty + Context "$($file.BaseName)::Parameter Unit Tests" { + it "Does not take any parameters" { + (get-command disconnect-zertoserver).parameters.count | Should -BeExactly 11 + } } - 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 + } } -} \ No newline at end of file +} diff --git a/Tests/Public/Edit-ZertoVra.Tests.ps1 b/Tests/Public/Edit-ZertoVra.Tests.ps1 index c48f099..4026b3d 100644 --- a/Tests/Public/Edit-ZertoVra.Tests.ps1 +++ b/Tests/Public/Edit-ZertoVra.Tests.ps1 @@ -70,7 +70,7 @@ Describe $file.BaseName -Tag 'Unit' { $errors | Should -HaveCount 0 } - Context "$($File.BaseName)::Parameter Tests" { + 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 @@ -108,7 +108,8 @@ Describe $file.BaseName -Tag 'Unit' { @{vraIpAddress = 192.168.1}, ` @{vraIpAddress = 192.168.1.246}, ` @{vraIpAddress = 32}, ` - @{vraIpAddress = ""} + @{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 @@ -121,7 +122,8 @@ Describe $file.BaseName -Tag 'Unit' { @{subnetMask = 192.168.1}, ` @{subnetMask = 192.168.1.246}, ` @{subnetMask = 32}, ` - @{subnetMask = ""} + @{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 @@ -134,7 +136,8 @@ Describe $file.BaseName -Tag 'Unit' { @{defaultGateway = 192.168.1}, ` @{defaultGateway = 192.168.1.246}, ` @{defaultGateway = 32}, ` - @{defaultGateway = ""} + @{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 @@ -142,12 +145,17 @@ Describe $file.BaseName -Tag 'Unit' { $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 = "defaultGateway"; paramValue = ""} + @{vraIdentifier = "MyVraIdentifier"; paramName = "subnetMask"; paramValue = $null}, ` + @{vraIdentifier = "MyVraIdentifier"; paramName = "defaultGateway"; paramValue = ""}, ` + @{vraIdentifier = "MyVraIdentifier"; paramName = "defaultGateway"; paramValue = $null} - It " does not take empty strings" -TestCases $cases { + It " does not take empty or null" -TestCases $cases { param($vraIdentifier, $paramValue, $paramName ) if ([String]::IsNullOrEmpty($vraIdentifier)) { {Edit-ZertoVra -vraIdentifier $vraIdentifier} | Should -Throw @@ -157,7 +165,7 @@ Describe $file.BaseName -Tag 'Unit' { } } - Context "$($File.BaseName)::Function Tests" { + Context "$($File.BaseName)::Function Unit Tests" { It "Returns a string" { $results = Edit-ZertoVra -vraIdentifier "MyVraIdentifier" -groupName "MyGroup" diff --git a/Tests/Public/Export-ZertoVpg.Tests.ps1 b/Tests/Public/Export-ZertoVpg.Tests.ps1 index 2b0e2de..5f5afd9 100644 --- a/Tests/Public/Export-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Export-ZertoVpg.Tests.ps1 @@ -19,29 +19,35 @@ Describe $file.BaseName -Tag 'Unit' { $errors | Should -HaveCount 0 } - it "has a mantatory string parameter for the output path" { - Get-Command $file.BaseName | Should -HaveParameter outputPath -Type String -Mandatory + 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 + } } - it "has a non-mandatory string array parameter for vpgName(s) to export" { - Get-Command $file.BaseName | Should -HaveParameter vpgName -Type String[] -Mandatory - } + Context "$($file.BaseName)::Function Unit Tests" { - 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 } } From d0a75153adf8acf7bfcd59cc0c59526b35b6527e Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 1 Apr 2019 22:25:52 -0400 Subject: [PATCH 082/147] Start Function Tests --- Tests/Public/Export-ZertoVpg.Tests.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Tests/Public/Export-ZertoVpg.Tests.ps1 b/Tests/Public/Export-ZertoVpg.Tests.ps1 index 5f5afd9..ff084e2 100644 --- a/Tests/Public/Export-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Export-ZertoVpg.Tests.ps1 @@ -48,6 +48,14 @@ Describe $file.BaseName -Tag 'Unit' { } Context "$($file.BaseName)::Function Unit Tests" { + Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest { + } + + $outputPath = "TestDrive:\" + + it "Should Exist" { + $outputPath | Should -Exist + } } } From 071053cf92dac7eec048afaa978de66eca97e753 Mon Sep 17 00:00:00 2001 From: wildcard78 Date: Tue, 2 Apr 2019 09:01:40 -0400 Subject: [PATCH 083/147] Update Get-ZertoAlert.Tests.ps1 Added alertId check --- Tests/Public/Get-ZertoAlert.Tests.ps1 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Tests/Public/Get-ZertoAlert.Tests.ps1 b/Tests/Public/Get-ZertoAlert.Tests.ps1 index 50d2f9d..1367839 100644 --- a/Tests/Public/Get-ZertoAlert.Tests.ps1 +++ b/Tests/Public/Get-ZertoAlert.Tests.ps1 @@ -16,4 +16,14 @@ Describe $file.BaseName -Tag 'Unit' { $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) $errors | Should -HaveCount 0 } -} \ No newline at end of file + + 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[] + } + + } + +} + From 8e86b26d5267351761424f86f9839e134b2d5945 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Tue, 2 Apr 2019 14:56:25 -0400 Subject: [PATCH 084/147] Update Export-ZertoVpg.Tests.ps1 Complete creation of Function Unit Tests. --- Tests/Public/Export-ZertoVpg.Tests.ps1 | 196 ++++++++++++++++++++++++- 1 file changed, 192 insertions(+), 4 deletions(-) diff --git a/Tests/Public/Export-ZertoVpg.Tests.ps1 b/Tests/Public/Export-ZertoVpg.Tests.ps1 index ff084e2..e46b59e 100644 --- a/Tests/Public/Export-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Export-ZertoVpg.Tests.ps1 @@ -48,14 +48,202 @@ Describe $file.BaseName -Tag 'Unit' { } Context "$($file.BaseName)::Function Unit Tests" { - Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest { - + Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpg { + $returnObj = @{ + VpgName = "HRIS" + VpgIdentifier = "dddf2fa8-79e2-4e4f-a83b-f66676afea64" + } + return $returnObj } - $outputPath = "TestDrive:\" + Mock -ModuleName ZertoApiWrapper -CommandName New-ZertoVpgSettingsIdentifier { + return "1024d377-afb8-4880-82f0-96eeff413ffd" + } - it "Should Exist" { + 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 } } From 42dc016d908a8bc926e3126180f10ed17f88eb40 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Tue, 2 Apr 2019 17:31:59 -0400 Subject: [PATCH 085/147] Starting Import-ZertoVpg Tests --- Tests/Public/Import-ZertoVpg.Tests.ps1 | 22 +++++++++++++++++++++- ZertoApiWrapper/Public/Import-ZertoVpg.ps1 | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Tests/Public/Import-ZertoVpg.Tests.ps1 b/Tests/Public/Import-ZertoVpg.Tests.ps1 index 50d2f9d..bd91e77 100644 --- a/Tests/Public/Import-ZertoVpg.Tests.ps1 +++ b/Tests/Public/Import-ZertoVpg.Tests.ps1 @@ -16,4 +16,24 @@ Describe $file.BaseName -Tag 'Unit' { $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) $errors | Should -HaveCount 0 } -} \ No newline at end of file + + 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/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 index bbc45ef..48a72cc 100644 --- a/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Import-ZertoVpg.ps1 @@ -8,6 +8,7 @@ function Import-ZertoVpg { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true )] + [ValidateNotNullOrEmpty()] [Alias("FullName")] [string[]]$settingsFile ) From 1a5f2b09f64f2acf3a7d089c165732543e497491 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 4 Apr 2019 08:38:56 -0400 Subject: [PATCH 086/147] Add Null and Empty Validators --- ZertoApiWrapper/Public/Install-ZertoVra.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ZertoApiWrapper/Public/Install-ZertoVra.ps1 b/ZertoApiWrapper/Public/Install-ZertoVra.ps1 index 719f6a4..0a66c93 100644 --- a/ZertoApiWrapper/Public/Install-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Install-ZertoVra.ps1 @@ -4,10 +4,13 @@ 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)] From 289e976773dcb06d5de108e03ec4f5ec616ee2a8 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 4 Apr 2019 08:39:11 -0400 Subject: [PATCH 087/147] Parameter Tests --- Tests/Public/Install-ZertoVra.Tests.ps1 | 91 ++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/Tests/Public/Install-ZertoVra.Tests.ps1 b/Tests/Public/Install-ZertoVra.Tests.ps1 index 50d2f9d..37c09a0 100644 --- a/Tests/Public/Install-ZertoVra.Tests.ps1 +++ b/Tests/Public/Install-ZertoVra.Tests.ps1 @@ -16,4 +16,93 @@ Describe $file.BaseName -Tag 'Unit' { $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) $errors | Should -HaveCount 0 } -} \ No newline at end of file + + 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 + } + + } + + Context "$($file.BaseName)::Function Unit Tests" { + + } +} From 96f70afe67d85bf7d86555eaa7670fe52702dc87 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 4 Apr 2019 11:30:48 -0400 Subject: [PATCH 088/147] Add TODO Items --- Tests/Public/Install-ZertoVra.Tests.ps1 | 2 +- ZertoApiWrapper/Public/Install-ZertoVra.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Public/Install-ZertoVra.Tests.ps1 b/Tests/Public/Install-ZertoVra.Tests.ps1 index 37c09a0..598a6e4 100644 --- a/Tests/Public/Install-ZertoVra.Tests.ps1 +++ b/Tests/Public/Install-ZertoVra.Tests.ps1 @@ -103,6 +103,6 @@ Describe $file.BaseName -Tag 'Unit' { } Context "$($file.BaseName)::Function Unit Tests" { - + #TODO } } diff --git a/ZertoApiWrapper/Public/Install-ZertoVra.ps1 b/ZertoApiWrapper/Public/Install-ZertoVra.ps1 index 0a66c93..2aad0a8 100644 --- a/ZertoApiWrapper/Public/Install-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Install-ZertoVra.ps1 @@ -1,5 +1,5 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> -#TODO - Add ability to installed with root password. +#TODO - Add ability to installed with root password, Move to Begin, Process, End Format function Install-ZertoVra { [cmdletbinding( SupportsShouldProcess = $true )] param( From b74f6cae51a378dc4ed071678aad9919407c8c5a Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 4 Apr 2019 16:07:27 -0400 Subject: [PATCH 089/147] Add TestingBranch to CI --- azure-pipelines.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 334cbdb..eb29a69 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,11 +11,13 @@ trigger: include: - master - develop + - TestingBranch # Trigger CI on pull requests to master and develop branches pr: - master - develop + - TestingBranch jobs: # Windows Build Job From cc43b272a8c0264fc7bb5cf51437bf3bde410430 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 4 Apr 2019 17:31:28 -0400 Subject: [PATCH 090/147] Specify OutputType --- ZertoApiWrapper/Public/Connect-ZertoServer.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 index 3ce5e49..5c7b3b0 100644 --- a/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 +++ b/ZertoApiWrapper/Public/Connect-ZertoServer.ps1 @@ -1,6 +1,7 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Connect-ZertoServer { [cmdletbinding()] + [OutputType([hashtable])] param( [Parameter( Mandatory = $true, From f2a95acc23c59533bd774cde3a3760e2b044b2f0 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 4 Apr 2019 17:36:34 -0400 Subject: [PATCH 091/147] Remove arraylist return object --- ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 b/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 index 3a8e0e9..1b8b4f2 100644 --- a/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 @@ -46,7 +46,6 @@ function Get-ZertoPeerSite { begin { $baseUri = "peersites" - $returnObject = [System.Collections.ArrayList]@() } process { @@ -54,14 +53,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 } } @@ -69,18 +68,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! } } From adc4391a917341ab3408e78f6f456046acac6e82 Mon Sep 17 00:00:00 2001 From: The Codacy Badger Date: Thu, 4 Apr 2019 22:47:20 +0000 Subject: [PATCH 092/147] Add Codacy badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e2f76cc..0fa3a9a 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ 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 From 68ad1e9443bdc1fe7826d046a8bb8c64edf6ac81 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 4 Apr 2019 20:34:15 -0400 Subject: [PATCH 093/147] Add Settings Validation and ShouldProcess --- ZertoApiWrapper/Public/New-ZertoVpg.ps1 | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/ZertoApiWrapper/Public/New-ZertoVpg.ps1 b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 index 020a309..48c96b3 100644 --- a/ZertoApiWrapper/Public/New-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 @@ -1,6 +1,6 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function New-ZertoVpg { - [cmdletbinding()] + [cmdletbinding(SupportsShouldProcess = $true)] param( [Parameter( HelpMessage = "Name of the VPG", @@ -226,6 +226,24 @@ 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." + Break + } } process { @@ -295,7 +313,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 { From a823b4971e62742a576392c6fb3be3cfcdfbea21 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Thu, 4 Apr 2019 21:12:53 -0400 Subject: [PATCH 094/147] Update with ShouldProcess --- ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 | 7 +++++-- ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 | 6 ++++-- ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 | 8 ++++++-- ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 | 7 +++++-- ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 | 7 +++++-- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 b/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 index 401b85d..9925d30 100644 --- a/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 +++ b/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 @@ -1,6 +1,6 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function New-ZertoVpgSettingsIdentifier { - [cmdletbinding()] + [cmdletbinding( SupportsShouldProcess = $true )] param( [Parameter( HelpMessage = "Identifier of the VPG to create a VPG settings identifier. If a vpgIdentifier is not provided, a new VPG settings object is created without any configured settings. This would be used for creating a new VPG from scratch.", @@ -33,7 +33,10 @@ function New-ZertoVpgSettingsIdentifier { } process { - Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST" + if ($PSCmdlet.ShouldProcess("Creating VPG Settings Object")) { + Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST" + } + } end { diff --git a/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 b/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 index 45ffd5b..03a9677 100644 --- a/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 +++ b/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 @@ -1,6 +1,6 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Start-ZertoCloneVpg { - [cmdletbinding()] + [cmdletbinding( SupportsShouldProcess = $true )] param( [Parameter( HelpMessage = "Name of the VPG you wish to clone.", @@ -53,7 +53,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 6e8ce11..51d1e38 100644 --- a/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 +++ b/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 @@ -1,6 +1,6 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Start-ZertoFailoverTest { - [cmdletbinding()] + [cmdletbinding( SupportsShouldProcess = $true )] param( [Parameter( HelpMessage = "Name of VPG to failover test", @@ -42,7 +42,11 @@ function Start-ZertoFailoverTest { } $body['VmIdentifiers'] = $vmIdentifiers } - Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) + if ($PSCmdlet.ShouldProcess("Starting Failover Test")) { + 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 892c167..72e09f4 100644 --- a/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 +++ b/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 @@ -1,6 +1,6 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Stop-ZertoCloneVpg { - [cmdletbinding()] + [cmdletbinding( SupportsShouldProcess = $true )] param( [Parameter( HelpMessage = "Name of the VPG to stop cloning", @@ -16,7 +16,10 @@ function Stop-ZertoCloneVpg { 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..c8c63c9 100644 --- a/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 +++ b/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 @@ -1,6 +1,6 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Stop-ZertoFailoverTest { - [cmdletbinding()] + [cmdletbinding( SupportsShouldProcess = $true )] param( [Parameter( HelpMessage = "Name(s) of VPG(s) to stop testing.", @@ -26,7 +26,10 @@ function Stop-ZertoFailoverTest { foreach ($name in $vpgName) { $vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier $uri = "{0}/{1}/FailoverTestStop" -f $baseUri, $vpgId - Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) + if ($PSCmdlet.ShouldProcess("Stopping Failover Test")) { + Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) + } + } } From bd1fe15d3e19e561cb40f15a9f11d0f1788ad395 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 12:05:15 -0400 Subject: [PATCH 095/147] Fix Typo --- Tests/ZertoApiWrapper.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/ZertoApiWrapper.Tests.ps1 b/Tests/ZertoApiWrapper.Tests.ps1 index b2300af..bcbb9ca 100644 --- a/Tests/ZertoApiWrapper.Tests.ps1 +++ b/Tests/ZertoApiWrapper.Tests.ps1 @@ -8,7 +8,7 @@ Describe "Module: $module" -Tags 'Unit' { Context "Module Configuration" { - It "Has a rood module file ($module.psm1)" { + It "Has a root module file ($module.psm1)" { "$modulePath\$module.psm1" | should -Exist } From 3a0f039a421af2ca971df0eb06a36adaf723ec05 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 12:06:00 -0400 Subject: [PATCH 096/147] Store Version in an External File --- ZertoApiWrapper.build.ps1 | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index d0cdecd..338b041 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -7,10 +7,7 @@ param([switch]$Install, [string]$Configuration = (property Configuration Release)) $targetDir = "temp/$Configuration/ZertoApiWrapper" #> - -$versionMajor = '0' -$versionMinor = '1' -$versionBuild = "{0}" -f $(get-date -format 'yyyyMMdd') +$version = "{0}.{1}" -f $(Get-Content .\version.txt), $(get-date -format 'yyyyMMdd') task . AnalyzeSourceFiles, CreateModule @@ -57,7 +54,7 @@ task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, CreatePsm1ForRelease, { Severity = @('Error', 'Warning') Recurse = $true Verbose = $false - ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments', 'PSUseShouldProcessForStateChangingFunctions', 'PSUseToExportFieldsInManifest') + ExcludeRule = @() } $saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams @@ -97,7 +94,7 @@ task CreatePsd1ForRelease CleanTemp, { $ManifestParams = @{ Path = "$BuildRoot\temp\ZertoApiWrapper.psd1" RootModule = 'ZertoApiWrapper.psm1' - ModuleVersion = '{0}.{1}.{2}' -f $versionMajor, $versionMinor, $versionBuild + ModuleVersion = $version GUID = '4c0b9e17-141b-4dd5-8549-fb21cccaa325' Author = 'Wes Carroll' CompanyName = 'Zerto' @@ -138,7 +135,6 @@ task CreatePsm1ForRelease CreatePsd1ForRelease, { $exportString = "{0}, {1}" -f $exportString, $file.BaseName } } - $export = "Export-ModuleMember -Function $exportString" $Private = @( Get-ChildItem -Path $BuildRoot\ZertoApiWrapper\Private\*.ps1 -ErrorAction SilentlyContinue ) Add-Content -Path $psm1Path -Value $lines Add-Content -Path $psm1Path -Value "#---------------------Private Functions----------------------#" From 25e559ff89c32fe0cda1686ddfe87037ab9761d2 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 12:06:19 -0400 Subject: [PATCH 097/147] Remove Unused File --- ZertoApiWrapper.build.ps1.old | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 ZertoApiWrapper.build.ps1.old diff --git a/ZertoApiWrapper.build.ps1.old b/ZertoApiWrapper.build.ps1.old deleted file mode 100644 index 39640d6..0000000 --- a/ZertoApiWrapper.build.ps1.old +++ /dev/null @@ -1,32 +0,0 @@ -task . FileTests, BuildPsd1, Analyze - -task InstallDependencies { - Install-Module Pester -Force - Install-Module PSScriptAnalyzer -Force -} - -task Analyze { - $scriptAnalyzerParams = @{ - Path = "$BuildRoot\ZertoApiWrapper\" - Severity = @('Error', 'Warning') - Recurse = $true - Verbose = $false - ExcludeRule = @('PSUseDeclaredVarsMoreThanAssignments','PSUseShouldProcessForStateChangingFunctions') - } - $saresults = Invoke-ScriptAnalyzer @scriptAnalyzerParams - - if ($saResults) { - $saResults | Format-Table - throw "One or more PSScriptAnalyzer errors/warnings were found" - } -} - -task FileTests { - Invoke-Pester "$BuildRoot\Tests\Public\ZertoApiWrapper.Tests.ps1" -} - -task BuildPsd1 { - $functionsToExportPath = "$BuildRoot\ZertoApiWrapper\Public\" - $functionsToExport = (Get-ChildItem -Path $functionsToExportPath -File).name.Replace('.ps1', '') - $functionsToExport -} From b9e5d069b629208d640ba5ecb8c1281d0da77985 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 12:06:45 -0400 Subject: [PATCH 098/147] Remove PSake as a dependency --- ZertoApiWrapper.Depend.psd1 | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/ZertoApiWrapper.Depend.psd1 b/ZertoApiWrapper.Depend.psd1 index 9b60641..09af820 100644 --- a/ZertoApiWrapper.Depend.psd1 +++ b/ZertoApiWrapper.Depend.psd1 @@ -1,16 +1,4 @@ @{ - psake = @{ - Name = 'InvokeBuild' - DependencyType = 'PSGalleryModule' - Parameters = @{ - Repository = 'PSGallery' - SkipPublisherCheck = $true - } - Target = 'CurrentUser' - Version = '5.4.3' - Tags = 'Bootstrap' - } - Pester = @{ Name = 'Pester' DependencyType = 'PSGalleryModule' @@ -46,5 +34,4 @@ Version = '0.12.0' Tags = 'Bootstrap' } - } From 1f1b5b9d9497e73000f0cd92f95bf225a7c13254 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 13:58:29 -0400 Subject: [PATCH 099/147] Add functionality for release notes in module --- RELEASENOTES.md | 6 ++++++ ZertoApiWrapper.build.ps1 | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 RELEASENOTES.md 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/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 338b041..9902a12 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -91,6 +91,8 @@ task UpdateMarkdownHelp CheckPlatyPSInstalled, { task CreatePsd1ForRelease CleanTemp, { $functionsToExport = Get-ChildItem -Path 'ZertoApiWrapper\Public\*.ps1' | ForEach-Object { $_.BaseName } + $releaseNotes = "# {0}{1}" -f $version, $(Get-Content .\RELEASENOTES.md -Raw) + $ManifestParams = @{ Path = "$BuildRoot\temp\ZertoApiWrapper.psd1" RootModule = 'ZertoApiWrapper.psm1' @@ -108,6 +110,7 @@ task CreatePsd1ForRelease CleanTemp, { CmdletsToExport = @() VariablesToExport = @() AliasesToExport = @() + ReleaseNotes = $releaseNotes } New-ModuleManifest @ManifestParams } @@ -156,6 +159,23 @@ task CreatePsm1ForRelease CreatePsd1ForRelease, { 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, { } From 402e624d0c2b180d62a7112e36e872a65250908e Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 13:59:16 -0400 Subject: [PATCH 100/147] Ignore Publish Directory --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ab7904e..975fb76 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ *.zip temp/* Tests/Public/TestResults.xml -Tests/TestResults.xml +Tests/TestResults.xml +publish/* From 9c309e70e93b87f99aca74f4538c08109bb457b7 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 14:08:49 -0400 Subject: [PATCH 101/147] Publish Artifacts --- azure-pipelines.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index eb29a69..1e7b477 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -60,6 +60,21 @@ jobs: displayName: 'Publish Test Results' condition: always() + - task: PublishPipelineArtifact@2 + displayName: 'Publish compiled module Artifact' + inputs: + artifactName: 'ZertoApiWrapper' + targetPath: ./temp + condition: always() + + - task: PublishPipelineArtifact@2 + displayName: 'Publish Data' + inputs: + artifactName: 'ReleaseData' + targetPath: ./publish + condition: always() + + # MacOS Build Job - job: Build_PSCore_MacOS1013 timeoutInMinutes: 10 From 026b622a3440fbf5dbfba564054eae01b7c68adb Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 14:09:06 -0400 Subject: [PATCH 102/147] Update Build to Create Artifacts --- ZertoApiWrapper.build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 9902a12..9a9ad17 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -9,7 +9,7 @@ param([switch]$Install, $targetDir = "temp/$Configuration/ZertoApiWrapper" #> $version = "{0}.{1}" -f $(Get-Content .\version.txt), $(get-date -format 'yyyyMMdd') -task . AnalyzeSourceFiles, CreateModule +task . CreateArtifacts <# Synopsis: Ensure platyPS is installed #> task CheckPlatyPSInstalled { From a63b6cab951a8a34944bc160d5ef9630020f9428 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 14:12:12 -0400 Subject: [PATCH 103/147] Clean YAML --- azure-pipelines.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1e7b477..a5b28a3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -59,14 +59,12 @@ jobs: testRunTitle: 'PSCore_Ubuntu1604' displayName: 'Publish Test Results' condition: always() - - task: PublishPipelineArtifact@2 displayName: 'Publish compiled module Artifact' inputs: artifactName: 'ZertoApiWrapper' targetPath: ./temp condition: always() - - task: PublishPipelineArtifact@2 displayName: 'Publish Data' inputs: @@ -74,7 +72,6 @@ jobs: targetPath: ./publish condition: always() - # MacOS Build Job - job: Build_PSCore_MacOS1013 timeoutInMinutes: 10 From cc6010774622f559b7dbedc448539c2a2bd18659 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 14:14:20 -0400 Subject: [PATCH 104/147] Update Version Number of PublishPipelineArtifact --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a5b28a3..a756f57 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -59,13 +59,13 @@ jobs: testRunTitle: 'PSCore_Ubuntu1604' displayName: 'Publish Test Results' condition: always() - - task: PublishPipelineArtifact@2 + - task: PublishPipelineArtifact@0 displayName: 'Publish compiled module Artifact' inputs: artifactName: 'ZertoApiWrapper' targetPath: ./temp condition: always() - - task: PublishPipelineArtifact@2 + - task: PublishPipelineArtifact@0 displayName: 'Publish Data' inputs: artifactName: 'ReleaseData' From 3acb7795f4c106c952ae517515ca757ddfceb501 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 14:18:43 -0400 Subject: [PATCH 105/147] Add InvokeBuild Requirement --- ZertoApiWrapper.Depend.psd1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ZertoApiWrapper.Depend.psd1 b/ZertoApiWrapper.Depend.psd1 index 09af820..d645015 100644 --- a/ZertoApiWrapper.Depend.psd1 +++ b/ZertoApiWrapper.Depend.psd1 @@ -1,4 +1,16 @@ @{ + InvokeBuild = @{ + Name = 'InvokeBuild' + DependencyType = 'PSGalleryModule' + Parameters = @{ + Repository = 'PSGallery' + SkipPublisherCheck = $true + } + Target = 'CurrentUser' + Version = '5.4.3' + Tags = 'Bootstrap' + } + Pester = @{ Name = 'Pester' DependencyType = 'PSGalleryModule' From 5b3a1c263e218b867bdfb78511e3b9a185c45f11 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 15:01:28 -0400 Subject: [PATCH 106/147] Attempt to publish testing code coverage --- .gitignore | 1 + ZertoApiWrapper.build.ps1 | 3 ++- azure-pipelines.yml | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 975fb76..2f58130 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ temp/* Tests/Public/TestResults.xml Tests/TestResults.xml publish/* +CodeCoverage.xml diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 9a9ad17..3829e9a 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -66,7 +66,8 @@ task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, CreatePsm1ForRelease, { task FileTests CheckPesterInstalled, { $testResultsFile = "$BuildRoot\Tests\TestResults.xml" - $script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru + $codeCoverageFile = "$BuildRoot\Tests\CoverageResults.xml" + $script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru -CodeCoverage "$BuildRoot\Public\*" -CodeCoverageOutputFile $codeCoverageFile $FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount assert ($results.FailedCount -eq 0) $FailureMessage } diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a756f57..bdcb7fa 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -39,6 +39,10 @@ jobs: testRunTitle: 'PS_Win2016' displayName: 'Publish Test Results' condition: always() + - task: PublishCodeCoverageResults@1 + inputs: + codeCoverageTool: 'JaCoCo' + summaryFileLocation: '**/CoverageResults.xml' # Linux Build Job - job: Build_PSCore_Ubuntu1604 From 4658b6b34a6ac264eb81e39adf1190f708118ad2 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 15:03:30 -0400 Subject: [PATCH 107/147] Fix YAML Spacing --- azure-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index bdcb7fa..21fe54f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -40,9 +40,9 @@ jobs: displayName: 'Publish Test Results' condition: always() - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: 'JaCoCo' - summaryFileLocation: '**/CoverageResults.xml' + inputs: + codeCoverageTool: 'JaCoCo' + summaryFileLocation: '**/CoverageResults.xml' # Linux Build Job - job: Build_PSCore_Ubuntu1604 From cb1774423154c3817442cb91d9b50bd24c307c6d Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 15:06:03 -0400 Subject: [PATCH 108/147] Fix CodeCoveragePath --- ZertoApiWrapper.build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 3829e9a..5cfa0fd 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -67,7 +67,7 @@ task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, CreatePsm1ForRelease, { task FileTests CheckPesterInstalled, { $testResultsFile = "$BuildRoot\Tests\TestResults.xml" $codeCoverageFile = "$BuildRoot\Tests\CoverageResults.xml" - $script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru -CodeCoverage "$BuildRoot\Public\*" -CodeCoverageOutputFile $codeCoverageFile + $script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru -CodeCoverage "$BuildRoot\ZertoApiWrapper\Public\*" -CodeCoverageOutputFile $codeCoverageFile $FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount assert ($results.FailedCount -eq 0) $FailureMessage } From 6d86fbea23000a92026509a60212b5f0de31a7fa Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 15:40:09 -0400 Subject: [PATCH 109/147] Remove CodeCoverage --- ZertoApiWrapper.build.ps1 | 3 +-- azure-pipelines.yml | 4 ---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/ZertoApiWrapper.build.ps1 b/ZertoApiWrapper.build.ps1 index 5cfa0fd..9a9ad17 100644 --- a/ZertoApiWrapper.build.ps1 +++ b/ZertoApiWrapper.build.ps1 @@ -66,8 +66,7 @@ task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, CreatePsm1ForRelease, { task FileTests CheckPesterInstalled, { $testResultsFile = "$BuildRoot\Tests\TestResults.xml" - $codeCoverageFile = "$BuildRoot\Tests\CoverageResults.xml" - $script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru -CodeCoverage "$BuildRoot\ZertoApiWrapper\Public\*" -CodeCoverageOutputFile $codeCoverageFile + $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 } diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 21fe54f..a756f57 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -39,10 +39,6 @@ jobs: testRunTitle: 'PS_Win2016' displayName: 'Publish Test Results' condition: always() - - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: 'JaCoCo' - summaryFileLocation: '**/CoverageResults.xml' # Linux Build Job - job: Build_PSCore_Ubuntu1604 From 2a8837aff736d1cc3d1dac1d48a10e307c4288ed Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 17:16:37 -0400 Subject: [PATCH 110/147] Add parameter tests --- Tests/Public/Invoke-ZertoFailover.Tests.ps1 | 60 ++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/Tests/Public/Invoke-ZertoFailover.Tests.ps1 b/Tests/Public/Invoke-ZertoFailover.Tests.ps1 index 50d2f9d..8582291 100644 --- a/Tests/Public/Invoke-ZertoFailover.Tests.ps1 +++ b/Tests/Public/Invoke-ZertoFailover.Tests.ps1 @@ -16,4 +16,62 @@ Describe $file.BaseName -Tag 'Unit' { $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$($file.BaseName)::Parameter Unit Tests" { + it "has a mandatory string parameter for the vpgName" { + Get-Command $file.BaseName | Should -HaveParameter vpgName + Get-Command $file.BaseName | Should -HaveParameter vpgName -Type string + Get-Command $file.BaseName | Should -HaveParameter vpgName -Mandatory + } + + it "has a non-mandatory string parameter for the checkpoint" { + Get-Command $file.BaseName | Should -HaveParameter checkpointIdentifier + Get-Command $file.BaseName | Should -HaveParameter checkpointIdentifier -Type string + Get-Command $file.BaseName | Should -HaveParameter checkpointIdentifier -Not -Mandatory + } + + it "has a non-mandatory string parameter for the commit policy" { + Get-Command $file.BaseName | Should -HaveParameter commitPolicy + Get-Command $file.BaseName | Should -HaveParameter commitPolicy -Type string + Get-Command $file.BaseName | Should -HaveParameter commitPolicy -Not -Mandatory + Get-Command $file.BaseName | Should -HaveParameter commitPolicy -DefaultValue "Rollback" + } + + it "has a non-mandatory int parameter for the shutdown policy" { + Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy + Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy -Type int + Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy -Not -Mandatory + Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy -DefaultValue 0 + } + + it "has a non-mandatory int parameter for the time to wait before force shutdown" { + Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec + Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec -Type int + Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec -Not -Mandatory + Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec -DefaultValue 3600 + } + + it "has a non-mandatory bool parameter for the reverse protection policy" { + Get-Command $file.BaseName | Should -HaveParameter reverseProtection + Get-Command $file.BaseName | Should -HaveParameter reverseProtection -Type bool + Get-Command $file.BaseName | Should -HaveParameter reverseProtection -Not -Mandatory + } + + it "has a non-mandatory array string parameter for the named VMs to be failed over" { + Get-Command $file.BaseName | Should -HaveParameter vmName + Get-Command $file.BaseName | Should -HaveParameter vmName -Type string[] + Get-Command $file.BaseName | Should -HaveParameter vmName -Not -Mandatory + } + + it "Supports 'SupportsShouldProcess'" { + Get-Command $file.BaseName | Should -HaveParameter WhatIf + Get-Command $file.BaseName | Should -HaveParameter Confirm + $file | Should -FileContentMatch 'SupportsShouldProcess' + $file | Should -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)' + } + } + + Context "$($file.BaseName)::Function Unit Tests" { + #TODO + } +} From 5533bae319f7921c87c68b3ff6449844c943d0c2 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 17:18:56 -0400 Subject: [PATCH 111/147] Various fixes Removed Commit Value as it is not a vaild param Enabled ShouldProcess Ensured mandatory default values make it into the body Added Validate a valid VPG is selected. --- .../Public/Invoke-ZertoFailover.ps1 | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 index 75f70cc..9665b6e 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 @@ -1,16 +1,18 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Invoke-ZertoFailover { - [cmdletbinding()] + [cmdletbinding( SupportsShouldProcess = $true )] param( [Parameter( Mandatory = $true, HelpMessage = "Name of the VPG to Failover" )] + [ValidateNotNullOrEmpty()] [string]$vpgName, [Parameter( HelpMessage = "Checkpoint Identifier to use as the Point-In-Time to rollback to." )] [Alias("checkpointId")] + [ValidateNotNullOrEmpty()] [string]$checkpointIdentifier, [Parameter( HelpMessage = "'Rollback': After the seconds specified in the commitValue setting have elapsed, the failover is rolled back. @@ -19,11 +21,7 @@ function Invoke-ZertoFailover { Default is the Site Settings setting." )] [ValidateSet("Rollback", "Commit", "None")] - [string]$commitPolicy, - [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, + [string]$commitPolicy = "Rollback", [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. @@ -32,9 +30,9 @@ function Invoke-ZertoFailover { [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, + [int]$timeToWaitBeforeShutdownInSec = 3600, [Parameter( HelpMessage = "True: Enable reverse protection. The virtual machines are recovered on the recovery site and then protected using the default reverse protection settings. False: Do not enable reverse protection. The VPG definition is kept with the status Needs Configuration and the reverse settings in the VPG definition are not set." @@ -43,15 +41,23 @@ function Invoke-ZertoFailover { [Parameter( HelpMessage = "Name(s) of VMs in the VPG to failover" )] + [ValidateNotNullOrEmpty()] [string[]]$vmName ) begin { - $vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier - $baseUri = "vpgSettings/{0}/failover" -f $vpgId + $vpgId = $(Get-ZertoVpg -name $vpgName).vpgIdentifier + if ( -not $vpgId) { + Write-Error "VPG: $vpgName Not Found. Please check the name and try again!" + break + } + $baseUri = "vpgs/{0}/failover" -f $vpgId $body = [ordered]@{} + # Setup Defaults + $body['commitpolicy'] = $commitPolicy + $body['TimeToWaitBeforeShutdownInSec'] = $timeToWaitBeforeShutdownInSec foreach ($key in $PSBoundParameters.Keys) { - if ($key -notlike 'vpgGroup' -or $key -notlike 'vmName') { + if ($key -notlike 'vpgName' -and $key -notlike 'vmName' -and $key -notlike 'WhatIf' -and $key -notlike 'TimeToWaitBeforeShutdownInSec' -and $key -notlike 'commitpolicy') { $body[$key] = $PSBoundParameters['key'] } } @@ -65,7 +71,10 @@ function Invoke-ZertoFailover { } 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 { From b242b5314d5406842f183685eb1deaec2472dc5d Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 17:52:57 -0400 Subject: [PATCH 112/147] Update Invoke-ZertoFailover.ps1 Working on vmName Validation --- ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 index 9665b6e..ac97b01 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 @@ -48,8 +48,11 @@ function Invoke-ZertoFailover { begin { $vpgId = $(Get-ZertoVpg -name $vpgName).vpgIdentifier if ( -not $vpgId) { - Write-Error "VPG: $vpgName Not Found. Please check the name and try again!" - break + Write-Error "VPG: $vpgName Not Found. Please check the name and try again!" -ErrorAction Stop + } + $uniqueVmNames = $vmName | Select-Object -Unique + if ($uniqueVmNames.Count -ne $vmName.Count) { + Write-Error "The VM names you submitted contains a duplicate. Please check the values you submitted and try again. VALUES: $vmName" -ErrorAction Stop } $baseUri = "vpgs/{0}/failover" -f $vpgId $body = [ordered]@{} @@ -62,9 +65,13 @@ function Invoke-ZertoFailover { } } if ($PSBoundParameters.ContainsKey('vmName')) { - $vmIdentifiers = @() + [array]$vmIdentifiers = @() $vmIdentifiers = foreach ( $name in $vmName ) { - $(Get-ZertoProtectedVm -vmName $name).vmIdentifier + $result = $(Get-ZertoProtectedVm -vmName $name -vpgName $vpgName).vmIdentifier + if ($null -eq $result) { + Write-Error "VM: $name NOT found in VPG: $vpgName. Please check the names and try again." -ErrorAction Stop + } + $result } $body['VmIdentifiers'] = $vmIdentifiers } From e279ba0cdaa3bc0d7aae6aa3eafe3299025ea102 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 19:19:56 -0400 Subject: [PATCH 113/147] Add VmName validation and uniquiness checks --- .../Public/Invoke-ZertoFailover.ps1 | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 index ac97b01..bc8aae6 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 @@ -50,10 +50,6 @@ function Invoke-ZertoFailover { if ( -not $vpgId) { Write-Error "VPG: $vpgName Not Found. Please check the name and try again!" -ErrorAction Stop } - $uniqueVmNames = $vmName | Select-Object -Unique - if ($uniqueVmNames.Count -ne $vmName.Count) { - Write-Error "The VM names you submitted contains a duplicate. Please check the values you submitted and try again. VALUES: $vmName" -ErrorAction Stop - } $baseUri = "vpgs/{0}/failover" -f $vpgId $body = [ordered]@{} # Setup Defaults @@ -65,13 +61,17 @@ function Invoke-ZertoFailover { } } if ($PSBoundParameters.ContainsKey('vmName')) { - [array]$vmIdentifiers = @() - $vmIdentifiers = foreach ( $name in $vmName ) { - $result = $(Get-ZertoProtectedVm -vmName $name -vpgName $vpgName).vmIdentifier - if ($null -eq $result) { - Write-Error "VM: $name NOT found in VPG: $vpgName. Please check the names and try again." -ErrorAction Stop + $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 } - $result } $body['VmIdentifiers'] = $vmIdentifiers } From 5bf7d0d6df1b8ffd304327c76c3b3a3e3561bdf0 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Fri, 5 Apr 2019 22:49:36 -0400 Subject: [PATCH 114/147] Validate identifiers are present --- ZertoApiWrapper/Public/Edit-ZertoVra.ps1 | 3 ++ .../Public/Invoke-ZertoFailover.ps1 | 1 + .../Public/Invoke-ZertoFailoverCommit.ps1 | 8 +++-- .../Public/Invoke-ZertoFailoverRollback.ps1 | 8 +++-- .../Public/Invoke-ZertoForceSync.ps1 | 8 +++-- ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 | 9 +++-- .../Public/Invoke-ZertoMoveCommit.ps1 | 8 +++-- .../Public/Invoke-ZertoMoveRollback.ps1 | 8 +++-- ZertoApiWrapper/Public/New-ZertoVpg.ps1 | 3 +- .../Public/New-ZertoVpgSettingsIdentifier.ps1 | 3 +- ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 | 2 +- ZertoApiWrapper/Public/Resume-ZertoVpg.ps1 | 8 +++-- .../Public/Start-ZertoCloneVpg.ps1 | 25 ++++++++++--- .../Public/Start-ZertoFailoverTest.ps1 | 36 ++++++++++--------- ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 | 3 ++ .../Public/Stop-ZertoFailoverTest.ps1 | 5 ++- ZertoApiWrapper/Public/Suspend-ZertoVpg.ps1 | 8 +++-- ZertoApiWrapper/Public/Uninstall-ZertoVra.ps1 | 8 +++-- 18 files changed, 109 insertions(+), 45 deletions(-) diff --git a/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 b/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 index 0b5ef84..acf1693 100644 --- a/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Edit-ZertoVra.ps1 @@ -38,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 { diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 index bc8aae6..f266a8a 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 @@ -2,6 +2,7 @@ function Invoke-ZertoFailover { [cmdletbinding( SupportsShouldProcess = $true )] param( + #TODO - Refactor? [Parameter( Mandatory = $true, HelpMessage = "Name of the VPG to Failover" diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 index 05f40b5..5d87c56 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 @@ -25,8 +25,12 @@ function Invoke-ZertoFailoverCommit { process { foreach ($name in $vpgName) { $vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier - $uri = "{0}/{1}/FailoverCommit" -f $baseUri, $vpgId - Invoke-ZertoRestRequest -uri $uri -body $($body | convertto-json) -method "POST" + if ( -not $vpgId ) { + Write-Error "VPG: $name could not be found. Please check the name and try again. Skipping." + } else { + $uri = "{0}/{1}/FailoverCommit" -f $baseUri, $vpgId + Invoke-ZertoRestRequest -uri $uri -body $($body | convertto-json) -method "POST" + } } } diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailoverRollback.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailoverRollback.ps1 index e6bc6cb..7ff5c3d 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailoverRollback.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailoverRollback.ps1 @@ -16,8 +16,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..2e75c96 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoForceSync.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoForceSync.ps1 @@ -16,8 +16,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 1007b5d..7166225 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 @@ -49,6 +49,7 @@ function Invoke-ZertoMove { 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 } @@ -72,8 +73,12 @@ function Invoke-ZertoMove { 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 + Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) + } } } diff --git a/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 index eedb889..59ee712 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 @@ -29,8 +29,12 @@ function Invoke-ZertoMoveCommit { 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 + Invoke-ZertoRestRequest -uri $uri -body $($body | convertto-json) -method "POST" + } } } diff --git a/ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 index d51ecc5..d3c11ff 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 @@ -16,8 +16,12 @@ 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 + Invoke-ZertoRestRequest -uri $uri -method "POST" + } } } diff --git a/ZertoApiWrapper/Public/New-ZertoVpg.ps1 b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 index 48c96b3..21ea609 100644 --- a/ZertoApiWrapper/Public/New-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 @@ -241,8 +241,7 @@ function New-ZertoVpg { } if ( -not $validSettings ) { - Write-Error "One or more parameters passed do not have valid identifiers or 0 valid VMs were found. Please check your settings and try again." - Break + Write-Error "One or more parameters passed do not have valid identifiers or 0 valid VMs were found. Please check your settings and try again." -ErrorAction Stop } } diff --git a/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 b/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 index 9925d30..cd52e5b 100644 --- a/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 +++ b/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 @@ -36,10 +36,9 @@ function New-ZertoVpgSettingsIdentifier { if ($PSCmdlet.ShouldProcess("Creating VPG Settings Object")) { Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST" } - } end { - + #Nothing to do } } diff --git a/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 index b3cedcf..8aafb91 100644 --- a/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 @@ -55,7 +55,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..e258d0c 100644 --- a/ZertoApiWrapper/Public/Resume-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Resume-ZertoVpg.ps1 @@ -16,8 +16,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/Start-ZertoCloneVpg.ps1 b/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 index 03a9677..adf82ff 100644 --- a/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 +++ b/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 @@ -24,18 +24,35 @@ function Start-ZertoCloneVpg { 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 } } } diff --git a/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 b/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 index 51d1e38..6d5ecc5 100644 --- a/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 +++ b/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 @@ -21,32 +21,34 @@ function Start-ZertoFailoverTest { 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 ( $PSBoundParameters.ContainsKey('vmName') ) { - $vmIdentifiers = @() - $vmIdentifiers = foreach ( $name in $vmName ) { - $(Get-ZertoProtectedVm -vmName $name).vmIdentifier - } - $body['VmIdentifiers'] = $vmIdentifiers - } - if ($PSCmdlet.ShouldProcess("Starting Failover Test")) { + if ($PSCmdlet.ShouldProcess($vpgName)) { 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 72e09f4..746238e 100644 --- a/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 +++ b/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 @@ -12,6 +12,9 @@ function Stop-ZertoCloneVpg { 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 { diff --git a/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 b/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 index c8c63c9..add6b89 100644 --- a/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 +++ b/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 @@ -6,6 +6,7 @@ function Stop-ZertoFailoverTest { 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." @@ -25,11 +26,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 if ($PSCmdlet.ShouldProcess("Stopping Failover Test")) { 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..68e8bee 100644 --- a/ZertoApiWrapper/Public/Suspend-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Suspend-ZertoVpg.ps1 @@ -16,8 +16,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..31496ff 100644 --- a/ZertoApiWrapper/Public/Uninstall-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Uninstall-ZertoVra.ps1 @@ -17,8 +17,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 } From d6d72a5be2cd6960629f0ea1e42af00af1dd4812 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sat, 6 Apr 2019 22:49:41 -0400 Subject: [PATCH 115/147] Update ways params are accessed for dynamic body creation --- ZertoApiWrapper/Public/Get-ZertoVpg.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 index b3d686a..ac7d614 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 @@ -173,9 +173,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 From b3d649e495241a2333368742cadd6beb3c6e1b3c Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sat, 6 Apr 2019 22:49:54 -0400 Subject: [PATCH 116/147] Dynamic Body Creation --- ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 index f266a8a..0428388 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 @@ -56,9 +56,9 @@ function Invoke-ZertoFailover { # Setup Defaults $body['commitpolicy'] = $commitPolicy $body['TimeToWaitBeforeShutdownInSec'] = $timeToWaitBeforeShutdownInSec - foreach ($key in $PSBoundParameters.Keys) { - if ($key -notlike 'vpgName' -and $key -notlike 'vmName' -and $key -notlike 'WhatIf' -and $key -notlike 'TimeToWaitBeforeShutdownInSec' -and $key -notlike 'commitpolicy') { - $body[$key] = $PSBoundParameters['key'] + foreach ($param in $PSBoundParameters.GetEnumerator()) { + if ($param.key -notlike 'vpgName' -and $param.key -notlike 'vmName' -and $param.key -notlike 'WhatIf' -and $param.key -notlike 'TimeToWaitBeforeShutdownInSec' -and $param.key -notlike 'commitpolicy') { + $body[$param.key] = $param.value } } if ($PSBoundParameters.ContainsKey('vmName')) { From 31db21c325c8b51963d21a5dbacc5b2ba3b91ba2 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sat, 6 Apr 2019 22:51:03 -0400 Subject: [PATCH 117/147] Update Invoke-ZertoMove.ps1 WhatIf Processing Reverse Protection Logic Ensure Params are set and do not rely on defaults --- ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 | 64 ++++++++++++--------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 index 7166225..2251def 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 @@ -1,11 +1,12 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Invoke-ZertoMove { - [CmdletBinding()] + [CmdletBinding( DefaultParameterSetName = "main", SupportsShouldProcess = $true )] param( [Parameter( HelpMessage = "Name(s) of the VPG(s) you want to move.", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string[]]$vpgName, [Parameter( HelpMessage = "'Rollback': After the seconds specified in the commitValue setting have elapsed, the failover is rolled back. @@ -20,30 +21,23 @@ function Invoke-ZertoMove { )] [Int32]$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." )] - [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." )] - [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 { @@ -57,16 +51,30 @@ 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 + } } } @@ -77,7 +85,9 @@ function Invoke-ZertoMove { Write-Error "VPG: $name not found. Please check the name and try again. Skipping" } else { $uri = "{0}/{1}/move" -f $baseUri, $vpgId - Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) + if ($PSCmdlet.ShouldProcess("Moving VPG: $name wiht settings: $($body | convertto-json)")) { + Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) + } } } } From b5b873ac1848ea1005338e9c8e8f69fd7e8f8550 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sat, 6 Apr 2019 22:51:38 -0400 Subject: [PATCH 118/147] Correct Param to match API Spec --- ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 index 5d87c56..37db864 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 @@ -10,15 +10,15 @@ function Invoke-ZertoFailoverCommit { [Parameter( HelpMessage = "Use this switch to reverse protect the VPG(s) to the source site." )] - [switch]$reverseProtect + [switch]$reverseProtection ) begin { $baseUri = "vpgs" - if ( $reverseProtect ) { - $body = @{"IsReverseProtect" = $true} + if ( $reverseProtection ) { + $body = @{"IsReverseProtection" = $true} } else { - $body = @{"IsReverseProtect" = $false} + $body = @{"IsReverseProtection" = $false} } } From ee2acca20cd2f6f1d19ab6359b5d375cebda3c1d Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sat, 6 Apr 2019 23:31:26 -0400 Subject: [PATCH 119/147] Add mandatory params --- ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 index 2251def..66d61f9 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoMove.ps1 @@ -26,12 +26,14 @@ function Invoke-ZertoMove { [switch]$forceShutdown, [Parameter( 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." + 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 )] [switch]$disableReverseProtection, [Parameter( ParameterSetName = "keepSourceVms", - HelpMessage = "Prevent the protected virtual machines from being deleted in the protected site. Using this setting disables reverse protection." + HelpMessage = "Prevent the protected virtual machines from being deleted in the protected site. Using this setting disables reverse protection.", + Mandatory = $true )] [switch]$keepSourceVms, [Parameter( From ef22b6363dca5e78366f706049b2cd16e71182b8 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sat, 6 Apr 2019 23:31:51 -0400 Subject: [PATCH 120/147] Add ShouldProcess support --- ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 index d3c11ff..0450175 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoMoveRollback.ps1 @@ -1,6 +1,6 @@ <# .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", @@ -20,7 +20,9 @@ function Invoke-ZertoMoveRollback { Write-Error "VPG: $name not found. Please check the name and try again." } else { $uri = "{0}/{1}/moveRollBack" -f $baseUri, $id - Invoke-ZertoRestRequest -uri $uri -method "POST" + if ($PSCmdlet.ShouldProcess("Rolling back VPG: $name")) { + Invoke-ZertoRestRequest -uri $uri -method "POST" + } } } } From 497d43fe812e71808c6d5ded4bb4f8d55276f9af Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sat, 6 Apr 2019 23:32:08 -0400 Subject: [PATCH 121/147] Remove excess white space --- ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 index 0428388..cf1431d 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 @@ -82,7 +82,6 @@ function Invoke-ZertoFailover { if ($PSCmdlet.ShouldProcess("$vpgName with identifier $vpgId and these options $($body | convertto-json)")) { Invoke-ZertoRestRequest -uri $baseUri -body $($body | ConvertTo-Json) -method "POST" } - } end { From 8c9babd9d56ae22c855b1c36fc98599986b01f88 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sat, 6 Apr 2019 23:33:14 -0400 Subject: [PATCH 122/147] Update Invoke-ZertoMoveCommit.ps1 Add ShouldProcess Use switches instead of bools Prioritize Reverse Protect over KeepSourceVms --- .../Public/Invoke-ZertoMoveCommit.ps1 | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 index 59ee712..4c229a4 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoMoveCommit.ps1 @@ -1,6 +1,6 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Invoke-ZertoMoveCommit { - [cmdletbinding()] + [cmdletbinding(SupportsShouldProcess = $true)] param( [Parameter( HelpMessage = "Name(s) of the VPG(s) to commit.", @@ -10,7 +10,7 @@ function Invoke-ZertoMoveCommit { [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,10 +19,11 @@ 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 } } @@ -33,7 +34,9 @@ function Invoke-ZertoMoveCommit { Write-Error "VPG: $name not found. Please check the name and try again. Skipping." } else { $uri = "{0}/{1}/MoveCommit" -f $baseUri, $vpgId - Invoke-ZertoRestRequest -uri $uri -body $($body | convertto-json) -method "POST" + if ($PSCmdlet.ShouldProcess("Commiting VPG: $name with settings $($body | convertto-json)")) { + Invoke-ZertoRestRequest -uri $uri -body $($body | convertto-json) -method "POST" + } } } } From ec9eda9dcda74924c690f2ebabdfcbc173f57015 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sat, 6 Apr 2019 23:42:29 -0400 Subject: [PATCH 123/147] Update Export-ZertoVpg.md --- docs/Export-ZertoVpg.md | 210 ++++++++++++++++++++-------------------- 1 file changed, 105 insertions(+), 105 deletions(-) diff --git a/docs/Export-ZertoVpg.md b/docs/Export-ZertoVpg.md index 9bd5be3..1c0d9f8 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#) From 7c3f14aaeb47592dcc5718be43a92ecc16de8c53 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sat, 6 Apr 2019 23:48:32 -0400 Subject: [PATCH 124/147] Update Invoke-ZertoFailoverCommit.md --- docs/Invoke-ZertoFailoverCommit.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/Invoke-ZertoFailoverCommit.md b/docs/Invoke-ZertoFailoverCommit.md index afdaa91..b1abfa4 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 From b9d781f785395bcbdb95e2c4c7c3d407694ef6d9 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sat, 6 Apr 2019 23:49:18 -0400 Subject: [PATCH 125/147] Add ShouldProcess --- docs/Invoke-ZertoMoveRollback.md | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/docs/Invoke-ZertoMoveRollback.md b/docs/Invoke-ZertoMoveRollback.md index 40b5501..e7fd776 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,6 +45,36 @@ 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). From ef83cdfe9656856c9b9775227c852d59e939cbcd Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sat, 6 Apr 2019 23:50:53 -0400 Subject: [PATCH 126/147] Add ShouldSupport --- docs/New-ZertoVpg.md | 42 ++++++++++++++++++++++++++++----- docs/Start-ZertoCloneVpg.md | 32 ++++++++++++++++++++++++- docs/Start-ZertoFailoverTest.md | 34 ++++++++++++++++++++++++-- docs/Stop-ZertoCloneVpg.md | 32 ++++++++++++++++++++++++- docs/Stop-ZertoFailoverTest.md | 32 ++++++++++++++++++++++++- 5 files changed, 161 insertions(+), 11 deletions(-) diff --git a/docs/New-ZertoVpg.md b/docs/New-ZertoVpg.md index 73d2536..317c9cb 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,6 +492,36 @@ 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). diff --git a/docs/Start-ZertoCloneVpg.md b/docs/Start-ZertoCloneVpg.md index 467068c..226e97a 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 @@ -94,6 +94,36 @@ 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). diff --git a/docs/Start-ZertoFailoverTest.md b/docs/Start-ZertoFailoverTest.md index c5622da..e2d3c1d 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 @@ -78,6 +78,36 @@ 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). diff --git a/docs/Stop-ZertoCloneVpg.md b/docs/Stop-ZertoCloneVpg.md index f4905c6..65e7ab4 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,6 +45,36 @@ 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). diff --git a/docs/Stop-ZertoFailoverTest.md b/docs/Stop-ZertoFailoverTest.md index 0a499dd..63d9f95 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,6 +78,36 @@ 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). From 0bb5b8c222409f54cd450d184ea302d7f06a39b3 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 7 Apr 2019 09:38:10 -0400 Subject: [PATCH 127/147] Update versions of required modules for builds --- ZertoApiWrapper.Depend.psd1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ZertoApiWrapper.Depend.psd1 b/ZertoApiWrapper.Depend.psd1 index d645015..95b3918 100644 --- a/ZertoApiWrapper.Depend.psd1 +++ b/ZertoApiWrapper.Depend.psd1 @@ -7,7 +7,7 @@ SkipPublisherCheck = $true } Target = 'CurrentUser' - Version = '5.4.3' + Version = '5.5.0' Tags = 'Bootstrap' } @@ -19,7 +19,7 @@ SkipPublisherCheck = $true } Target = 'CurrentUser' - Version = '4.6.0' + Version = '4.7.3' Tags = 'Bootstrap' } @@ -31,7 +31,7 @@ SkipPublisherCheck = $true } Target = 'CurrentUser' - Version = '1.17.1' + Version = '1.18.0' Tags = 'Bootstrap' } @@ -43,7 +43,7 @@ SkipPublisherCheck = $true } Target = 'CurrentUser' - Version = '0.12.0' + Version = '0.14.0' Tags = 'Bootstrap' } } From 5a579d6fe88670d6978a10367b1f62680d998cce Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 15 Apr 2019 09:32:51 -0400 Subject: [PATCH 128/147] Add name to should process --- ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 b/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 index add6b89..7593077 100644 --- a/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 +++ b/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 @@ -30,7 +30,7 @@ function Stop-ZertoFailoverTest { Write-Error "VPG: $vpgName Not Found. Please check the name and try again!" -ErrorAction Stop } $uri = "{0}/{1}/FailoverTestStop" -f $baseUri, $vpgId - if ($PSCmdlet.ShouldProcess("Stopping Failover Test")) { + if ($PSCmdlet.ShouldProcess("Stopping Failover Test on VPG: $name")) { Invoke-ZertoRestRequest -uri $uri -method "POST" -body $($body | ConvertTo-Json) } } From 2e4cd68b5e6bb226b2d227fa481dbcd9bebca3ff Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 15 Apr 2019 17:20:17 -0400 Subject: [PATCH 129/147] Update Body Build Logic --- .../Public/Invoke-ZertoFailover.ps1 | 52 +++++++++++-------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 index cf1431d..5db8223 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailover.ps1 @@ -24,9 +24,9 @@ function Invoke-ZertoFailover { [ValidateSet("Rollback", "Commit", "None")] [string]$commitPolicy = "Rollback", [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, @@ -52,29 +52,39 @@ function Invoke-ZertoFailover { Write-Error "VPG: $vpgName Not Found. Please check the name and try again!" -ErrorAction Stop } $baseUri = "vpgs/{0}/failover" -f $vpgId - $body = [ordered]@{} - # Setup Defaults + $body = @{} + # Setup Required Defaults $body['commitpolicy'] = $commitPolicy $body['TimeToWaitBeforeShutdownInSec'] = $timeToWaitBeforeShutdownInSec - foreach ($param in $PSBoundParameters.GetEnumerator()) { - if ($param.key -notlike 'vpgName' -and $param.key -notlike 'vmName' -and $param.key -notlike 'WhatIf' -and $param.key -notlike 'TimeToWaitBeforeShutdownInSec' -and $param.key -notlike 'commitpolicy') { - $body[$param.key] = $param.value + + Switch ($PSBoundParameters.Keys) { + "checkpointIdentifier" { + $body['checkpointIdentifier'] = $checkpointIdentifier } - } - if ($PSBoundParameters.ContainsKey('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 + + "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 } } From ed225024a6f07664f4edd23b10a921dc9eb3d4d4 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Tue, 16 Apr 2019 16:18:33 -0400 Subject: [PATCH 130/147] 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 ) From 8ec3293ff47b819c71d24b73e5b0a37b7885761e Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Tue, 16 Apr 2019 22:46:21 -0400 Subject: [PATCH 131/147] String Not Null or Empty Validators --- ZertoApiWrapper/Public/Get-ZertoAlert.ps1 | 9 +++++++++ ZertoApiWrapper/Public/Get-ZertoDatastore.ps1 | 1 + ZertoApiWrapper/Public/Get-ZertoEvent.ps1 | 16 ++++++++++++++-- ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 | 5 +++++ ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 | 10 ++++++++++ .../Public/Get-ZertoRecoveryReport.ps1 | 7 +++++++ .../Public/Get-ZertoResourcesReport.ps1 | 17 +++++++++++++++++ .../Public/Get-ZertoServiceProfile.ps1 | 3 +++ ZertoApiWrapper/Public/Get-ZertoTask.ps1 | 6 ++++++ .../Public/Get-ZertoVirtualizationSite.ps1 | 2 ++ ZertoApiWrapper/Public/Get-ZertoVolume.ps1 | 5 +++++ ZertoApiWrapper/Public/Get-ZertoVpg.ps1 | 13 +++++++++++++ ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 | 4 ++++ ZertoApiWrapper/Public/Get-ZertoVra.ps1 | 10 ++++++++++ ZertoApiWrapper/Public/Get-ZertoZorg.ps1 | 1 + ZertoApiWrapper/Public/Get-ZertoZsspSession.ps1 | 1 + ZertoApiWrapper/Public/Install-ZertoVra.ps1 | 1 + ZertoApiWrapper/Public/New-ZertoVpg.ps1 | 15 +++++++++++++++ .../Public/New-ZertoVpgSettingsIdentifier.ps1 | 1 + ZertoApiWrapper/Public/Remove-ZertoPeerSite.ps1 | 2 ++ ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 | 2 ++ ZertoApiWrapper/Public/Resume-ZertoVpg.ps1 | 1 + ZertoApiWrapper/Public/Save-ZertoVpgSetting.ps1 | 1 + ZertoApiWrapper/Public/Set-ZertoAlert.ps1 | 4 ++-- ZertoApiWrapper/Public/Set-ZertoLicense.ps1 | 1 + ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 | 4 ++++ .../Public/Start-ZertoFailoverTest.ps1 | 3 +++ ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 | 1 + .../Public/Stop-ZertoFailoverTest.ps1 | 1 + ZertoApiWrapper/Public/Suspend-ZertoVpg.ps1 | 1 + ZertoApiWrapper/Public/Uninstall-ZertoVra.ps1 | 1 + 31 files changed, 145 insertions(+), 4 deletions(-) diff --git a/ZertoApiWrapper/Public/Get-ZertoAlert.ps1 b/ZertoApiWrapper/Public/Get-ZertoAlert.ps1 index 1375ba5..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,45 +33,53 @@ function Get-ZertoAlert { ParameterSetName = "filter", HelpMessage = "Returns Alerts after the Start Date. Provide the string in the format of 'yyyy-MM-ddTHH:mm:ss.fff'" )] + [ValidateNotNullOrEmpty()] [string]$startDate, [Parameter( ParameterSetName = "filter", HelpMessage = "Returns Alerts before the End Date. Provide the string in the format of 'yyyy-MM-ddTHH:mm:ss.fff'" )] + [ValidateNotNullOrEmpty()] [string]$endDate, [Parameter( ParameterSetName = "filter", HelpMessage = "Returns alerts for the specified vraIdentifier" )] + [ValidateNotNullOrEmpty()] [Alias("vpgId")] [string]$vpgIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "Returns alerts for the specified siteIdentifier" )] + [ValidateNotNullOrEmpty()] [Alias("siteId")] [string]$siteIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "Returns alerts for the specified zorgIdentifier" )] + [ValidateNotNullOrEmpty()] [Alias("zorgId")] [string]$zorgIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "Returns alerts for the specified level" )] + [ValidateNotNullOrEmpty()] [string]$level, [Parameter( ParameterSetName = "filter", HelpMessage = "Returns alerts for the specified helpIdentifier" )] + [ValidateNotNullOrEmpty()] [Alias("helpId")] [string]$helpIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "Returns alerts for the specified entity" )] + [ValidateNotNullOrEmpty()] [string]$entity, [Parameter( ParameterSetName = "filter", diff --git a/ZertoApiWrapper/Public/Get-ZertoDatastore.ps1 b/ZertoApiWrapper/Public/Get-ZertoDatastore.ps1 index 46f10ae..8584e90 100644 --- a/ZertoApiWrapper/Public/Get-ZertoDatastore.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoDatastore.ps1 @@ -7,6 +7,7 @@ function Get-ZertoDatastore { 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 c87cab7..1c45ee8 100644 --- a/ZertoApiWrapper/Public/Get-ZertoEvent.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoEvent.ps1 @@ -6,43 +6,51 @@ function Get-ZertoEvent { ParameterSetName = "filter", HelpMessage = "The starting date for the list of events, supplied as a date with the format of the Zerto Virtual Manager where the API runs, for example, yyyy-MM-dd. You can also specify a local time with the following format: yyyy-MM-ddTHH:mm:ss.fffZ. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$startDate, [Parameter( ParameterSetName = "filter", HelpMessage = "The end date for the list, supplied as a date with the format of the Zerto Virtual Manager where the API runs, for example, yyyy-MM-dd. You can also specify a local time with the following format: yyyy-MM-ddTHH:mm:ss.fffZ. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$endDate, [Parameter( ParameterSetName = "filter", HelpMessage = "The name of the VPG for which you want to return events." )] + [ValidateNotNullOrEmpty()] [Alias("vpgName")] [string]$vpg, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the VPG for which you want to return events." )] + [ValidateNotNullOrEmpty()] [Alias("vpgId")] [string]$vpgIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The type of event. For the description of events, refer to the Zerto Virtual Replication documentation about alerts and events. Please see Zerto API Documentation for possible values." )] + [ValidateNotNullOrEmpty()] [string]$eventType, [Parameter( ParameterSetName = "filter", HelpMessage = "The name of the site for which you want to return events." )] + [ValidateNotNullOrEmpty()] [string]$siteName, [Parameter( ParameterSetName = "filter", HelpMessage = "The internal site identifier for which you want to return events." )] + [ValidateNotNullOrEmpty()] [Alias("siteId")] [string]$siteIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the ZORG, Zerto organization, defined in the Zerto Cloud Manager for which you want to return results." )] + [ValidateNotNullOrEmpty()] [Alias("zorgId")] [string]$zorgIdentifier, [Parameter( @@ -55,12 +63,13 @@ function Get-ZertoEvent { ParameterSetName = "filter", HelpMessage = "The name of the user for which the event occurred. If the event occurred as a result of a task started by the Zerto Virtual Manager, for example, when moving a VPG before the commit stage, the user is System." )] + [ValidateNotNullOrEmpty()] [string]$userName, [Parameter( ParameterSetName = "filter", HelpMessage = "The type of event to return. This filter behaves in the same way as the eventCategory filter. Possible Values are: Possible Values are: 'All', 'Events', 'Alerts'" )] - + [ValidateNotNullOrEmpty()] [string]$category, [Parameter( ParameterSetName = "filter", @@ -72,6 +81,7 @@ function Get-ZertoEvent { ParameterSetName = "filter", HelpMessage = "The internal alert identifier for the Event" )] + [ValidateNotNullOrEmpty()] [Alias("alertId")] [string]$alertIdentifier, [Parameter( @@ -79,7 +89,9 @@ function Get-ZertoEvent { Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, - HelpMessage = "The identifier or identifiers of the event for which information is returned.")] + HelpMessage = "The identifier or identifiers of the event for which information is returned." + )] + [ValidateNotNullOrEmpty()] [string[]]$eventId, [Parameter( ParameterSetName = "categories", diff --git a/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 b/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 index 1b8b4f2..8f64673 100644 --- a/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoPeerSite.ps1 @@ -15,6 +15,7 @@ function Get-ZertoPeerSite { ValueFromPipelineByPropertyName = $true, HelpMessage = "The identifier(s) of the peer site(s) for which information is to be returned." )] + [ValidateNotNullOrEmpty()] [Alias("siteId")] [string[]]$siteIdentifier, [Parameter( @@ -26,21 +27,25 @@ function Get-ZertoPeerSite { ParameterSetName = "filter", HelpMessage = "The pairing status for which information is to be returned." )] + [ValidateNotNullOrEmpty()] [string]$paringStatus, [Parameter ( ParameterSetName = "filter", HelpMessage = "The site location, as specified in the site information, for which information is to be returned." )] + [ValidateNotNullOrEmpty()] [string]$location, [Parameter ( ParameterSetName = "filter", HelpMessage = "The IP address of a Zerto Virtual Manager, paired with this site, for which information is to be returned." )] + [ValidateNotNullOrEmpty()] [string]$hostName, [Parameter ( ParameterSetName = "filter", HelpMessage = "The port used to access peer sites for which information is to be returned. The default port is 9081." )] + [ValidateNotNullOrEmpty()] [string]$port ) diff --git a/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 b/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 index 9dc58ae..36dc2aa 100644 --- a/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoProtectedVm.ps1 @@ -9,32 +9,38 @@ function Get-ZertoProtectedVm { ValueFromPipelineByPropertyName = $true, HelpMessage = "vmIdentifier(s) for which to return information" )] + [ValidateNotNullOrEmpty()] [Alias("vmId")] [string[]]$vmIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The name of the VPG which protects the virtual machine." )] + [ValidateNotNullOrEmpty()] [string]$vpgName, [Parameter( ParameterSetName = "filter", HelpMessage = "The name of the virtual machine." )] + [ValidateNotNullOrEmpty()] [string]$vmName, [Parameter( ParameterSetName = "filter", HelpMessage = "The status of the VPG. Please see Zerto API documentation for possible values." )] + [ValidateNotNullOrEmpty()] [string]$status, [Parameter( ParameterSetName = "filter", HelpMessage = "The substatus of the VPG, for example the VPG is in a bitmap sync. For the description of substatuses, refer to the Zerto Virtual Manager Administration Guide. Please see Zerto API documentation for possible values." )] + [ValidateNotNullOrEmpty()] [string]$substatus, [Parameter( ParameterSetName = "filter", HelpMessage = "The ZORG for this VPG." )] + [ValidateNotNullOrEmpty()] [string]$organizationName, [Parameter( ParameterSetName = "filter", @@ -46,22 +52,26 @@ function Get-ZertoProtectedVm { ParameterSetName = "filter", HelpMessage = "The protected site type. Please see Zerto API documentation for possible values." )] + [ValidateNotNullOrEmpty()] [string]$protectedSiteType, [Parameter( ParameterSetName = "filter", HelpMessage = "The recovery site type. Please see Zerto API documentation for possible values." )] + [ValidateNotNullOrEmpty()] [string]$recoverySiteType, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the protected site where the VPG virtual machines are protected." )] + [ValidateNotNullOrEmpty()] [Alias("protectedSiteId")] [string]$protectedSiteIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the recovery site where the VPG virtual machines are recovered." )] + [ValidateNotNullOrEmpty()] [Alias("recoverySiteId")] [string]$recoverySiteIdentifier ) diff --git a/ZertoApiWrapper/Public/Get-ZertoRecoveryReport.ps1 b/ZertoApiWrapper/Public/Get-ZertoRecoveryReport.ps1 index 1e4997e..c15ba9c 100644 --- a/ZertoApiWrapper/Public/Get-ZertoRecoveryReport.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoRecoveryReport.ps1 @@ -6,31 +6,37 @@ function Get-ZertoRecoveryReport { ParameterSetName = "filter", HelpMessage = "Operations performed between the specified start Time and end Time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$startTime, [Parameter( ParameterSetName = "filter", HelpMessage = "Operations performed between the specified start Time and end Time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$endTime, [Parameter( ParameterSetName = "filter", HelpMessage = "The page number the user wants to retrieve. Minimum value is 1." )] + [ValidateNotNullOrEmpty()] [string]$pageNumber, [Parameter( ParameterSetName = "filter", HelpMessage = "The number of reports to display in a single page. The maximum number of reports per page is 1000." )] + [ValidateNotNullOrEmpty()] [string]$pageSize, [Parameter( ParameterSetName = "filter", HelpMessage = "The internal identifier of the VPG. You can specify more than one VPG, separated by commas." )] + [ValidateNotNullOrEmpty()] [string]$vpgIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The name of the VPG. You can specify more than one VPG, separated by commas." )] + [ValidateNotNullOrEmpty()] [string]$vpgName, [Parameter( ParameterSetName = "filter", @@ -42,6 +48,7 @@ function Get-ZertoRecoveryReport { ParameterSetName = "filter", HelpMessage = "Whether the recovery operation has completed." )] + [ValidateNotNullOrEmpty()] [string]$state ) 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 4081a9d..76a5e2e 100644 --- a/ZertoApiWrapper/Public/Get-ZertoServiceProfile.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoServiceProfile.ps1 @@ -6,12 +6,15 @@ function Get-ZertoServiceProfile { ParameterSetName = "siteIdentifier", HelpMessage = "The identifier of the site for which service profiles should be returned." )] + [ValidateNotNullOrEmpty()] [Alias("siteId")] [string]$siteIdentifier, [Parameter( ParameterSetName = "serviceProfileId", HelpMessage = "The service profile ID for which information should be returned." )] + [ValidateNotNullOrEmpty()] + [Alias("serviceProfileIdentifier")] [string[]]$serviceProfileId ) diff --git a/ZertoApiWrapper/Public/Get-ZertoTask.ps1 b/ZertoApiWrapper/Public/Get-ZertoTask.ps1 index fb670bc..d8f1537 100644 --- a/ZertoApiWrapper/Public/Get-ZertoTask.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoTask.ps1 @@ -6,6 +6,7 @@ function Get-ZertoTask { ParameterSetName = "taskIdentifier", HelpMessage = "The identifier(s) for which task information is to be returned." )] + [ValidateNotNullOrEmpty()] [Alias("taskId")] [string[]]$taskIdentifier, [Parameter( @@ -17,26 +18,31 @@ function Get-ZertoTask { ParameterSetName = "filter", HelpMessage = "Tasks started before this time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$startedBeforeDate, [Parameter( ParameterSetName = "filter", HelpMessage = "Tasks started after this time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$startedAfterDate, [Parameter( ParameterSetName = "filter", HelpMessage = "Tasks completed after this time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$completedAfterDate, [Parameter( ParameterSetName = "filter", HelpMessage = "Tasks completed before this time (inclusive) are displayed. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$completedBeforeDate, [Parameter( ParameterSetName = "filter", HelpMessage = "The type of task. For the description of the tasks, refer to the Zerto Virtual Replication documentation about monitoring tasks. Please see Zerto API Documentation for possible types and values." )] + [ValidateNotNullOrEmpty()] [string]$type, [Parameter( ParameterSetName = "filter", diff --git a/ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 b/ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 index a7e4e01..e296887 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVirtualizationSite.ps1 @@ -52,6 +52,7 @@ function Get-ZertoVirtualizationSite { Mandatory = $true, HelpMessage = "The identifier of the Zerto Virtual Manager site." )] + [ValidateNotNullOrEmpty()] [Alias("siteId")] [string]$siteIdentifier, [Parameter( @@ -82,6 +83,7 @@ function Get-ZertoVirtualizationSite { Mandatory = $false, HelpMessage = "The identifier of the host at the selected site to return information for only one host." )] + [ValidateNotNullOrEmpty()] [Alias("hostId")] [string]$hostIdentifier, [Parameter( diff --git a/ZertoApiWrapper/Public/Get-ZertoVolume.ps1 b/ZertoApiWrapper/Public/Get-ZertoVolume.ps1 index 6f44002..dee5130 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVolume.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVolume.ps1 @@ -6,29 +6,34 @@ function Get-ZertoVolume { ParameterSetName = "filter", HelpMessage = "The type of volume. Please see Zerto API Documentation for possible values." )] + [ValidateNotNullOrEmpty()] [string]$volumeType, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the VPG." )] + [ValidateNotNullOrEmpty()] [Alias("vpgId")] [string]$vpgIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the datastore." )] + [ValidateNotNullOrEmpty()] [Alias("datastoreId", "dsId")] [string]$datastoreIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the protected virtual machine." )] + [ValidateNotNullOrEmpty()] [Alias("protectedVmId")] [string]$protectedVmIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the owning virtual machine." )] + [ValidateNotNullOrEmpty()] [Alias("owningVmId")] [string]$owningVmIdentifier ) diff --git a/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 index ac7d614..d151152 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVpg.ps1 @@ -17,6 +17,7 @@ function Get-ZertoVpg { Mandatory = $true, HelpMessage = "The identifier(s) of the Virtual Protection Group to return" )] + [ValidateNotNullOrEmpty()] [Alias("vpgId", "protectionGroupId", "pgId")] [string[]]$protectionGroupIdentifier, [Parameter( @@ -29,11 +30,13 @@ function Get-ZertoVpg { ParameterSetName = "checkpoints", HelpMessage = "Return checkpoints after the specified start date. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$startDate, [Parameter( ParameterSetName = "checkpoints", HelpMessage = "Return checkpoints before the specified start date. Valid formats include: 'yyyy-MM-ddTHH:mm:ss.fffZ', 'yyyy-MM-ddTHH:mm:ssZ', 'yyyy-MM-ddTHH:mmZ', 'yyyy-MM-ddTHHZ', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy'. Adding Z to the end of the time sets the time to UTC." )] + [ValidateNotNullOrEmpty()] [string]$endDate, [Parameter( ParameterSetName = "stats", Mandatory = $true, @@ -86,47 +89,56 @@ function Get-ZertoVpg { ParameterSetName = "filter", HelpMessage = "The name of the VPG." )] + [ValidateNotNullOrEmpty()] [Alias("vpgName")] [string]$name, [Parameter( ParameterSetName = "filter", HelpMessage = "The status of the VPG. Please use 'Get-ZertoVpg -statuses' for valid values" )] + [ValidateNotNullOrEmpty()] [string]$status, [Parameter( ParameterSetName = "filter", HelpMessage = "The substatus of the VPG. Please use 'Get-ZertoVpg -substatuses' for valid values" )] + [ValidateNotNullOrEmpty()] [string]$subStatus, [Parameter( ParameterSetName = "filter", HelpMessage = "The protected site environment. This filter behaves in the same way as the sourceType filter. Please see Zerto API Documentation for vaild values and discriptions." )] + [ValidateNotNullOrEmpty()] [string]$protectedSiteType, [Parameter( ParameterSetName = "filter", HelpMessage = "The recovery site environment. This filter behaves in the same way as the sourceType filter. Please see Zerto API Documentation for vaild values and discriptions." )] + [ValidateNotNullOrEmpty()] [string]$recoverySiteType, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the protected site where the VPG virtual machines are protected." )] + [ValidateNotNullOrEmpty()] [string]$protectedSiteIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The identifier of the protected site where the VPG virtual machines are recovered." )] + [ValidateNotNullOrEmpty()] [string]$recoverySiteIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "The ZORG for this VPG." )] + [ValidateNotNullOrEmpty()] [string]$organizationName, [Parameter( ParameterSetName = "filter", HelpMessage = "The internal identifier for the ZORG." )] + [ValidateNotNullOrEmpty()] [string]$zorgIdentifier, [Parameter( ParameterSetName = "filter", @@ -138,6 +150,7 @@ function Get-ZertoVpg { ParameterSetName = "filter", HelpMessage = "The identifier of the service profile to use for the VPG when a Zerto Cloud Manager is used." )] + [ValidateNotNullOrEmpty()] [string]$serviceProfileIdentifier, [Parameter( ParameterSetName = "filter", diff --git a/ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 b/ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 index 5c68f54..a5b8f53 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 @@ -131,6 +131,7 @@ function Get-ZertoVpgSetting { Mandatory = $true, HelpMessage = "The identifier of the VPG settings object for which information is retrieved." )] + [ValidateNotNullOrEmpty()] [Alias("vpgSettingsId", "settingsId")] [string]$vpgSettingsIdentifier, [Parameter( @@ -230,6 +231,7 @@ function Get-ZertoVpgSetting { Mandatory = $true, HelpMessage = "VM Identifier" )] + [ValidateNotNullOrEmpty()] [Alias("vmId")] [string]$vmIdentifier, [Parameter( @@ -243,6 +245,7 @@ function Get-ZertoVpgSetting { Mandatory = $true, HelpMessage = "Return NIC information for specified NIC of the specified VM" )] + [ValidateNotNullOrEmpty()] [Alias("nicId")] [string]$nicIdentifier, [Parameter( @@ -256,6 +259,7 @@ function Get-ZertoVpgSetting { Mandatory = $true, HelpMessage = "Return volume information for the specified volume of the specified VM" )] + [ValidateNotNullOrEmpty()] [Alias("volumeId")] [string]$volumeIdentifier ) diff --git a/ZertoApiWrapper/Public/Get-ZertoVra.ps1 b/ZertoApiWrapper/Public/Get-ZertoVra.ps1 index 410ff7e..e94d08b 100644 --- a/ZertoApiWrapper/Public/Get-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoVra.ps1 @@ -18,52 +18,62 @@ function Get-ZertoVra { ParameterSetName = "vraIdentifier", HelpMessage = "Returns information for provided VRA identifier(s)" )] + [ValidateNotNullOrEmpty()] [Alias("vraId")] [string[]]$vraIdentifier, [Parameter( ParameterSetName = "filter", HelpMessage = "VRA Name to return information for." )] + [ValidateNotNullOrEmpty()] [string]$vraName, [Parameter( ParameterSetName = "filter", HelpMessage = "Search for VRAs in a specific status" )] + [ValidateNotNullOrEmpty()] [string]$status, [Parameter( ParameterSetName = "filter", HelpMessage = "Search for VRAs of a specific version" )] + [ValidateNotNullOrEmpty()] [string]$vraVersion, [Parameter( ParameterSetName = "filter", HelpMessage = "Search for VRAs paired to a specific host version" )] + [ValidateNotNullOrEmpty()] [string]$hostVersion, [Parameter( ParameterSetName = "filter", HelpMessage = "Search for a VRA with the specified IP address" )] + [ValidateNotNullOrEmpty()] [string]$ipAddress, [Parameter( ParameterSetName = "filter", HelpMessage = "Search for VRAs belonging to a specific group" )] + [ValidateNotNullOrEmpty()] [string]$vraGroup, [Parameter( ParameterSetName = "filter", HelpMessage = "Search for VRAs on a specific datastore" )] + [ValidateNotNullOrEmpty()] [string]$datastoreName, [Parameter( ParameterSetName = "filter", HelpMessage = "Search for VRAs on a specific datastore cluster" )] + [ValidateNotNullOrEmpty()] [string]$datastoreClusterName, [Parameter( ParameterSetName = "filter", HelpMessage = "Search for VRAs on a specific network" )] + [ValidateNotNullOrEmpty()] [string]$networkName ) diff --git a/ZertoApiWrapper/Public/Get-ZertoZorg.ps1 b/ZertoApiWrapper/Public/Get-ZertoZorg.ps1 index 5d17d29..27f39ee 100644 --- a/ZertoApiWrapper/Public/Get-ZertoZorg.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoZorg.ps1 @@ -6,6 +6,7 @@ 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 2d6b293..1c11b36 100644 --- a/ZertoApiWrapper/Public/Get-ZertoZsspSession.ps1 +++ b/ZertoApiWrapper/Public/Get-ZertoZsspSession.ps1 @@ -6,6 +6,7 @@ function Get-ZertoZsspSession { ParameterSetName = "zsspSessionIdentifier", HelpMessage = "ZSSP Session Id(s) to get information." )] + [ValidateNotNullOrEmpty()] [Alias("zsspSessionId")] [string[]]$zsspSessionIdentifier ) diff --git a/ZertoApiWrapper/Public/Install-ZertoVra.ps1 b/ZertoApiWrapper/Public/Install-ZertoVra.ps1 index 2aad0a8..2bca65f 100644 --- a/ZertoApiWrapper/Public/Install-ZertoVra.ps1 +++ b/ZertoApiWrapper/Public/Install-ZertoVra.ps1 @@ -16,6 +16,7 @@ function Install-ZertoVra { [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/New-ZertoVpg.ps1 b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 index 21ea609..a4885f5 100644 --- a/ZertoApiWrapper/Public/New-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 @@ -6,6 +6,7 @@ function New-ZertoVpg { HelpMessage = "Name of the VPG", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$vpgName, [Parameter( HelpMessage = "VPG Priority. High, Medium, or Low. Default value is Medium" @@ -27,6 +28,7 @@ function New-ZertoVpg { HelpMessage = "Name of the site where the VM(s) will be recovered", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$recoverySite, [Parameter( HelpMessage = "Name of the cluster where the VM(s) will be recovered.", @@ -38,6 +40,7 @@ function New-ZertoVpg { ParameterSetName = "recoveryClusterDatastoreCluster", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$recoveryCluster, [Parameter( HelpMessage = "Name of the host where the VM(s) will be recovered.", @@ -49,6 +52,7 @@ function New-ZertoVpg { ParameterSetName = "recoveryHostDatastoreCluster", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$recoveryHost, [Parameter( HelpMessage = "Name of the resource pool where the VM(s) will be recovered.", @@ -60,6 +64,7 @@ function New-ZertoVpg { ParameterSetName = "recoveryResourcePoolDatastoreCluster", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$recoveryResourcePool, [Parameter( HelpMessage = "Name of the datastore where the VM(s), Volume(s), and Journal(s) will reside.", @@ -76,6 +81,7 @@ function New-ZertoVpg { ParameterSetName = "recoveryResourcePoolDatastore", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$datastore, [Parameter( HelpMessage = "Name of the datastore cluster where the VM(s), Volume(s), and Journal(s) will reside.", @@ -92,11 +98,13 @@ function New-ZertoVpg { ParameterSetName = "recoveryResourcePoolDatastoreCluster", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$datastoreCluster, [Parameter( HelpMessage = "Name of folder at recovery location where the recovered virtual machine(s) will be created.", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$recoveryFolder, [Parameter( HelpMessage = "RPO alert" @@ -111,6 +119,7 @@ function New-ZertoVpg { [Parameter( HelpMessage = "Service profile name to use." )] + [ValidateNotNullOrEmpty()] [string]$serviceProfile, [Parameter( HelpMessage = "Turn on or off WAN and Journal Compression. Default is turned on." @@ -119,31 +128,37 @@ function New-ZertoVpg { [Parameter( HelpMessage = "Name of ZORG to use." )] + [ValidateNotNullOrEmpty()] [String]$zorg, [Parameter( HelpMessage = "Name of the network to use during a Failover Live \ Move VPG operation.", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [String]$recoveryNetwork, [Parameter( HelpMessage = "Name of the network to use during a Failover Test operation", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$testNetwork, [Parameter( HelpMessage = "Name of the datastore to utilize to store Journal data. If not specified, the default datastore will be used.", Mandatory = $false )] + [ValidateNotNullOrEmpty()] [string]$journalDatastore, [Parameter( HelpMessage = "Default journal hard limit in megabytes. Default set to 153600 MB (150 GB). Set to 0 to set the journal to unlimited", Mandatory = $false )] + [ValidateNotNullOrEmpty()] [uint64]$journalHardLimitInMb = 153600, [Parameter( HelpMessage = "Default journal warning threshold in megabytes. If unset or greater than the hard limit, will be set to 75% of the journal hard limit.", Mandatory = $false )] + [ValidateNotNullOrEmpty()] [uint64]$journalWarningThresholdInMb = 0 ) diff --git a/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 b/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 index cd52e5b..07273b8 100644 --- a/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 +++ b/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 @@ -9,6 +9,7 @@ function New-ZertoVpgSettingsIdentifier { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true )] + [ValidateNotNullOrEmpty()] [Alias("vpgId")] [string]$vpgIdentifier, [Parameter( diff --git a/ZertoApiWrapper/Public/Remove-ZertoPeerSite.ps1 b/ZertoApiWrapper/Public/Remove-ZertoPeerSite.ps1 index 6eb8740..0d818e9 100644 --- a/ZertoApiWrapper/Public/Remove-ZertoPeerSite.ps1 +++ b/ZertoApiWrapper/Public/Remove-ZertoPeerSite.ps1 @@ -12,6 +12,7 @@ function Remove-ZertoPeerSite { ValueFromPipelineByPropertyName = $true, Mandatory = $true )] + [ValidateNotNullOrEmpty()] [Alias("siteId")] [string[]]$siteIdentifier, [Parameter( @@ -21,6 +22,7 @@ function Remove-ZertoPeerSite { ValueFromPipelineByPropertyName = $true, Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string[]]$peerSiteName, [Parameter( HelpMessage = "IP address of the peer site to be removed from the connected site", diff --git a/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Remove-ZertoVpg.ps1 index 8aafb91..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,6 +18,7 @@ function Remove-ZertoVpg { ValueFromPipelineByPropertyName = $true, HelpMessage = "vpgIdentifier(s) of the VPG(s) to delete." )] + [ValidateNotNullOrEmpty()] [Alias("vpgId")] [string[]]$vpgidentifier, [Parameter( diff --git a/ZertoApiWrapper/Public/Resume-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Resume-ZertoVpg.ps1 index e258d0c..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 ) diff --git a/ZertoApiWrapper/Public/Save-ZertoVpgSetting.ps1 b/ZertoApiWrapper/Public/Save-ZertoVpgSetting.ps1 index 8e06784..64c9127 100644 --- a/ZertoApiWrapper/Public/Save-ZertoVpgSetting.ps1 +++ b/ZertoApiWrapper/Public/Save-ZertoVpgSetting.ps1 @@ -10,6 +10,7 @@ function Save-ZertoVpgSetting { ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true )] + [ValidateNotNullOrEmpty()] [Alias("vpgSettingsId")] [string]$vpgSettingsIdentifier ) diff --git a/ZertoApiWrapper/Public/Set-ZertoAlert.ps1 b/ZertoApiWrapper/Public/Set-ZertoAlert.ps1 index 8724476..1969177 100644 --- a/ZertoApiWrapper/Public/Set-ZertoAlert.ps1 +++ b/ZertoApiWrapper/Public/Set-ZertoAlert.ps1 @@ -2,14 +2,14 @@ function Set-ZertoAlert { [cmdletbinding( SupportsShouldProcess = $true )] param ( - [Alias("identifier")] [Parameter( ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory = $true, HelpMessage = "Alert identifier(s) to be dismissed or undismissed." )] - [Alias("alertIdentifier")] + [ValidateNotNullOrEmpty()] + [Alias("alertIdentifier", "identifier", "id")] [string[]]$alertId, [Parameter( ParameterSetName = "dismiss", 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 adf82ff..1678c8b 100644 --- a/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 +++ b/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 @@ -6,19 +6,23 @@ function Start-ZertoCloneVpg { 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 ) diff --git a/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 b/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 index 6d5ecc5..ee044e3 100644 --- a/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 +++ b/ZertoApiWrapper/Public/Start-ZertoFailoverTest.ps1 @@ -6,15 +6,18 @@ function Start-ZertoFailoverTest { 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 ) diff --git a/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 b/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 index 746238e..6e78ade 100644 --- a/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 +++ b/ZertoApiWrapper/Public/Stop-ZertoCloneVpg.ps1 @@ -6,6 +6,7 @@ function Stop-ZertoCloneVpg { HelpMessage = "Name of the VPG to stop cloning", Mandatory = $true )] + [ValidateNotNullOrEmpty()] [string]$vpgName ) diff --git a/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 b/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 index 7593077..babb190 100644 --- a/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 +++ b/ZertoApiWrapper/Public/Stop-ZertoFailoverTest.ps1 @@ -15,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" ) diff --git a/ZertoApiWrapper/Public/Suspend-ZertoVpg.ps1 b/ZertoApiWrapper/Public/Suspend-ZertoVpg.ps1 index 68e8bee..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 ) diff --git a/ZertoApiWrapper/Public/Uninstall-ZertoVra.ps1 b/ZertoApiWrapper/Public/Uninstall-ZertoVra.ps1 index 31496ff..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 ) From 9be2f09947f23034d08bc7751ccf22be75731ba0 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 17 Apr 2019 08:50:54 -0400 Subject: [PATCH 132/147] Alias and WhatIf updates --- docs/Get-ZertoServiceProfile.md | 2 +- docs/New-ZertoVpgSettingsIdentifier.md | 34 ++++++++++++++++++++++++-- docs/Set-ZertoAlert.md | 2 +- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/docs/Get-ZertoServiceProfile.md b/docs/Get-ZertoServiceProfile.md index 21a381c..536e4e9 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 diff --git a/docs/New-ZertoVpgSettingsIdentifier.md b/docs/New-ZertoVpgSettingsIdentifier.md index 93f9beb..4c73305 100644 --- a/docs/New-ZertoVpgSettingsIdentifier.md +++ b/docs/New-ZertoVpgSettingsIdentifier.md @@ -14,12 +14,12 @@ Creates and returns a VPG Settings Identifier either for an existing VPG or a ne ### existingVpg ``` -New-ZertoVpgSettingsIdentifier -vpgIdentifier [] +New-ZertoVpgSettingsIdentifier -vpgIdentifier [-WhatIf] [-Confirm] [] ``` ### newVpg ``` -New-ZertoVpgSettingsIdentifier [-newVpg] [] +New-ZertoVpgSettingsIdentifier [-newVpg] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -75,6 +75,36 @@ 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). diff --git a/docs/Set-ZertoAlert.md b/docs/Set-ZertoAlert.md index 9e68770..9de6fc9 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: alertIdentifier, identifier +Aliases: alertIdentifier, identifier, id Required: True Position: Named From 2186c2613221573808e641bb55e30b4a7cc9aeb1 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 17 Apr 2019 08:59:48 -0400 Subject: [PATCH 133/147] Update required version of InvokeBuild --- ZertoApiWrapper.Depend.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZertoApiWrapper.Depend.psd1 b/ZertoApiWrapper.Depend.psd1 index 95b3918..196f108 100644 --- a/ZertoApiWrapper.Depend.psd1 +++ b/ZertoApiWrapper.Depend.psd1 @@ -7,7 +7,7 @@ SkipPublisherCheck = $true } Target = 'CurrentUser' - Version = '5.5.0' + Version = '5.5.1' Tags = 'Bootstrap' } From 902636c5170c2e31cf72e2bf9c464e22d9a9a7f6 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 17 Apr 2019 09:12:15 -0400 Subject: [PATCH 134/147] Add WhatIf and second example --- docs/Invoke-ZertoFailover.md | 61 ++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/docs/Invoke-ZertoFailover.md b/docs/Invoke-ZertoFailover.md index ecc48e6..0c9f515 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 @@ -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: @@ -172,6 +163,36 @@ 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). From 51146fd933ccfdcb57daa91c3a840f8cf0a2968a Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 17 Apr 2019 09:23:19 -0400 Subject: [PATCH 135/147] Update Invoke-ZertoMove.md --- docs/Invoke-ZertoMove.md | 117 +++++++++++++++++++++++---------------- 1 file changed, 70 insertions(+), 47 deletions(-) diff --git a/docs/Invoke-ZertoMove.md b/docs/Invoke-ZertoMove.md index 4cfd149..0f0ac71 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 @@ -69,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: @@ -88,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: @@ -108,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. @@ -164,6 +157,36 @@ 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). From db32f259874e03bc2d6f54a19d7313bea06e9379 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 17 Apr 2019 13:36:06 -0400 Subject: [PATCH 136/147] Update Invoke-ZertoMoveCommit.md --- docs/Invoke-ZertoMoveCommit.md | 42 ++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/docs/Invoke-ZertoMoveCommit.md b/docs/Invoke-ZertoMoveCommit.md index 584ee4c..72c687e 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,6 +77,36 @@ 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). From 63df77e5edd164c4db705a1c00c559ce7c7fac89 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Wed, 17 Apr 2019 17:53:50 -0400 Subject: [PATCH 137/147] Update Build Names --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a756f57..46201e1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,7 +3,7 @@ # Add steps that build, run tests, deploy, and more: # https://aka.ms/yaml -name: $(TeamProject)_$(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.rr) +name: $(TeamProject)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.rr) # Trigger CI on commit to master and develop branches trigger: From b514eed939aa7e7eb82fe24fdbc1e11b78d77b3f Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sat, 20 Apr 2019 09:49:33 -0400 Subject: [PATCH 138/147] Update ZertoApiWrapper-help.xml --- .../Public/en-us/ZertoApiWrapper-help.xml | 924 +++++++++++++++--- 1 file changed, 781 insertions(+), 143 deletions(-) diff --git a/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml b/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml index 98cacd1..df46e9f 100644 --- a/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml +++ b/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml @@ -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. @@ -3422,7 +3422,7 @@ Get-ZertoServiceProfile - + serviceProfileId The service profile ID for which information should be returned. @@ -3452,7 +3452,7 @@ - + serviceProfileId The service profile ID for which information should be returned. @@ -7151,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 @@ -7180,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 @@ -7214,6 +7202,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 + @@ -7244,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 @@ -7286,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 @@ -7319,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 + @@ -7353,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. + + @@ -7393,7 +7422,7 @@ None - reverseProtect + reverseProtection Use this switch to reverse protect the VPG(s) to the source site. @@ -7407,7 +7436,7 @@ - reverseProtect + reverseProtection Use this switch to reverse protect the VPG(s) to the source site. @@ -7466,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 @@ -7716,60 +7745,155 @@ 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 + @@ -7801,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 @@ -7869,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 + @@ -7942,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 @@ -7965,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 + @@ -7980,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 @@ -8004,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 + @@ -8077,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 + @@ -8092,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 + @@ -8383,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 @@ -8615,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 @@ -8847,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 @@ -9079,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 @@ -9311,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 @@ -9543,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 + @@ -9798,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 + @@ -9947,6 +10333,28 @@ 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 @@ -9962,6 +10370,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 + @@ -9989,6 +10419,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 + @@ -10824,7 +11278,7 @@ Set-ZertoAlert - + alertId Alert identifier(s) to be dismissed or undismissed. @@ -10872,7 +11326,7 @@ Set-ZertoAlert - + alertId Alert identifier(s) to be dismissed or undismissed. @@ -10920,7 +11374,7 @@ - + alertId Alert identifier(s) to be dismissed or undismissed. @@ -11230,6 +11684,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 + @@ -11281,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 + @@ -11378,6 +11878,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 + @@ -11417,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 + @@ -11490,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 + @@ -11505,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 + @@ -11602,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 + @@ -11641,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 + From 80655985343ea0add46d277dd97c057798304db2 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 28 Apr 2019 13:16:27 -0400 Subject: [PATCH 139/147] Refactor Get-ZertoVpgSetting Update for Pipeline input and switch processing. --- .../Public/Get-ZertoVpgSetting.ps1 | 132 ++++++++++++++---- 1 file changed, 105 insertions(+), 27 deletions(-) diff --git a/ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 b/ZertoApiWrapper/Public/Get-ZertoVpgSetting.ps1 index a5b8f53..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,13 +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." )] [ValidateNotNullOrEmpty()] [Alias("vpgSettingsId", "settingsId")] - [string]$vpgSettingsIdentifier, + [string[]]$vpgSettingsIdentifier, [Parameter( ParameterSetName = "backup", Mandatory = $true, @@ -266,38 +284,98 @@ function Get-ZertoVpgSetting { 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! } } From 2ebf469c12e8a4e035f52142cdf802931f106223 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 28 Apr 2019 13:24:56 -0400 Subject: [PATCH 140/147] Update New-ZertoVpgSettingsIdentifier.ps1 Set default Parameter Set, Move body creation to process block for pipeline processing. --- .../Public/New-ZertoVpgSettingsIdentifier.ps1 | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 b/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 index 07273b8..06150d2 100644 --- a/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 +++ b/ZertoApiWrapper/Public/New-ZertoVpgSettingsIdentifier.ps1 @@ -1,6 +1,6 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function New-ZertoVpgSettingsIdentifier { - [cmdletbinding( SupportsShouldProcess = $true )] + [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.", @@ -11,7 +11,7 @@ function New-ZertoVpgSettingsIdentifier { )] [ValidateNotNullOrEmpty()] [Alias("vpgId")] - [string]$vpgIdentifier, + [string[]]$vpgIdentifier, [Parameter( HelpMessage = "Use this switch when creating a vpgSettingsIdentifier for a new VPG", ParameterSetName = "newVpg", @@ -22,20 +22,24 @@ function New-ZertoVpgSettingsIdentifier { begin { $baseUri = "vpgSettings" - switch ($PSCmdlet.ParameterSetName) { - "newVpg" { - $body = "{}" - } - - "existingVpg" { - $body = "{""VpgIdentifier"":""$vpgIdentifier""}" - } - } } process { - if ($PSCmdlet.ShouldProcess("Creating VPG Settings Object")) { - Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST" + switch ($PSCmdlet.ParameterSetName) { + "newVpg" { + $body = "{}" + if ($PSCmdlet.ShouldProcess("Creating VPG Settings Object")) { + Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST" + } + } + "existingVpg" { + foreach ($id in $vpgIdentifier) { + $body = "{""VpgIdentifier"":""$id""}" + if ($PSCmdlet.ShouldProcess("Creating VPG Settings Object")) { + Invoke-ZertoRestRequest -uri $baseUri -body $body -Method "POST" + } + } + } } } From 5e9adbd2540f40446e099b26023ad19d37eb5a22 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 28 Apr 2019 16:09:43 -0400 Subject: [PATCH 141/147] Update Pester to 0.14.0 --- docs/Add-ZertoPeerSite.md | 2 +- docs/Checkpoint-ZertoVpg.md | 2 +- docs/Connect-ZertoServer.md | 2 +- docs/Disconnect-ZertoServer.md | 2 +- docs/Edit-ZertoVra.md | 2 +- docs/Export-ZertoVpg.md | 2 +- docs/Get-ZertoAlert.md | 2 +- docs/Get-ZertoDatastore.md | 2 +- docs/Get-ZertoEvent.md | 2 +- docs/Get-ZertoLicense.md | 2 +- docs/Get-ZertoLocalSite.md | 2 +- docs/Get-ZertoPeerSite.md | 2 +- docs/Get-ZertoProtectedVm.md | 2 +- docs/Get-ZertoRecoveryReport.md | 2 +- docs/Get-ZertoResourcesReport.md | 2 +- docs/Get-ZertoServiceProfile.md | 2 +- docs/Get-ZertoTask.md | 2 +- docs/Get-ZertoUnprotectedVm.md | 2 +- docs/Get-ZertoVirtualizationSite.md | 2 +- docs/Get-ZertoVolume.md | 2 +- docs/Get-ZertoVpg.md | 2 +- docs/Get-ZertoVra.md | 2 +- docs/Get-ZertoZorg.md | 2 +- docs/Get-ZertoZsspSession.md | 2 +- docs/Install-ZertoVra.md | 2 +- docs/Invoke-ZertoFailover.md | 2 +- docs/Invoke-ZertoFailoverCommit.md | 2 +- docs/Invoke-ZertoFailoverRollback.md | 2 +- docs/Invoke-ZertoForceSync.md | 2 +- docs/Invoke-ZertoMove.md | 2 +- docs/Invoke-ZertoMoveCommit.md | 2 +- docs/Invoke-ZertoMoveRollback.md | 2 +- docs/New-ZertoVpg.md | 2 +- docs/Remove-ZertoPeerSite.md | 2 +- docs/Remove-ZertoVpg.md | 2 +- docs/Resume-ZertoVpg.md | 2 +- docs/Set-ZertoAlert.md | 2 +- docs/Set-ZertoLicense.md | 2 +- docs/Start-ZertoCloneVpg.md | 2 +- docs/Start-ZertoFailoverTest.md | 2 +- docs/Stop-ZertoCloneVpg.md | 2 +- docs/Stop-ZertoFailoverTest.md | 2 +- docs/Suspend-ZertoVpg.md | 2 +- docs/Uninstall-ZertoVra.md | 2 +- 44 files changed, 44 insertions(+), 44 deletions(-) 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 41d75e8..810bdb0 100644 --- a/docs/Connect-ZertoServer.md +++ b/docs/Connect-ZertoServer.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/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 89b8866..be40e81 100644 --- a/docs/Edit-ZertoVra.md +++ b/docs/Edit-ZertoVra.md @@ -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 1c0d9f8..52e6dc5 100644 --- a/docs/Export-ZertoVpg.md +++ b/docs/Export-ZertoVpg.md @@ -89,7 +89,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-ZertoAlert.md b/docs/Get-ZertoAlert.md index a9cefa0..1dfd749 100644 --- a/docs/Get-ZertoAlert.md +++ b/docs/Get-ZertoAlert.md @@ -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 40adbe2..8db8390 100644 --- a/docs/Get-ZertoDatastore.md +++ b/docs/Get-ZertoDatastore.md @@ -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 4e76263..3e0c546 100644 --- a/docs/Get-ZertoEvent.md +++ b/docs/Get-ZertoEvent.md @@ -338,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 e5e2936..9142de4 100644 --- a/docs/Get-ZertoPeerSite.md +++ b/docs/Get-ZertoPeerSite.md @@ -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 daaa2c5..1d814ea 100644 --- a/docs/Get-ZertoProtectedVm.md +++ b/docs/Get-ZertoProtectedVm.md @@ -237,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 536e4e9..98a0c97 100644 --- a/docs/Get-ZertoServiceProfile.md +++ b/docs/Get-ZertoServiceProfile.md @@ -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 6ff80af..8e10bcd 100644 --- a/docs/Get-ZertoTask.md +++ b/docs/Get-ZertoTask.md @@ -185,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 7f44405..88f78cf 100644 --- a/docs/Get-ZertoVirtualizationSite.md +++ b/docs/Get-ZertoVirtualizationSite.md @@ -271,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 5b17799..5663b51 100644 --- a/docs/Get-ZertoVolume.md +++ b/docs/Get-ZertoVolume.md @@ -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 4c8a3b5..d574889 100644 --- a/docs/Get-ZertoVpg.md +++ b/docs/Get-ZertoVpg.md @@ -496,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-ZertoVra.md b/docs/Get-ZertoVra.md index d44cd4e..676e491 100644 --- a/docs/Get-ZertoVra.md +++ b/docs/Get-ZertoVra.md @@ -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 fac0cfc..5ddcd16 100644 --- a/docs/Get-ZertoZorg.md +++ b/docs/Get-ZertoZorg.md @@ -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 b6463df..09ce28b 100644 --- a/docs/Get-ZertoZsspSession.md +++ b/docs/Get-ZertoZsspSession.md @@ -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/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 0c9f515..41edbae 100644 --- a/docs/Invoke-ZertoFailover.md +++ b/docs/Invoke-ZertoFailover.md @@ -194,7 +194,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-ZertoFailoverCommit.md b/docs/Invoke-ZertoFailoverCommit.md index b1abfa4..9f1b3d1 100644 --- a/docs/Invoke-ZertoFailoverCommit.md +++ b/docs/Invoke-ZertoFailoverCommit.md @@ -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 0f0ac71..6239eda 100644 --- a/docs/Invoke-ZertoMove.md +++ b/docs/Invoke-ZertoMove.md @@ -188,7 +188,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-ZertoMoveCommit.md b/docs/Invoke-ZertoMoveCommit.md index 72c687e..08c6e92 100644 --- a/docs/Invoke-ZertoMoveCommit.md +++ b/docs/Invoke-ZertoMoveCommit.md @@ -108,7 +108,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-ZertoMoveRollback.md b/docs/Invoke-ZertoMoveRollback.md index e7fd776..4df0772 100644 --- a/docs/Invoke-ZertoMoveRollback.md +++ b/docs/Invoke-ZertoMoveRollback.md @@ -76,7 +76,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/New-ZertoVpg.md b/docs/New-ZertoVpg.md index 317c9cb..cd68b3d 100644 --- a/docs/New-ZertoVpg.md +++ b/docs/New-ZertoVpg.md @@ -523,7 +523,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/Remove-ZertoPeerSite.md b/docs/Remove-ZertoPeerSite.md index 6bb3816..9475bdc 100644 --- a/docs/Remove-ZertoPeerSite.md +++ b/docs/Remove-ZertoPeerSite.md @@ -150,7 +150,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/Remove-ZertoVpg.md b/docs/Remove-ZertoVpg.md index 95af5db..86ef8db 100644 --- a/docs/Remove-ZertoVpg.md +++ b/docs/Remove-ZertoVpg.md @@ -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/Set-ZertoAlert.md b/docs/Set-ZertoAlert.md index 9de6fc9..9a7cd65 100644 --- a/docs/Set-ZertoAlert.md +++ b/docs/Set-ZertoAlert.md @@ -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 226e97a..6c0cedb 100644 --- a/docs/Start-ZertoCloneVpg.md +++ b/docs/Start-ZertoCloneVpg.md @@ -125,7 +125,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-ZertoFailoverTest.md b/docs/Start-ZertoFailoverTest.md index e2d3c1d..7899454 100644 --- a/docs/Start-ZertoFailoverTest.md +++ b/docs/Start-ZertoFailoverTest.md @@ -109,7 +109,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/Stop-ZertoCloneVpg.md b/docs/Stop-ZertoCloneVpg.md index 65e7ab4..5e96bd7 100644 --- a/docs/Stop-ZertoCloneVpg.md +++ b/docs/Stop-ZertoCloneVpg.md @@ -76,7 +76,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/Stop-ZertoFailoverTest.md b/docs/Stop-ZertoFailoverTest.md index 63d9f95..f4ab758 100644 --- a/docs/Stop-ZertoFailoverTest.md +++ b/docs/Stop-ZertoFailoverTest.md @@ -109,7 +109,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/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 From 4946ac51babcd4856f9da592ca117c0e0275a857 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 28 Apr 2019 16:11:01 -0400 Subject: [PATCH 142/147] Update for vpgSettingsIdentifier Array --- docs/Get-ZertoVpgSetting.md | 56 +++++++++++++++---------------------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/docs/Get-ZertoVpgSetting.md b/docs/Get-ZertoVpgSetting.md index 8c97811..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 @@ -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 +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: vpgSettingsId, settingsId - -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 From b6fd4a57e208cecc493ca74f2ae629525e5cbcff Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 28 Apr 2019 16:11:12 -0400 Subject: [PATCH 143/147] Update Import-ZertoVpg.md --- docs/Import-ZertoVpg.md | 124 ++++++++++++++++++++-------------------- 1 file changed, 62 insertions(+), 62 deletions(-) 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#) From 1b3a6127956f200010a99af63f46612163e295d7 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 28 Apr 2019 16:11:52 -0400 Subject: [PATCH 144/147] Update Default Parameter Set --- docs/New-ZertoVpgSettingsIdentifier.md | 244 ++++++++++++------------- 1 file changed, 122 insertions(+), 122 deletions(-) diff --git a/docs/New-ZertoVpgSettingsIdentifier.md b/docs/New-ZertoVpgSettingsIdentifier.md index 4c73305..f703f1b 100644 --- a/docs/New-ZertoVpgSettingsIdentifier.md +++ b/docs/New-ZertoVpgSettingsIdentifier.md @@ -1,122 +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 [-WhatIf] [-Confirm] [] -``` - -### newVpg -``` -New-ZertoVpgSettingsIdentifier [-newVpg] [-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#) +--- +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#) From c209d29964eb26347c58681095526e9134577362 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 28 Apr 2019 16:12:11 -0400 Subject: [PATCH 145/147] Update to PlatyPS 0.14.0 --- docs/Save-ZertoVpgSetting.md | 184 +++++++++++++++++------------------ 1 file changed, 92 insertions(+), 92 deletions(-) diff --git a/docs/Save-ZertoVpgSetting.md b/docs/Save-ZertoVpgSetting.md index 2e2efaf..b0305e1 100644 --- a/docs/Save-ZertoVpgSetting.md +++ b/docs/Save-ZertoVpgSetting.md @@ -1,92 +1,92 @@ ---- -external help file: ZertoApiWrapper-help.xml -Module Name: ZertoApiWrapper -online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSetting.md -schema: 2.0.0 ---- - -# Save-ZertoVpgSetting - -## SYNOPSIS -Commits the updated Vpg Settings with the configured Vpg Settings Identifier - -## SYNTAX - -``` -Save-ZertoVpgSetting [-vpgSettingsIdentifier] [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -Commits the updated Vpg Settings with the configured Vpg Settings Identifier - -## EXAMPLES - -### Example 1 -```powershell -PS C:> Save-ZertoVpgSetting -vpgSettingsIdentifier "MyVpgSettingsIdentifier" -``` - -Commits vpg settings with vpg settings identifier "MyVpgSettingsIdentifier" - -## PARAMETERS - -### -vpgSettingsIdentifier -VpgSettings Identifier to save - -```yaml -Type: String -Parameter Sets: (All) -Aliases: vpgSettingsId - -Required: True -Position: 1 -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#) +--- +external help file: ZertoApiWrapper-help.xml +Module Name: ZertoApiWrapper +online version: https://github.com/wcarroll/ZertoApiWrapper/blob/master/docs/Save-ZertoVpgSetting.md +schema: 2.0.0 +--- + +# Save-ZertoVpgSetting + +## SYNOPSIS +Commits the updated Vpg Settings with the configured Vpg Settings Identifier + +## SYNTAX + +``` +Save-ZertoVpgSetting [-vpgSettingsIdentifier] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Commits the updated Vpg Settings with the configured Vpg Settings Identifier + +## EXAMPLES + +### Example 1 +```powershell +PS C:> Save-ZertoVpgSetting -vpgSettingsIdentifier "MyVpgSettingsIdentifier" +``` + +Commits vpg settings with vpg settings identifier "MyVpgSettingsIdentifier" + +## PARAMETERS + +### -vpgSettingsIdentifier +VpgSettings Identifier to save + +```yaml +Type: String +Parameter Sets: (All) +Aliases: vpgSettingsId + +Required: True +Position: 1 +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#) From 7c40401b1f825a3b4ff3e11c91d787cc4ca1104c Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 28 Apr 2019 16:14:33 -0400 Subject: [PATCH 146/147] Update ZertoApiWrapper-help.xml --- .../Public/en-us/ZertoApiWrapper-help.xml | 122 +++++++++--------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml b/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml index df46e9f..6ae1461 100644 --- a/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml +++ b/ZertoApiWrapper/Public/en-us/ZertoApiWrapper-help.xml @@ -5256,14 +5256,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5282,14 +5282,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5308,14 +5308,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5334,14 +5334,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5360,14 +5360,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5386,14 +5386,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5425,14 +5425,14 @@ None - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5463,14 +5463,14 @@ None - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5489,14 +5489,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5515,14 +5515,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5541,14 +5541,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5567,14 +5567,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5593,14 +5593,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5632,14 +5632,14 @@ None - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5670,14 +5670,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5697,14 +5697,14 @@ None - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5723,14 +5723,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5738,14 +5738,14 @@ Get-ZertoVpgSetting - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -5957,14 +5957,14 @@ False - + vpgSettingsIdentifier The identifier of the VPG settings object for which information is retrieved. - String + String[] - String + String[] None @@ -10363,9 +10363,9 @@ 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 @@ -10412,9 +10412,9 @@ 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 From 23bc5dbe99c0ef5f40d1cddd480d31badad4d47b Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 29 Apr 2019 16:15:42 -0400 Subject: [PATCH 147/147] Update For Pester Tests --- .../Invoke-ZertoFailoverCommit.Tests.ps1 | 27 ++++++++++++++++++- .../Public/Invoke-ZertoFailoverCommit.ps1 | 16 ++++++----- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/Tests/Public/Invoke-ZertoFailoverCommit.Tests.ps1 b/Tests/Public/Invoke-ZertoFailoverCommit.Tests.ps1 index 50d2f9d..2fa2e2e 100644 --- a/Tests/Public/Invoke-ZertoFailoverCommit.Tests.ps1 +++ b/Tests/Public/Invoke-ZertoFailoverCommit.Tests.ps1 @@ -16,4 +16,29 @@ Describe $file.BaseName -Tag 'Unit' { $null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) $errors | Should -HaveCount 0 } -} \ No newline at end of file + + Context "$($file.BaseName)::Parameter Unit Tests" { + + it "Supports 'ShouldProcess'" { + Get-Command $file.BaseName | Should -HaveParameter WhatIf + Get-Command $file.BaseName | Should -HaveParameter Confirm + $file | Should -FileContentMatch 'SupportsShouldProcess' + $file | Should -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)' + } + + it "has a mandatory string parameter for the vpgName" { + Get-Command $file.BaseName | Should -HaveParameter vpgName + Get-Command $file.BaseName | Should -HaveParameter vpgName -Type string[] + Get-Command $file.BaseName | Should -HaveParameter vpgName -Mandatory + } + + it "has a switch parameter for reverse protection" { + Get-Command $file.BaseName | Should -HaveParameter reverseProtection + Get-Command $file.BaseName | Should -HaveParameter reverseProtection -Type switch + } + } + + Context "$($file.BaseName)::Function Unit Tests" { + #TODO + } +} diff --git a/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 b/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 index 5f88c47..cbd5250 100644 --- a/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 +++ b/ZertoApiWrapper/Public/Invoke-ZertoFailoverCommit.ps1 @@ -1,6 +1,6 @@ <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> function Invoke-ZertoFailoverCommit { - [cmdletbinding()] + [cmdletbinding( SupportsShouldProcess = $true )] param( [Parameter( HelpMessage = "Name(s) of the VPG(s) to commit.", @@ -16,21 +16,23 @@ function Invoke-ZertoFailoverCommit { begin { $baseUri = "vpgs" - if ( $reverseProtection ) { - $body = @{"IsReverseProtection" = $true} - } else { - $body = @{"IsReverseProtection" = $false} - } } process { + if ( $reverseProtection.IsPresent ) { + $body = @{"IsReverseProtection" = $true } + } else { + $body = @{"IsReverseProtection" = $false } + } foreach ($name in $vpgName) { $vpgId = $(Get-ZertoVpg -name $name).vpgIdentifier if ( -not $vpgId ) { Write-Error "VPG: $name could not be found. Please check the name and try again. Skipping." } else { $uri = "{0}/{1}/FailoverCommit" -f $baseUri, $vpgId - Invoke-ZertoRestRequest -uri $uri -body $($body | convertto-json) -method "POST" + if ($PSCmdlet.ShouldProcess($body, $uri)) { + Invoke-ZertoRestRequest -uri $uri -body $($body | convertto-json) -method "POST" + } } } }