fix: improve MSP360 module import and installation process

This commit is contained in:
2026-05-29 11:24:53 -04:00
parent d2824cb771
commit 9d36fabf00
+5 -3
View File
@@ -585,15 +585,17 @@ Function Disable-Log {
# Function to install the MSP360 Powershell module
Function Import-MSP360Module {
Try {
$Module = Get-Module -ListAvailable -Name MSP360,msp360 | Sort-Object Version -Descending | Select-Object -First 1
If ( $Module ) { Import-Module -Name $Module.Name -Force -ErrorAction Stop ; Return }
If ( -not (IsAdmin) ) { Write-Output "The MSP360 Powershell module needs to be installed, but the current account is not an administrative user" ; Return }
Write-Output "Installing MSP360 Powershell module"
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Force
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/msp360/MSP360-PSModule/master/private/Install-MSP360Module.ps1')
Install-MSP360Module
Import-Module -Name MSP360
Import-Module -Name MSP360 -Force -ErrorAction Stop
}
Catch { Write-Error $_.Exception.Message }
Catch { Write-Error "Could not import or install MSP360 PowerShell module: $($_.Exception.Message)" }
}
# Function to ZIP a file or directory, returns the newly created zip file