From d542a56ed73d5d25d1844fda402754340eddb009 Mon Sep 17 00:00:00 2001 From: David Yoder Date: Thu, 1 Feb 2024 11:03:10 -0500 Subject: [PATCH] minor changes --- Fix-EmberkomCloudBackupProductEdition.ps1 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Fix-EmberkomCloudBackupProductEdition.ps1 b/Fix-EmberkomCloudBackupProductEdition.ps1 index 6443a34..6dda0ca 100644 --- a/Fix-EmberkomCloudBackupProductEdition.ps1 +++ b/Fix-EmberkomCloudBackupProductEdition.ps1 @@ -12,18 +12,20 @@ switch ( $Edition.ToLower() ) { # Install and import additional Powershell module Import-MSP360Module -# 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 } +# 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 -# Note: the product edition must be set *after* the user is added Write-Output "Setting Emberkom Cloud Backup agent edition to ""$AgentEdition""" -Try { Set-MBSAgentSetting -Edition $AgentEdition -Verbose } +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