# Install and update use the same published Emberkom packages. switch ($Edition) { 'server' { $CloudBackupBuild = 'Windows'; $AgentEdition = 'baremetal' } 'vm' { $CloudBackupBuild = 'VM'; $AgentEdition = 'vmedition' } default { $CloudBackupBuild = 'Windows'; $AgentEdition = 'desktop' } } # Install and import additional Powershell module Import-MSP360Module # Exit this script if the agent is already installed If ( $(Get-MBSAgent -ErrorAction SilentlyContinue) ) { Microsoft.Powershell.Utility\Write-Output "Backup agent is already installed. This script will now exit." Return } $CloudBackupRelease = Get-EmberkomCloudBackupRelease -Build $CloudBackupBuild $Installer = Join-Path (Get-TempPath) ("EmberkomCloudBackup-{0}.exe" -f [guid]::NewGuid()) Save-EmberkomCloudBackupInstaller -Release $CloudBackupRelease -Path $Installer # 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 Write-Output "Adding backup user account: ${MSP360Username}" Try { Add-MBSUserAccount -User $MSP360Username -Password $(ConvertTo-SecureString -string $MSP360Password -AsPlainText -Force) } 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 $Installer If ( Test-Path $Installer ) { Write-Output "Deleting downloaded file: ${Installer}" ; Remove-Item $Installer -Force -ErrorAction SilentlyContinue } # 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 }