separate PSAtera module install into separate script
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
## Define settings for PSAtera module
|
||||||
|
$PSAteraMinimumModuleVersion = '1.5.7'
|
||||||
|
|
||||||
|
## Get the PSAtera module if it's installed
|
||||||
|
$module = (Get-Module -ListAvailable 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"
|
||||||
|
}
|
||||||
@@ -1,11 +1,6 @@
|
|||||||
## Define the MSP name
|
## Define the MSP name
|
||||||
[string]$Global:MSPName = "Emberkom"
|
[string]$Global:MSPName = "Emberkom"
|
||||||
|
|
||||||
## Define settings for PSAtera module
|
|
||||||
[string]$Global:PSAteraMinimumModuleVersion = '1.5.7'
|
|
||||||
[bool]$Global:InstallPSAteraModule = $false
|
|
||||||
|
|
||||||
|
|
||||||
## This section will define several global variables that can be used in scripts that source this one
|
## This section will define several global variables that can be used in scripts that source this one
|
||||||
[string]$Global:RootDirectory
|
[string]$Global:RootDirectory
|
||||||
[string]$Global:ScriptsDirectory
|
[string]$Global:ScriptsDirectory
|
||||||
@@ -486,35 +481,5 @@ function Toggle-Log {
|
|||||||
Catch { LogMsg $_.Exception.Message }
|
Catch { LogMsg $_.Exception.Message }
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Install-PSAteraModule {
|
|
||||||
$module = (Get-Module -ListAvailable PSAtera)
|
|
||||||
If ( IsAdmin ) {
|
|
||||||
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 }
|
|
||||||
}
|
|
||||||
} 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 PSAtera -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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Setup-MSPDirectories
|
Setup-MSPDirectories
|
||||||
Setup-LogFile
|
Setup-LogFile
|
||||||
If ( $Global:InstallPSAteraModule ) { Install-PSAteraModule }
|
|
||||||
Reference in New Issue
Block a user