Files
management-scripts/Fix-EmberkomCloudBackupProductEdition.ps1
2024-02-01 11:08:42 -05:00

34 lines
1.4 KiB
PowerShell

# This script requires the $Edition variable is set from the RMM script
If (! $Edition ) { $Edition = 'desktop' }
# Set the correct download URL and agent edition
switch ( $Edition.ToLower() ) {
'server' { $AgentEdition = 'baremetal' }
'desktop' { $AgentEdition = 'desktop' }
'vm' { $AgentEdition = 'vmedition' }
default { $AgentEdition = 'desktop' }
}
# Install and import additional Powershell module
Import-MSP360Module
# Exit this script if the agent is not installed
If ( !($(Get-MBSAgent -ErrorAction SilentlyContinue)) ) {
Microsoft.Powershell.Utility\Write-Output "Backup agent is not installed. This script will now exit."
Return
}
# Set the agent edition
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
Write-Output "Removing desktop icon"
Remove-Item -Path "${Env:PUBLIC}\Desktop\Emberkom Backup.LNK" -Force -ErrorAction SilentlyContinue
Remove-Item -Path "${Env:PUBLIC}\Desktop\Emberkom Cloud Backup.LNK" -Force -ErrorAction SilentlyContinue