add update script for cloud backup

This commit is contained in:
2026-11-17 00:13:07 -05:00
parent f2830cb10a
commit 467f699103
8 changed files with 426 additions and 64 deletions
+62
View File
@@ -219,6 +219,38 @@ Function ConvertTo-RmmBoolean {
}
}
# Convert an RMM semicolon-separated text variable into individual strings.
Function ConvertTo-RmmList {
<#
.SYNOPSIS
Splits an RMM text value on semicolons and trims each item.
.DESCRIPTION
Null, blank, and empty items are omitted. Item order, case, duplicates,
internal spaces, commas, and backslashes are preserved. Values are not
evaluated, expanded, resolved, or checked for existence. Semicolons are
always separators; there is no quoting or escaping syntax.
Wrap the call in @() to obtain an array for zero, one, or many items.
.EXAMPLE
$Paths = @(ConvertTo-RmmList -Value 'C:\QB Data; \\server\Archive;')
.EXAMPLE
$Shares = @(ConvertTo-RmmList -Value $QuickBooksShareNames)
#>
[CmdletBinding()]
[OutputType([string])]
param(
[Parameter(Mandatory=$true,Position=0,ValueFromPipeline=$true)]
[AllowNull()]
[AllowEmptyString()]
[string]$Value
)
process {
foreach ($Item in ([string]$Value).Split(';')) {
$Item = $Item.Trim()
if ($Item.Length -gt 0) { $Item }
}
}
}
# Determines whether a URL is valid
Function IsURLValid {
param([Parameter(Mandatory=$true,ValueFromPipeline=$true)][string]$URL)
@@ -853,6 +885,36 @@ Function Disable-Log {
Catch { Write-Error $_.Exception.Message }
}
# Published packages for both Install- and Update-EmberkomCloudBackup.
Function Get-EmberkomCloudBackupRelease {
param([Parameter(Mandatory=$true)][ValidateSet('Windows','VM')][string]$Build)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$client = New-Object Net.WebClient
try {
$json = $client.DownloadString('https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/resources/EmberkomCloudBackup.json')
} finally { $client.Dispose() }
$release = ($json | ConvertFrom-Json -ErrorAction Stop).$Build
if ($release.Version -notmatch '^\d+\.\d+\.\d+\.\d+$' -or $release.Url -notmatch '^https://' -or
$release.SHA256 -notmatch '^[a-f0-9]{64}$') {
throw "Incomplete Emberkom Cloud Backup release for $Build."
}
return $release
}
Function Save-EmberkomCloudBackupInstaller {
param([Parameter(Mandatory=$true)]$Release, [Parameter(Mandatory=$true)][string]$Path)
$client = New-Object Net.WebClient
try {
$client.DownloadFile($Release.Url, $Path)
if ((Get-FileHash -LiteralPath $Path -Algorithm SHA256 -ErrorAction Stop).Hash -ne $Release.SHA256) {
throw 'The installer SHA-256 does not match the published release.'
}
} catch {
if (Test-Path -LiteralPath $Path) { Remove-Item -LiteralPath $Path -Force -ErrorAction Stop }
throw
} finally { $client.Dispose() }
}
# Function to install the MSP360 Powershell module
Function Import-MSP360Module {
Try {