Files
management-scripts/Install-EmberkomCloudBackup.ps1
T

58 lines
2.6 KiB
PowerShell
Raw Normal View History

2021-09-22 16:22:14 -04:00
## This script requires the $Edition variable is set from the RMM script
If (! $Edition ) { $Edition = 'desktop' }
2021-09-22 14:51:23 -04:00
## Specify URL to "Backup for Windows" agent installer
$ECB_WIN_URL = 'https://s3.amazonaws.com/cb_setups/MBS/53CFB286-7A97-4FDF-8CFA-475C0DB63A9A/EmberkomEmberkomBackup_v7.2.0.280_netv4.0_ALLEDITIONS_Setup_20210914204936.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/EmberkomEmberkomBackup_v7.2.0.280_netv4.0_VM_Setup_20210914205143.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 the MSP360 Powershell module
Run-Script -LivePSScript Install-MSP360PowershellModule
LogMsg "Importing MSP360 Powershell module"
2021-09-22 14:51:23 -04:00
Import-Module -Name MSP360
## Install the agent
$INSTALLER = Download-File -URL $URL
LogMsg "Installing Emberkom Cloud Backup agent"
Try { Start-Process $INSTALLER -ArgumentList "/S" -Wait }
2021-09-22 14:51:23 -04:00
Catch { LogErr $_.Exception.Message }
If ( Test-Path $INSTALLER ) {
LogMsg "Deleting Emberkom Cloud Backup agent installer: ""${INSTALLER}"""
Try { Remove-Item $INSTALLER -Force }
Catch { LogErr $_.Exception.Message }
}
2021-09-22 14:51:23 -04:00
## Set the agent edition
LogMsg "Setting Emberkom Cloud Backup agent edition to ""$AgentEdition"""
Try { Set-MBSAgentSetting -Edition $AgentEdition }
Catch { $_.Exception.Message }
## Install and import the PSAtera Powershell Module
Run-Script -LivePSScript Install-PSAteraModule
LogMsg "Importing PSAtera Powershell module"
Import-Module -Name PSAtera
Set-AteraAPIKey = $AteraAPIKey
## Get agent details and custom fields from Atera
LogMsg "Getting Atera agent and custom field information"
Try {
$AteraAgent = Get-AteraAgent
$MSP360Username = Get-AteraCustomValue -ObjectType Customer -ObjectId $agent.CustomerID -FieldName 'MSP360 Account Username'
$MSP360Password = Get-AteraCustomValue -ObjectType Customer -ObjectId $agent.CustomerID -FieldName 'MSP360 Account Password'
$MSP360Password = ConvertTo-SecureString -string $MSP360Password -AsPlainText -Force
}
Catch { LogErr $_.Exception.Message }
## Add account and password
LogMsg "Adding backup user account: ${MSP360Username}"
Try { Add-MBSUserAccount -User $MSP360Username -Password $MSP360Password }
Catch { LogErr $_.Exception.Message }