From a8fa66a5404184c40796c1785e307d42d95bbd04 Mon Sep 17 00:00:00 2001 From: jaromirk Date: Wed, 18 May 2022 22:26:15 +0200 Subject: [PATCH] small fixes --- Tools/DownloadLatestCUs.ps1 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Tools/DownloadLatestCUs.ps1 b/Tools/DownloadLatestCUs.ps1 index c73e1f01..a5ff2998 100644 --- a/Tools/DownloadLatestCUs.ps1 +++ b/Tools/DownloadLatestCUs.ps1 @@ -1,6 +1,6 @@ #region download MSCatalog module -Write-Output "Checking if MSCatalog PS Module is Installed" -if (!(Get-InstalledModule -Name MSCatalog -ErrorAction Ignore).version -ne ((Find-Module mscatalog).version)){ +Write-Output "Checking if latest MSCatalog PS Module is Installed" +if ((Get-InstalledModule -Name MSCatalog -ErrorAction Ignore).version -ne ((Find-Module mscatalog).version)){ # Verify Running as Admin $isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") If (!( $isAdmin )) { @@ -25,13 +25,15 @@ if ($version.Minor -eq 27){ #patch $ContentNew=$Content.Replace($Regex1,$Regex2) if (Compare-Object $ContentNew $Content){ + Write-Output "Current version of MSCatalog needs to be patched" # Verify Running as Admin $isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") If (!( $isAdmin )) { - Write-Host "-- Restarting as Administrator to install Modules" -ForegroundColor Cyan ; Start-Sleep -Seconds 1 + Write-Host "-- Restarting as Administrator to patch MSCatalog module" -ForegroundColor Cyan ; Start-Sleep -Seconds 1 Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs exit } + Write-Output "Writing new Get-UpdateLinks.ps1 content" $ContentNew | Out-File "C:\Program Files\WindowsPowerShell\Modules\MSCatalog\$version\Private\Get-UpdateLinks.ps1" } }