move powershell module installs to Tools.ps1
update Install-EmberkomCloudBackup.ps1
This commit is contained in:
@@ -15,10 +15,11 @@ switch ( $Edition.ToLower() ) {
|
||||
default { $URL = $ECB_WIN_URL; $AgentEdition = 'desktop' }
|
||||
}
|
||||
|
||||
## Install and import the MSP360 Powershell module
|
||||
Run-Script -LivePSScript Install-MSP360PowershellModule
|
||||
LogMsg "Importing MSP360 Powershell module"
|
||||
## Install and import additional Powershell modules
|
||||
Install-MSP360Module
|
||||
Import-Module -Name MSP360
|
||||
Install-PSAteraModule
|
||||
Import-Module -Name PSAtera
|
||||
|
||||
## Install the agent
|
||||
$INSTALLER = Download-File -URL $URL
|
||||
@@ -36,15 +37,10 @@ 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
|
||||
Try {
|
||||
LogMsg "Getting Atera agent and custom field information"
|
||||
Set-AteraAPIKey = $AteraAPIKey
|
||||
$AteraAgent = Get-AteraAgent
|
||||
$MSP360Username = Get-AteraCustomValue -ObjectType Customer -ObjectId $AteraAgent.CustomerID -FieldName 'MSP360 Account Username'
|
||||
$MSP360Password = Get-AteraCustomValue -ObjectType Customer -ObjectId $AteraAgent.CustomerID -FieldName 'MSP360 Account Password'
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
## Check if the MSP360 module needs to be installed
|
||||
If (-not (Get-Module -ListAvailable -Name MSP360) ) {
|
||||
|
||||
LogMsg "Setting Powershell Execution Policy to Unrestricted for this script"
|
||||
Try { Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process }
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
|
||||
LogMsg "Downloading and installing MSP360 Powershell module"
|
||||
Try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://git.io/JUSAA'); Install-MSP360Module }
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
|
||||
} Else { LogMsg "MSP360 Powershell module is already installed" }
|
||||
@@ -1,37 +0,0 @@
|
||||
## Define settings for PSAtera module
|
||||
$PSAteraMinimumModuleVersion = '1.5.7'
|
||||
|
||||
## Get the PSAtera module if it's installed
|
||||
$module = (Get-Module -ListAvailable -Name PSAtera)
|
||||
|
||||
## Install only if we're an admin
|
||||
If ( IsAdmin ) {
|
||||
|
||||
## If the module is installed, check to make sure it's updated
|
||||
If ( $module ) {
|
||||
[version]$current = $module.Version
|
||||
[version]$minimum = (Get-Version $Global:PSAteraMinimumModuleVersion)
|
||||
If ( $current -lt $minimum ) {
|
||||
LogMsg "Updating Powershell module PSAtera"
|
||||
Try { Update-Module -Name PSAtera -Force }
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
}
|
||||
}
|
||||
|
||||
## If it's not already installed, install it
|
||||
Else {
|
||||
Try { [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityPotocol -bor 3072 }
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
|
||||
LogMsg "Installing NuGet package manager"
|
||||
Try { Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force}
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
|
||||
LogMsg "Installing Powershell module PSAtera"
|
||||
Try { Install-Module -Name PSAtera -MinimumVersion $(Get-Version $PSAteraMinimumModuleVersion) -Force}
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
}
|
||||
}
|
||||
ElseIf ( ($Global:InstallPSAteraModule) -and (-not ($module)) ) {
|
||||
LogMsg "The PSAtera module needs to be installed, but the current security context is not sufficient to install it"
|
||||
}
|
||||
@@ -481,5 +481,40 @@ function Toggle-Log {
|
||||
Catch { LogMsg $_.Exception.Message }
|
||||
}
|
||||
|
||||
# Function to install the PSAtera Powershell module
|
||||
function Install-PSAteraModule {
|
||||
Try {
|
||||
$module = Get-Module -ListAvailable -Name PSAtera
|
||||
If ( (-not $module) -and (IsAdmin) ) {
|
||||
LogMsg "Installing PSAtera Powershell module"
|
||||
Install-Module -Name PSAtera -MinimumVersion 2.8.5.201
|
||||
}
|
||||
ElseIf ( (-not $module) -and (-not (IsAdmin)) ) {
|
||||
LogMsg "The PSAtera module needs to be installed, but the current security context is not sufficient to install it"
|
||||
}
|
||||
ElseIf ( ($module) -and (IsAdmin) ) {
|
||||
LogMsg "Updating PSAtera Powershell module"
|
||||
Update-Module -Name PSAtera -Force
|
||||
}
|
||||
}
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
}
|
||||
|
||||
# Function to install the MSP360 Powershell module
|
||||
function Install-MSP360Module {
|
||||
Try {
|
||||
$module = Get-Module -ListAvailable -Name MSP360
|
||||
If ( (-not $module) -and (IsAdmin) ) {
|
||||
LogMsg "Installing MSP360 Powershell module"
|
||||
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://git.io/JUSAA'); Install-MSP360Module
|
||||
}
|
||||
ElseIf ( (-not $module) -and (-not (IsAdmin)) ) {
|
||||
LogMsg "The MSP360 Powershell module needs to be installed, but the current security context is not sufficient to install it"
|
||||
}
|
||||
}
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
}
|
||||
|
||||
Setup-MSPDirectories
|
||||
Setup-LogFile
|
||||
Reference in New Issue
Block a user