Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions HPCMLS/Detect.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#HP HPCMLS Detection Script
#HP HPCMSL Detection Script
#Created by:
#Jan Ketil Skanke & Maurice Daly
#MSEndpointMgr.com

#Declarations

$PSRepository = "PSGallery"

#Start Detection
#Validate that script is executed on HP hardware
$Manufacturer = (Get-WmiObject -Class "Win32_ComputerSystem" | Select-Object -ExpandProperty Manufacturer).Trim()
Expand Down Expand Up @@ -30,19 +34,19 @@ if ($Providers.Name -notcontains "NuGet") {

if ($ProviderInstalled) {
$PowerShellGetInstalledModule = Get-InstalledModule -Name "PowerShellGet" -ErrorAction SilentlyContinue -Verbose:$false
if ($PowerShellGetInstalledModule -ne $null) {
if ($null -ne $PowerShellGetInstalledModule) {
try {
# Attempt to locate the latest available version of the PowerShellGet module from repository
Write-Output "Attempting to request the latest PowerShellGet module version from repository"
$PowerShellGetLatestModule = Find-Module -Name "PowerShellGet" -ErrorAction Stop -Verbose:$false
if ($PowerShellGetLatestModule -ne $null) {
if ($null -ne $PowerShellGetLatestModule) {
if ($PowerShellGetInstalledModule.Version -lt $PowerShellGetLatestModule.Version) {
Write-Output "Newer PowerShellGet version detected, update from repository is needed";exit 1
} else {
Write-Output "PowershellGet is Ready"
$HPInstalledModule = Get-InstalledModule | Where-Object {$_.Name -match "HPCMSL"} -ErrorAction SilentlyContinue -Verbose:$false
if ($HPInstalledModule -ne $null) {
$HPGetLatestModule = Find-Module -Name "HPCMSL" -ErrorAction Stop -Verbose:$false
if ($null -ne $HPInstalledModule) {
$HPGetLatestModule = Find-Module -Name "HPCMSL" -Repository $PSRepository -ErrorAction Stop -Verbose:$false
if ($HPInstalledModule.Version -lt $HPGetLatestModule.Version) {
Write-Output "Newer HPCMSL version detected, update from repository is needed";exit 1
} else {
Expand All @@ -62,4 +66,4 @@ if ($ProviderInstalled) {
} else {
Write-Output "PowershellGet module is missing"; exit 1
}
}
}
22 changes: 13 additions & 9 deletions HPCMLS/Remeditate.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#HP HPCMLS Detection Script
#HP HPCMSL Detection Script
#Created by:
#Jan Ketil Skanke & Maurice Daly
#MSEndpointMgr.com
#Start-PowerShellSysNative is inspired by @NickolajA's method to install the HPCMLS module

#Declarations

$PSRepository = "PSGallery"

#Start remediate
#This remediation must run in system context and in 64bit powershell.
function Start-PowerShellSysNative {
Expand Down Expand Up @@ -64,12 +68,12 @@ catch [System.Exception] {
# Install the latest PowershellGet Module
if ($PackageProvider.Version -ge "2.8.5"){
$PowerShellGetInstalledModule = Get-InstalledModule -Name "PowerShellGet" -ErrorAction SilentlyContinue -Verbose:$false
if ($PowerShellGetInstalledModule -ne $null) {
if ($null -ne $PowerShellGetInstalledModule) {
try {
# Attempt to locate the latest available version of the PowerShellGet module from repository
Write-Output "Attempting to request the latest PowerShellGet module version from repository"
$PowerShellGetLatestModule = Find-Module -Name "PowerShellGet" -ErrorAction Stop -Verbose:$false
if ($PowerShellGetLatestModule -ne $null) {
$PowerShellGetLatestModule = Find-Module -Name "PowerShellGet" -Repository $PSRepository -ErrorAction Stop -Verbose:$false
if ($null -ne $PowerShellGetLatestModule) {
if ($PowerShellGetInstalledModule.Version -lt $PowerShellGetLatestModule.Version) {
try {
# Newer module detected, attempt to update
Expand All @@ -93,9 +97,9 @@ if ($PackageProvider.Version -ge "2.8.5"){
# PowerShellGet module was not found, attempt to install from repository
Write-Output "PowerShellGet module was not found, attempting to install it including dependencies from repository"
Write-Output "Attempting to install PackageManagement module from repository"
Install-Module -Name "PackageManagement" -Force -Scope AllUsers -AllowClobber -ErrorAction Stop -Verbose:$false
Install-Module -Name "PackageManagement" -Repository $PSRepository -Force -Scope AllUsers -AllowClobber -ErrorAction Stop -Verbose:$false
Write-Output "Attempting to install PowerShellGet module from repository"
Install-Module -Name "PowerShellGet" -Force -Scope AllUsers -AllowClobber -ErrorAction Stop -Verbose:$false
Install-Module -Name "PowerShellGet" -Repository $PSRepository -Force -Scope AllUsers -AllowClobber -ErrorAction Stop -Verbose:$false
}
catch [System.Exception] {
Write-Output "Unable to install PowerShellGet module from repository. Error message: $($_.Exception.Message)"; exit 1
Expand All @@ -104,8 +108,8 @@ if ($PackageProvider.Version -ge "2.8.5"){

#Install the latest HPCMSL Module
$HPInstalledModule = Get-InstalledModule | Where-Object {$_.Name -match "HPCMSL"} -ErrorAction SilentlyContinue -Verbose:$false
if ($HPInstalledModule -ne $null) {
$HPGetLatestModule = Find-Module -Name "HPCMSL" -ErrorAction Stop -Verbose:$false
if ($null -ne $HPInstalledModule) {
$HPGetLatestModule = Find-Module -Name "HPCMSL" -Repository $PSRepository -ErrorAction Stop -Verbose:$false
if ($HPInstalledModule.Version -lt $HPGetLatestModule.Version) {
Write-Output "Newer HPCMSL version detected, updating from repository"
$scriptBlock = {
Expand All @@ -128,7 +132,7 @@ if ($PackageProvider.Version -ge "2.8.5"){
try {
# Install HP Client Management Script Library
Write-Output -Value "Attempting to install HPCMSL module from repository"
Install-Module -Name "HPCMSL" -AcceptLicense -Force -ErrorAction Stop -Verbose:$false
Install-Module -Name "HPCMSL" -Repository $PSRepository -AcceptLicense -Force -ErrorAction Stop -Verbose:$false
}
catch [System.Exception] {
Write-OutPut -Value "Unable to install HPCMSL module from repository. Error message: $($_.Exception.Message)"; exit 1
Expand Down