Files
management-scripts/Install-EmberkomCloudBackup.ps1
T

53 lines
2.6 KiB
PowerShell

# Specify URL to "Backup for Windows" agent installer
$ECB_WIN_URL = 'https://s3.amazonaws.com/cb_setups/MBS/53CFB286-7A97-4FDF-8CFA-475C0DB63A9A/Brands/FB8308E2-448A-4645-A5F6-A3632A7E57F4/EmberkomCloudBackup_v7.9.2.266_ALLEDITIONS_Setup.exe'
# Specify URL to "Backup Virtual Machine Edition" agent installer
$ECB_VMM_URL = 'https://s3.amazonaws.com/cb_setups/MBS/53CFB286-7A97-4FDF-8CFA-475C0DB63A9A/Brands/FB8308E2-448A-4645-A5F6-A3632A7E57F4/EmberkomCloudBackup_v7.9.2.266_VMWARE_Setup.exe'
# Set the correct download URL and agent edition
switch ( $Edition.ToLower() ) {
'server' { $URL = $ECB_WIN_URL; $AgentEdition = 'baremetal' }
'desktop' { $URL = $ECB_WIN_URL; $AgentEdition = 'desktop' }
'vm' { $URL = $ECB_VMM_URL; $AgentEdition = 'vmedition' }
default { $URL = $ECB_WIN_URL; $AgentEdition = 'desktop' }
}
# Install and import additional Powershell module
Import-MSP360Module
# Exit this script if the agent is already installed
If ( $(Get-MBSAgent) ) {
Microsoft.Powershell.Utility\Write-Output "Backup agent is already installed. This script will now exit."
Return
}
# Download the installer
$Installer = Download-File -URL $URL
# Install the agent
Write-Output "Installing Emberkom Cloud Backup agent"
Try { Start-Process "${Installer}" -ArgumentList "/S" -Wait }
Catch { Write-Error $_.Exception.Message }
# Add backup user to installed product
Try {
$MSP360Password = ConvertTo-SecureString -string $MSP360Password -AsPlainText -Force
Write-Output "Adding backup user account: ${MSP360Username}"
Add-MBSUserAccount -User $MSP360Username -Password $MSP360Password
}
Catch { Write-Error $_.Exception.Message }
# Wait a few seconds to let the agent check-in
Start-Sleep -Seconds 10
# Set the agent edition
# Note: the product edition must be set *after* the user is added
Write-Output "Setting Emberkom Cloud Backup agent edition to ""$AgentEdition"""
Try {
Switch ([string]::IsNullOrEmpty($MasterPassword)) {
$true { Set-MBSAgentSetting -Edition $AgentEdition -Verbose }
$false { Set-MBSAgentSetting -Edition $AgentEdition -MasterPassword (ConvertTo-SecureString -String $MasterPassword -AsPlainText -Force) -Verbose }
}
}
Catch { Write-Error $_.Exception.Message }
# Delete the desktop icon
If ( Test-Path "${Env:PUBLIC}\Desktop\Emberkom Backup.LNK" ) { Remove-Item -Path "${Env:PUBLIC}\Desktop\Emberkom Backup.LNK" -Force -ErrorAction SilentlyContinue }
If ( Test-Path "${Env:PUBLIC}\Desktop\Emberkom Cloud Backup.LNK" ) { Remove-Item -Path "${Env:PUBLIC}\Desktop\Emberkom Cloud Backup.LNK" -Force -ErrorAction SilentlyContinue }