From 83447772b6c844ef74016fbe1d8ed5a886d446c6 Mon Sep 17 00:00:00 2001 From: Joshua Post Date: Mon, 24 May 2021 14:41:56 -0500 Subject: [PATCH 1/6] Replace invalid character with ' --- Modules/Backup-VCSA/Backup-VCSA.psm1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Modules/Backup-VCSA/Backup-VCSA.psm1 b/Modules/Backup-VCSA/Backup-VCSA.psm1 index b240e4c..f53abc3 100644 --- a/Modules/Backup-VCSA/Backup-VCSA.psm1 +++ b/Modules/Backup-VCSA/Backup-VCSA.psm1 @@ -35,9 +35,9 @@ Function Backup-VCSAToFile { -CommonBackup will only backup the config whereas -Fullbackup grabs the historical data as well #> param ( - [Parameter(ParameterSetName=’FullBackup’)] + [Parameter(ParameterSetName='FullBackup')] [switch]$FullBackup, - [Parameter(ParameterSetName=’CommonBackup’)] + [Parameter(ParameterSetName='CommonBackup')] [switch]$CommonBackup, [ValidateSet('FTPS', 'HTTP', 'SCP', 'HTTPS', 'FTP')] $LocationType = "FTP", @@ -239,7 +239,7 @@ Function New-VCSASchedule { .EXAMPLE The Below Create a schedule on Monday @11:30pm to FTP location 10.1.1.10:/vcsabackup/vcenter01 and keep 4 backups with a Encryption Passowrd of "VMw@re123" - + $location = "ftp://10.1.1.10/vcsabackup/vcenter01" $LocationUser = "admin" [VMware.VimAutomation.Cis.Core.Types.V1.Secret]$locationPassword = "VMw@re123" @@ -248,14 +248,14 @@ Function New-VCSASchedule { $BDays = @("Monday") $MaxCount = 4 [VMware.VimAutomation.Cis.Core.Types.V1.Secret]$BackupPassword = "VMw@re123" - + PS C:\> New-VCSASchedule -Location $location -LocationUser $LocationUser -LocationPassword $locationPassword -BackupHour $BHour -BackupMinute $BMin -backupDays $BDays -MaxCount $MaxCount -BackupPassword $BackupPassword .EXAMPLE The Below Create a schedule on Sunday & Wednesday @5:15am to NFS location 10.1.1.10:/vcsabackup/vcenter01 keep 10 backups with a Encryption Passowrd of "VMw@re123" with Event Data included (Seat) and will delete any existing schedule. - + $location = "nfs://10.1.1.10/vcsabackup/vcenter01" $LocationUser = "admin" [VMware.VimAutomation.Cis.Core.Types.V1.Secret]$locationPassword = "VMw@re123" @@ -264,7 +264,7 @@ Function New-VCSASchedule { $BDays = @("Sunday", "Monday") $MaxCount = 10 [VMware.VimAutomation.Cis.Core.Types.V1.Secret]$BackupPassword = "VMw@re123" - + PS C:\> New-VCSASchedule -IncludeSeat -force -Location $location -LocationUser $LocationUser -LocationPassword $locationPassword -BackupHour $BHour -BackupMinute $BMin -backupDays $BDays -MaxCount $MaxCount -BackupPassword $BackupPassword -CisServer "vcserver.sphere.local" .NOTES Credit goes to @AlanRenouf & @vBrianGraf for sharing the base of this function. @@ -324,8 +324,8 @@ Function New-VCSASchedule { $CreateSpec.parts = @() } $CurrentSchedule = $BackupAPI.list() - - + + if ($CurrentSchedule.keys.value) { if($Force -or $PSCmdlet.ShouldContinue($CurrentSchedule.keys.value,'Delete Old Schedule')){ $BackupAPI.delete($CurrentSchedule.keys.value) @@ -374,7 +374,7 @@ Function Get-VCSASchedule { PS C:\> Get-VCSASchedule -ScheduleID 1 -CisServer "vcserver.sphere.local" .NOTES Credit goes to @AlanRenouf & @vBrianGraf for sharing the base of this function. - Returns a simplified object with the schedule details. + Returns a simplified object with the schedule details. You must be connected to the CisService for this to work, if you are not connected, the function will prompt you for your credentials #> param ( From 9519635847f6e26cc3b8e98d657c10e025855519 Mon Sep 17 00:00:00 2001 From: Joshua Post Date: Mon, 24 May 2021 14:43:39 -0500 Subject: [PATCH 2/6] Add support for SMB location --- Modules/Backup-VCSA/Backup-VCSA.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Backup-VCSA/Backup-VCSA.psm1 b/Modules/Backup-VCSA/Backup-VCSA.psm1 index f53abc3..40993d1 100644 --- a/Modules/Backup-VCSA/Backup-VCSA.psm1 +++ b/Modules/Backup-VCSA/Backup-VCSA.psm1 @@ -39,7 +39,7 @@ Function Backup-VCSAToFile { [switch]$FullBackup, [Parameter(ParameterSetName='CommonBackup')] [switch]$CommonBackup, - [ValidateSet('FTPS', 'HTTP', 'SCP', 'HTTPS', 'FTP')] + [ValidateSet('FTPS', 'HTTP', 'SCP', 'HTTPS', 'FTP', 'SMB')] $LocationType = "FTP", $Location, $LocationUser, From e872cc50d199c9ffb9202f77e59b96101999bf12 Mon Sep 17 00:00:00 2001 From: Joshua Post Date: Mon, 24 May 2021 14:45:14 -0500 Subject: [PATCH 3/6] If 'common' is not specified, it is not included If 'common' is not included, it is unchecked when viewing in the GUI --- Modules/Backup-VCSA/Backup-VCSA.psm1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Backup-VCSA/Backup-VCSA.psm1 b/Modules/Backup-VCSA/Backup-VCSA.psm1 index 40993d1..07eddb7 100644 --- a/Modules/Backup-VCSA/Backup-VCSA.psm1 +++ b/Modules/Backup-VCSA/Backup-VCSA.psm1 @@ -319,9 +319,9 @@ Function New-VCSASchedule { $CreateSpec.recurrence_info.Days = $BackupDays $CreateSpec.retention_info.max_count = $MaxCount if ($IncludeSeat) { - $CreateSpec.parts = @("seat") + $CreateSpec.parts = @("seat","common") } else { - $CreateSpec.parts = @() + $CreateSpec.parts = @("common") } $CurrentSchedule = $BackupAPI.list() From 9a02c0e1fafd24d8960fc6fe310c4c0af9883b48 Mon Sep 17 00:00:00 2001 From: Joshua Post Date: Mon, 24 May 2021 14:47:07 -0500 Subject: [PATCH 4/6] Correct casting of int Interger is not a valid type, at least in Powershell 5.1 --- Modules/Backup-VCSA/Backup-VCSA.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Backup-VCSA/Backup-VCSA.psm1 b/Modules/Backup-VCSA/Backup-VCSA.psm1 index 07eddb7..2a194f1 100644 --- a/Modules/Backup-VCSA/Backup-VCSA.psm1 +++ b/Modules/Backup-VCSA/Backup-VCSA.psm1 @@ -279,7 +279,7 @@ Function New-VCSASchedule { [Parameter(Mandatory=$true)][ValidateRange(0,23)]$BackupHour, [Parameter(Mandatory=$true)][ValidateRange(0,59)]$BackupMinute, [Parameter(Mandatory=$true)][ValidateSet('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday')][Array]$BackupDays = $null, - [Parameter(Mandatory=$true)][Integer]$MaxCount, + [Parameter(Mandatory=$true)][Int]$MaxCount, [Parameter(Mandatory=$false)]$BackupID = "default", [Parameter(Mandatory=$false)]$CisServer = $global:DefaultCisServers, [Parameter(Mandatory=$false)][switch]$IncludeSeat, From 5df407071745f77c66d9dfffe7feb9e28d2d3896 Mon Sep 17 00:00:00 2001 From: Joshua Post Date: Mon, 24 May 2021 14:48:19 -0500 Subject: [PATCH 5/6] Encrypt Backup is option in VAMI Change Mandatory to false so it can be optional as shown in the VAMI GUI --- Modules/Backup-VCSA/Backup-VCSA.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Backup-VCSA/Backup-VCSA.psm1 b/Modules/Backup-VCSA/Backup-VCSA.psm1 index 2a194f1..ca77a54 100644 --- a/Modules/Backup-VCSA/Backup-VCSA.psm1 +++ b/Modules/Backup-VCSA/Backup-VCSA.psm1 @@ -275,7 +275,7 @@ Function New-VCSASchedule { [Parameter(Mandatory=$true)]$Location, [Parameter(Mandatory=$true)]$LocationUser, [Parameter(Mandatory=$true)][VMware.VimAutomation.Cis.Core.Types.V1.Secret]$LocationPassword, - [Parameter(Mandatory=$true)][VMware.VimAutomation.Cis.Core.Types.V1.Secret]$BackupPassword, + [Parameter(Mandatory=$false)][VMware.VimAutomation.Cis.Core.Types.V1.Secret]$BackupPassword, [Parameter(Mandatory=$true)][ValidateRange(0,23)]$BackupHour, [Parameter(Mandatory=$true)][ValidateRange(0,59)]$BackupMinute, [Parameter(Mandatory=$true)][ValidateSet('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday')][Array]$BackupDays = $null, From 5a45f4ec857755609c8b42517df4331528a213fa Mon Sep 17 00:00:00 2001 From: Joshua Post Date: Mon, 24 May 2021 14:50:28 -0500 Subject: [PATCH 6/6] BackupDays must be all caps for API call to work When days are in mixed or lower case, the schedule summary page shows the correct day, but editing the schedule shows a blank and scheduled executions do not happen. API reference shows it in all caps which does work as expected. Attempted to use .ToUpper() on line 319 but it resulted in an error Changing validation to require it in all caps --- Modules/Backup-VCSA/Backup-VCSA.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Backup-VCSA/Backup-VCSA.psm1 b/Modules/Backup-VCSA/Backup-VCSA.psm1 index ca77a54..ee59f74 100644 --- a/Modules/Backup-VCSA/Backup-VCSA.psm1 +++ b/Modules/Backup-VCSA/Backup-VCSA.psm1 @@ -278,7 +278,7 @@ Function New-VCSASchedule { [Parameter(Mandatory=$false)][VMware.VimAutomation.Cis.Core.Types.V1.Secret]$BackupPassword, [Parameter(Mandatory=$true)][ValidateRange(0,23)]$BackupHour, [Parameter(Mandatory=$true)][ValidateRange(0,59)]$BackupMinute, - [Parameter(Mandatory=$true)][ValidateSet('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday')][Array]$BackupDays = $null, + [Parameter(Mandatory=$true)][ValidateSet('MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY', IgnoreCase = $False)][Array]$BackupDays = $null, [Parameter(Mandatory=$true)][Int]$MaxCount, [Parameter(Mandatory=$false)]$BackupID = "default", [Parameter(Mandatory=$false)]$CisServer = $global:DefaultCisServers,