From 4112723a918ea82caadbf6dfd9ad343c7021a521 Mon Sep 17 00:00:00 2001 From: Jaromir Kaspar Date: Fri, 12 Mar 2021 13:39:36 +0100 Subject: [PATCH 01/17] exact unattend file location --- Scripts/3_Deploy.ps1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Scripts/3_Deploy.ps1 b/Scripts/3_Deploy.ps1 index dd2507cd..f4e06f2e 100644 --- a/Scripts/3_Deploy.ps1 +++ b/Scripts/3_Deploy.ps1 @@ -32,10 +32,10 @@ If (-not $isAdmin) { $RunSynchronous ) - if ( Test-Path "Unattend.xml" ) { - Remove-Item .\Unattend.xml + if ( Test-Path "$PSScriptRoot\unattend.xml" ) { + Remove-Item "$PSScriptRoot\unattend.xml" } - $unattendFile = New-Item "Unattend.xml" -type File + $unattendFile = New-Item "$PSScriptRoot\unattend.xml" -type File $fileContent = @" @@ -105,10 +105,10 @@ If (-not $isAdmin) { $AdditionalAccount ) - if ( Test-Path "Unattend.xml" ) { - Remove-Item .\Unattend.xml + if ( Test-Path "$PSScriptRoot\unattend.xml" ) { + Remove-Item "$PSScriptRoot\unattend.xml" } - $unattendFile = New-Item "Unattend.xml" -type File + $unattendFile = New-Item "$PSScriptRoot\unattend.xml" -type File $fileContent = @" @@ -170,10 +170,10 @@ If (-not $isAdmin) { [string] $DomainName ) - if ( Test-Path "Unattend.xml" ) { - Remove-Item .\Unattend.xml + if ( Test-Path "$PSScriptRoot\unattend.xml" ) { + Remove-Item "$PSScriptRoot\unattend.xml" } - $unattendFile = New-Item "Unattend.xml" -type File + $unattendFile = New-Item "$PSScriptRoot\unattend.xml" -type File $fileContent = @" From 69d5651d4b1b13bc1620c3dea9e3443b0dcd1797 Mon Sep 17 00:00:00 2001 From: Jaromir Kaspar Date: Tue, 16 Mar 2021 11:09:43 +0100 Subject: [PATCH 02/17] gen2 VM --- Scenarios/Azure Image Builder/Scenario.ps1 | 12 ++++++------ Scenarios/Azure Image Builder/armTemplateWVD.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Scenarios/Azure Image Builder/Scenario.ps1 b/Scenarios/Azure Image Builder/Scenario.ps1 index ae309a09..e3e4169b 100644 --- a/Scenarios/Azure Image Builder/Scenario.ps1 +++ b/Scenarios/Azure Image Builder/Scenario.ps1 @@ -104,7 +104,7 @@ #location $location="westeurope" # ImageDefinitionName - $imageDefName ="Windows10_20H2_WVD" + $imageDefName ="Win10_20H2_WVD_G2" #Subscription ID $subscriptionID = (Get-AzContext).Subscription.Id # Create the gallery @@ -121,8 +121,8 @@ OsType = 'Windows' Publisher = 'WSLab-MicrosoftWindowsDesktop' Offer = 'WSLab-office-365' - Sku = 'WSLab-20h2-evd-o365pp' - HyperVGeneration = 'V1' + Sku = 'WSLab-20h2-evd-g2-o365pp' + HyperVGeneration = 'V2' } New-AzGalleryImageDefinition @GalleryParams @@ -134,7 +134,7 @@ #name of Identity for Azure Image Builder Service $identityName="AzureImageBuilderService" # ImageDefinitionName - $imageDefName ="Windows10_20H2_WVD" + $imageDefName ="Win10_20H2_WVD_G2" #Image gallery name $sigGalleryName= "AzureImageBuilderSharedGallery" #grab identity @@ -144,8 +144,8 @@ # Azure replication region $replocation = 'northeurope' # Name of the image to be created - $date=get-date -Format "dd-MM-yy" - $imageTemplateName = "Windows10_20H2_WVD_$date" + $date=get-date -Format "yyMMdd" + $imageTemplateName = "Win10_20H2_WVD_G2_$date" # Distribution properties of the managed image upon completion $runOutputName = 'myDistResults' # Grab Subscription ID diff --git a/Scenarios/Azure Image Builder/armTemplateWVD.json b/Scenarios/Azure Image Builder/armTemplateWVD.json index 8dc54179..164e942c 100644 --- a/Scenarios/Azure Image Builder/armTemplateWVD.json +++ b/Scenarios/Azure Image Builder/armTemplateWVD.json @@ -49,7 +49,7 @@ "type": "PlatformImage", "publisher": "MicrosoftWindowsDesktop", "offer": "windows-10", - "sku": "20h2-evd", + "sku": "20h2-evd-g2", "version": "latest" }, From 6530a6976e2d80095b9f67a4ebbb371f964b4f24 Mon Sep 17 00:00:00 2001 From: Jaromir Kaspar Date: Tue, 16 Mar 2021 11:37:04 +0100 Subject: [PATCH 03/17] vmsize name fix --- Scenarios/Azure Image Builder/armTemplateWVD.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scenarios/Azure Image Builder/armTemplateWVD.json b/Scenarios/Azure Image Builder/armTemplateWVD.json index 164e942c..72ebea4a 100644 --- a/Scenarios/Azure Image Builder/armTemplateWVD.json +++ b/Scenarios/Azure Image Builder/armTemplateWVD.json @@ -41,7 +41,7 @@ "vmProfile": { - "vmSize": "Standard_D2_v2", + "vmSize": "Standard_DS2_v2", "osDiskSizeGB": 127 }, From 0b049f7765f6e5f681f74b57cdad4c87439d346e Mon Sep 17 00:00:00 2001 From: Jaromir Kaspar Date: Tue, 16 Mar 2021 12:15:42 +0100 Subject: [PATCH 04/17] osdisksizegb changed --- Scenarios/Azure Image Builder/armTemplateWVD.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scenarios/Azure Image Builder/armTemplateWVD.json b/Scenarios/Azure Image Builder/armTemplateWVD.json index 72ebea4a..b9984f4c 100644 --- a/Scenarios/Azure Image Builder/armTemplateWVD.json +++ b/Scenarios/Azure Image Builder/armTemplateWVD.json @@ -42,7 +42,7 @@ "vmProfile": { "vmSize": "Standard_DS2_v2", - "osDiskSizeGB": 127 + "osDiskSizeGB": 0 }, "source": { From aba3b950326710f9cb0a24fa559dd0d1448c1465 Mon Sep 17 00:00:00 2001 From: Jaromir Kaspar Date: Tue, 16 Mar 2021 12:34:51 +0100 Subject: [PATCH 05/17] size fix --- Scenarios/Azure Image Builder/armTemplateWVD.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scenarios/Azure Image Builder/armTemplateWVD.json b/Scenarios/Azure Image Builder/armTemplateWVD.json index b9984f4c..b01e32aa 100644 --- a/Scenarios/Azure Image Builder/armTemplateWVD.json +++ b/Scenarios/Azure Image Builder/armTemplateWVD.json @@ -41,7 +41,7 @@ "vmProfile": { - "vmSize": "Standard_DS2_v2", + "vmSize": "Standard_D2_v2", "osDiskSizeGB": 0 }, From 147eb3a011a2959e2acb39f6919ed97fb884b5be Mon Sep 17 00:00:00 2001 From: Jaromir Kaspar Date: Tue, 16 Mar 2021 12:46:10 +0100 Subject: [PATCH 06/17] size change --- Scenarios/Azure Image Builder/armTemplateWVD.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Scenarios/Azure Image Builder/armTemplateWVD.json b/Scenarios/Azure Image Builder/armTemplateWVD.json index b01e32aa..4670d3ac 100644 --- a/Scenarios/Azure Image Builder/armTemplateWVD.json +++ b/Scenarios/Azure Image Builder/armTemplateWVD.json @@ -41,8 +41,8 @@ "vmProfile": { - "vmSize": "Standard_D2_v2", - "osDiskSizeGB": 0 + "vmSize": "Standard_D2s_v4", + "osDiskSizeGB": 127 }, "source": { From 517eea12ede4ab3d0871f0d8e77855e96b89b3a6 Mon Sep 17 00:00:00 2001 From: Jaromir Kaspar Date: Tue, 16 Mar 2021 12:55:07 +0100 Subject: [PATCH 07/17] revert to gen1 --- Scenarios/Azure Image Builder/Scenario.ps1 | 10 +++++----- Scenarios/Azure Image Builder/armTemplateWVD.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Scenarios/Azure Image Builder/Scenario.ps1 b/Scenarios/Azure Image Builder/Scenario.ps1 index e3e4169b..e9d67043 100644 --- a/Scenarios/Azure Image Builder/Scenario.ps1 +++ b/Scenarios/Azure Image Builder/Scenario.ps1 @@ -104,7 +104,7 @@ #location $location="westeurope" # ImageDefinitionName - $imageDefName ="Win10_20H2_WVD_G2" + $imageDefName ="Win10_20H2_WVD" #Subscription ID $subscriptionID = (Get-AzContext).Subscription.Id # Create the gallery @@ -121,8 +121,8 @@ OsType = 'Windows' Publisher = 'WSLab-MicrosoftWindowsDesktop' Offer = 'WSLab-office-365' - Sku = 'WSLab-20h2-evd-g2-o365pp' - HyperVGeneration = 'V2' + Sku = 'WSLab-20h2-evd-o365pp' + HyperVGeneration = 'V1' } New-AzGalleryImageDefinition @GalleryParams @@ -134,7 +134,7 @@ #name of Identity for Azure Image Builder Service $identityName="AzureImageBuilderService" # ImageDefinitionName - $imageDefName ="Win10_20H2_WVD_G2" + $imageDefName ="Win10_20H2_WVD" #Image gallery name $sigGalleryName= "AzureImageBuilderSharedGallery" #grab identity @@ -145,7 +145,7 @@ $replocation = 'northeurope' # Name of the image to be created $date=get-date -Format "yyMMdd" - $imageTemplateName = "Win10_20H2_WVD_G2_$date" + $imageTemplateName = "Win10_20H2_WVD_$date" # Distribution properties of the managed image upon completion $runOutputName = 'myDistResults' # Grab Subscription ID diff --git a/Scenarios/Azure Image Builder/armTemplateWVD.json b/Scenarios/Azure Image Builder/armTemplateWVD.json index 4670d3ac..c54482d8 100644 --- a/Scenarios/Azure Image Builder/armTemplateWVD.json +++ b/Scenarios/Azure Image Builder/armTemplateWVD.json @@ -49,7 +49,7 @@ "type": "PlatformImage", "publisher": "MicrosoftWindowsDesktop", "offer": "windows-10", - "sku": "20h2-evd-g2", + "sku": "20h2-evd", "version": "latest" }, From b2368d0c7cb9edabb3ed30893554af4410211db0 Mon Sep 17 00:00:00 2001 From: Jaromir Kaspar Date: Fri, 19 Mar 2021 09:44:11 +0100 Subject: [PATCH 08/17] unattend.xml location moved --- Scripts/3_Deploy.ps1 | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/Scripts/3_Deploy.ps1 b/Scripts/3_Deploy.ps1 index f4e06f2e..b8a60010 100644 --- a/Scripts/3_Deploy.ps1 +++ b/Scripts/3_Deploy.ps1 @@ -32,10 +32,10 @@ If (-not $isAdmin) { $RunSynchronous ) - if ( Test-Path "$PSScriptRoot\unattend.xml" ) { - Remove-Item "$PSScriptRoot\unattend.xml" + if ( Test-Path "$PSScriptRoot\Temp\unattend.xml" ) { + Remove-Item "$PSScriptRoot\Temp\unattend.xml" } - $unattendFile = New-Item "$PSScriptRoot\unattend.xml" -type File + $unattendFile = New-Item "$PSScriptRoot\Temp\unattend.xml" -type File $fileContent = @" @@ -105,10 +105,10 @@ If (-not $isAdmin) { $AdditionalAccount ) - if ( Test-Path "$PSScriptRoot\unattend.xml" ) { - Remove-Item "$PSScriptRoot\unattend.xml" + if ( Test-Path "$PSScriptRoot\Temp\unattend.xml" ) { + Remove-Item "$PSScriptRoot\Temp\unattend.xml" } - $unattendFile = New-Item "$PSScriptRoot\unattend.xml" -type File + $unattendFile = New-Item "$PSScriptRoot\Temp\unattend.xml" -type File $fileContent = @" @@ -170,10 +170,10 @@ If (-not $isAdmin) { [string] $DomainName ) - if ( Test-Path "$PSScriptRoot\unattend.xml" ) { - Remove-Item "$PSScriptRoot\unattend.xml" + if ( Test-Path "$PSScriptRoot\Temp\unattend.xml" ) { + Remove-Item "$PSScriptRoot\Temp\unattend.xml" } - $unattendFile = New-Item "$PSScriptRoot\unattend.xml" -type File + $unattendFile = New-Item "$PSScriptRoot\Temp\unattend.xml" -type File $fileContent = @" @@ -1518,11 +1518,8 @@ If (-not $isAdmin) { #a bit cleanup Remove-Item -Path "$PSScriptRoot\temp" -Force -Recurse - if (Test-Path "$PSScriptRoot\unattend.xml") { - remove-item "$PSScriptRoot\unattend.xml" - } - #set MacSpoofing and AllowTeaming (for SET switch in VMs to work properly with vNICs) + #set MacSpoofing and AllowTeaming (for SET switch in VMs to work properly with vNICs) WriteInfo "`t Setting MacSpoofing On and AllowTeaming On" Set-VMNetworkAdapter -VMName "$($labconfig.Prefix)*" -MacAddressSpoofing On -AllowTeaming On From cee31a19bf3e769ef0e96158f81557bc5e4ab786 Mon Sep 17 00:00:00 2001 From: Jaromir Kaspar Date: Wed, 31 Mar 2021 16:38:32 +0200 Subject: [PATCH 09/17] New logic in script --- Tools/DownloadLatestCUs.ps1 | 177 +++++++++++++++++++++++++----------- 1 file changed, 126 insertions(+), 51 deletions(-) diff --git a/Tools/DownloadLatestCUs.ps1 b/Tools/DownloadLatestCUs.ps1 index 0650e5b8..875703e3 100644 --- a/Tools/DownloadLatestCUs.ps1 +++ b/Tools/DownloadLatestCUs.ps1 @@ -2,71 +2,146 @@ If ((Get-ExecutionPolicy) -ne "RemoteSigned"){ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force } -#set TLS 1.2 for github downloads -[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +#region variables -#download LatestUpdate module -Write-Output "Checking if LatestUpdate PS Module is Installed" -if (!(Get-InstalledModule -Name LatestUpdate -ErrorAction Ignore)){ - # 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 - Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs - exit +#grab folder to download to +$folder=Read-Host -Prompt "Please type path to download. For example `"c:\temp`" (if nothing specified, $PSScriptRoot is used)" +if(!$folder){$folder=$PSScriptRoot} + +#do you want preview? +$preview=Read-Host -Prompt "Do you want to download preview updates? Y/N, default N" +if($preview -eq "y"){$ + preview = $true +}else{ + $preview=$false +} + +#URLs with list of latest updates +$URLs=@() +$URLs+=@{Product="Windows10";URL="https://support.microsoft.com/en-us/topic/release-notes-for-azure-stack-hci-64c79b7f-d536-015d-b8dd-575f01090efd"} +$URLs+=@{Product="AzureStackHCI";URL="https://support.microsoft.com/en-us/topic/windows-10-update-history-7dd3071a-3906-fa2c-c342-f7f86728a6e3"} + +$UpdatesList=@() +$Titles=@() +#endregion + +#region process +#download content +Write-Output "Downloading content of latest update sites" +foreach ($url in $urls){ + $content=Invoke-WebRequest -Uri $url.url + $UpdatesList+=($content.ParsedHtml.getElementsByClassName("supLeftNavArticle") | Select-Object OuterText).OuterText + $Titles+=$content.ParsedHtml.getElementsByClassName("supLeftNavCategoryTitle") | Select-Object textcontent +} + +#clean white space +$CleanedList=@() +Foreach ($item in $UpdatesList){ + $CleanedList+=$item.Trim() +} + +#remove initial win10 +$Titles=$Titles | Where-Object {$_.textcontent -notlike "*initial version*"} + +#clean white space +$CleanedListTitles=@() +Foreach ($Title in $Titles){ + $CleanedListTitles+=$Title.TextContent.Trim() +} + +#Process data +Write-Output "Processing data" +$i=0 +$Output=@() +foreach ($item in $CleanedList){ + if ($item -match $CleanedListTitles[$i]){ + $Title=$CleanedListTitles[$i] + $i++ + }else{ + $DateString=([Regex]::Match($item,'\w*\ \d*,\ \d*')).Value + if (($DateString -split " ")[1].Length -eq 3){ + $format="MMMM dd, yyyy" + }else{ + $format="MMMM d, yyyy" + } + $Date=([datetime]::ParseExact($DateString,$format,$null)) + + if ($item -like "*Preview*"){ + $ReleaseType="Preview" + }elseif ($item -like "*Out-Of-Band*"){ + $ReleaseType="Out-Of-Band" + }elseif ($item -like "*servicing*"){ + $ReleaseType="ServicingStackUpdate" + }else{ + $ReleaseType="Standard" + } + $Product=$Title.Replace(", version","").Replace(" update history","").Replace(", and"," and") + #$Product="$(([Regex]::Match($Title,'^.+?(?=,)')).Value)$(([Regex]::Match($Title,'\ and\ .+?(?=,)')).value) $(([Regex]::Match($Title,"(?<=version\ )\w{4}")).Value)" + $Output += [PSCustomObject]@{ + "Product"=$Product + "Version"=([Regex]::Match($Title,"(?<=version\ )\w{4}")).Value + "NavCategoryTitle"=$Title + "Date"= $Date + "KB" = ([Regex]::Match($item,'KB\d*')).Value + "Build" = ([Regex]::Match($item,'\d*\.\d*')).Value + "ReleaseType" = $ReleaseType + } } - Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force - Install-Module -Name LatestUpdate -Force } -#check if latest json is added -$jsonweb=(Invoke-WebRequest -UseBasicParsing -Uri https://raw.githubusercontent.com/aaronparker/LatestUpdate/master/LatestUpdate/LatestUpdate.json).content | ConvertFrom-Json -$jsonlocal=Get-Content -Path "$((Get-InstalledModule -Name LatestUpdate).InstalledLocation)\LatestUpdate.json" | ConvertFrom-Json -if (($jsonlocal.ParameterValues.Windows10Versions).Count -ne ($jsonweb.ParameterValues.Windows10Versions).Count){ - Write-Output "JSON on Local web is different, replacing local JSON" - #elevate process + +$Products=$Output | Select-Object Product -Unique | Out-GridView -Title "Please select Products you want to download latest updates for" -OutputMode Multiple + +$Result=@() +Foreach ($Product in $products){ + if ($preview -eq $true){ + $result+=$Output | Where-Object {$_.Product -eq $Product.Product -and $_.ReleaseType -notlike "ServicingStackUpdate"} | Select-Object -First 1 + $result+=$Output | Where-Object {$_.Product -eq $Product.Product -and $_.ReleaseType -eq "ServicingStackUpdate"} | Select-Object -First 1 + }else{ + $result+=$Output | Where-Object {$_.Product -eq $Product.Product -and $_.ReleaseType -eq "Standard"} | Select-Object -First 1 + $result+=$Output | Where-Object {$_.Product -eq $Product.Product -and $_.ReleaseType -eq "ServicingStackUpdate"} | Select-Object -First 1 + } +} +#endregion + +#region download MSCatalog module +Write-Output "Checking if MSCatalog PS Module is Installed" +if (!(Get-InstalledModule -Name MSCatalog -ErrorAction Ignore)){ + # 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 replace JSON in LatestUpdate Module" -ForegroundColor Cyan ; Sleep -Seconds 1 + Write-Host "-- Restarting as Administrator to install Modules" -ForegroundColor Cyan ; Start-Sleep -Seconds 1 Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs exit } - $jsonweb | ConvertTo-Json | Out-File "$((Get-InstalledModule -Name LatestUpdate).InstalledLocation)\LatestUpdate.json" - If ((Get-ExecutionPolicy) -ne "RemoteSigned"){ - Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force - } + Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force + Install-Module -Name MSCatalog -Force } -#grab folder to download to -$folder=Read-Host -Prompt "Please type path to download. For example `"c:\temp`" (if nothing specified, $PSScriptRoot is used)" -if(!$folder){$folder=$PSScriptRoot} - -#grab versions to download -$versions=$jsonweb.ParameterValues.Windows10Versions | Out-GridView -OutputMode Multiple -Title "Select versions to download" - -foreach ($Version in $versions){ - Write-Output "Fetching for latest CU info from web" - $latestCU=Get-LatestCumulativeUpdate -OperatingSystem Windows10 -Version $Version | Where-Object -Property Note -Like "*Windows 10*x64*" | Select-Object -First 1 #1903 has 2 objects - $CUFilename=$latestCU.URL.Split('/') | Select-Object -Last 1 - $path="$folder\$version\$($latestCU.Note.Substring(0,7))" - New-Item -Path $path -ItemType Directory -ErrorAction Ignore | Out-Null - if (Test-Path -Path "$path\$CUFilename"){ - Write-Output "$CUFilename already present. Skipping download" - }else{ - Write-Output "Downloading $CUFilename" - $latestCU | Save-LatestUpdate -Path $path - } +#endregion - Write-Output "Fetching for latest SSU info from web" - $latestSSU=Get-LatestServicingStackUpdate -OperatingSystem Windows10 -Version $Version | Where-Object -Property Note -Like "*Windows 10*x64*" - $SSUFilename=$latestSSU.URL.Split('/') | Select-Object -Last 1 - if (Test-Path -Path "$path\$SSUFilename"){ - Write-Output "$SSUFilename already present. Skipping download" - }else{ - Write-Output "Downloading $SSUFilename" - $latestSSU | Save-LatestUpdate -Path $path +#region Download update +Write-Output "Downloading Updates" +Foreach ($item in $Result){ + $DateFolderName=($result | where Product -eq $item.Product | where ReleaseType -ne ServicingStackUpdate).Date | Get-Date -Format "dd-MMM-yy" + $Path="C:\temp\$($item.Product)\$DateFolderName" + New-Item -Path $Path -ItemType Directory -ErrorAction Ignore + $UpdateCandidate=Get-MSCatalogUpdate -Search $item.kb | Where-Object Title -Like "*x64*" + if ($UpdateCandidate.count -eq 1){ + $UpdateCandidate | Save-MSCatalogUpdate -UseBits -Destination $Path + }elseif ($item.Product -like "Azure Stack*"){ + $UpdateCandidate | Where-Object Products -Like "*Azure Stack*" | Save-MSCatalogUpdate -UseBits -Destination $Path + }elseif ($item.Product -like "*Windows Server*"){ + $update=$UpdateCandidate | Where Title -Like "*Windows Server*" + if ($update.count -eq 1){ + $update | Save-MSCatalogUpdate -UseBits -Destination $Path + }else{ + $update | Where-Object Title -Like "*$($item.Version)*" | Save-MSCatalogUpdate + } } } +#endregion + Write-Host "Job finished. Press enter to continue" -ForegroundColor Green Read-Host \ No newline at end of file From 4f29dcb0429c244507764f27b9767ed0c7a377fd Mon Sep 17 00:00:00 2001 From: Jaromir Kaspar Date: Wed, 31 Mar 2021 22:08:27 +0200 Subject: [PATCH 10/17] Update for March release --- Scenarios/AzSHCI and Kubernetes/Scenario.ps1 | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Scenarios/AzSHCI and Kubernetes/Scenario.ps1 b/Scenarios/AzSHCI and Kubernetes/Scenario.ps1 index 0a1a906d..406c8bed 100644 --- a/Scenarios/AzSHCI and Kubernetes/Scenario.ps1 +++ b/Scenarios/AzSHCI and Kubernetes/Scenario.ps1 @@ -195,9 +195,9 @@ Invoke-Command -ComputerName $ClusterName -ScriptBlock { #endregion #region Download AKS HCI module -Start-BitsTransfer -Source "https://aka.ms/aks-hci-download" -Destination "$env:USERPROFILE\Downloads\AKS-HCI-Public-Preview-Feb-2021.zip" +Start-BitsTransfer -Source "https://aka.ms/aks-hci-download" -Destination "$env:USERPROFILE\Downloads\AKS-HCI-Public-Preview-Mar-2021.zip" #unzip -Expand-Archive -Path "$env:USERPROFILE\Downloads\AKS-HCI-Public-Preview-Feb-2021.zip" -DestinationPath "$env:USERPROFILE\Downloads" -Force +Expand-Archive -Path "$env:USERPROFILE\Downloads\AKS-HCI-Public-Preview-Mar-2021.zip" -DestinationPath "$env:USERPROFILE\Downloads" -Force Expand-Archive -Path "$env:USERPROFILE\Downloads\AksHci.Powershell.zip" -DestinationPath "$env:USERPROFILE\Downloads\AksHci.Powershell" -Force #endregion @@ -248,7 +248,8 @@ Expand-Archive -Path "$env:USERPROFILE\Downloads\AksHci.Powershell.zip" -Destina #configure aks Invoke-Command -ComputerName $servers[0] -Credential $Credentials -Authentication Credssp -ScriptBlock { $vnet = New-AksHciNetworkSetting -vnetName $using:vSwitchName -vippoolstart $using:vippoolstart -vippoolend $using:vippoolend - Set-AksHciConfig -vnet $vnet -workingDir c:\clusterstorage\$using:VolumeName\Images -imageDir c:\clusterstorage\$using:VolumeName\Images -cloudConfigLocation c:\clusterstorage\$using:VolumeName\Config -ClusterRoleName "$($using:ClusterName)_AKS" -enableDiagnosticData -controlPlaneVmSize = 'default' # Get-AksHciVmSize + #Set-AksHciConfig -vnet $vnet -workingDir c:\clusterstorage\$using:VolumeName\Images -imageDir c:\clusterstorage\$using:VolumeName\Images -cloudConfigLocation c:\clusterstorage\$using:VolumeName\Config -ClusterRoleName "$($using:ClusterName)_AKS" -enableDiagnosticData -controlPlaneVmSize = 'default' # Get-AksHciVmSize + Set-AksHciConfig -vnet $vnet -imageDir c:\clusterstorage\$using:VolumeName\Images -cloudConfigLocation c:\clusterstorage\$using:VolumeName\Config -ClusterRoleName "$($using:ClusterName)_AKS" -enableDiagnosticData -controlPlaneVmSize = 'default' # Get-AksHciVmSize } #validate config @@ -256,10 +257,8 @@ Expand-Archive -Path "$env:USERPROFILE\Downloads\AksHci.Powershell.zip" -Destina Get-AksHciConfig } - #note: this step might need to run twice. As for first time it times out on https://github.com/Azure/aks-hci/issues/28 . Before second attempt, unistall-akshci first and set config again + #Install Invoke-Command -ComputerName $servers[0] -Credential $Credentials -Authentication Credssp -ScriptBlock { - #Uninstall-AksHCI - #Set-AksHciConfig -vnetName $using:vSwitchName -workingDir c:\clusterstorage\$using:VolumeName\Images -imageDir c:\clusterstorage\$using:VolumeName\Images -cloudConfigLocation c:\clusterstorage\$using:VolumeName\Config -ClusterRoleName "$($using:ClusterName)_AKS" Install-AksHci } From d4c5ebf8ae2ff1c24dfbdd40c31e90c54e8ec788 Mon Sep 17 00:00:00 2001 From: Jaromir Kaspar Date: Wed, 31 Mar 2021 22:13:57 +0200 Subject: [PATCH 11/17] typo fixes --- Tools/DownloadLatestCUs.ps1 | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Tools/DownloadLatestCUs.ps1 b/Tools/DownloadLatestCUs.ps1 index 875703e3..def5ad36 100644 --- a/Tools/DownloadLatestCUs.ps1 +++ b/Tools/DownloadLatestCUs.ps1 @@ -11,7 +11,7 @@ if(!$folder){$folder=$PSScriptRoot} #do you want preview? $preview=Read-Host -Prompt "Do you want to download preview updates? Y/N, default N" if($preview -eq "y"){$ - preview = $true + $preview = $true }else{ $preview=$false } @@ -64,8 +64,7 @@ foreach ($item in $CleanedList){ }else{ $format="MMMM d, yyyy" } - $Date=([datetime]::ParseExact($DateString,$format,$null)) - + $Date=([datetime]::ParseExact($DateString,$format,[Globalization.CultureInfo]::CreateSpecificCulture('en-US'))) if ($item -like "*Preview*"){ $ReleaseType="Preview" }elseif ($item -like "*Out-Of-Band*"){ @@ -123,8 +122,8 @@ if (!(Get-InstalledModule -Name MSCatalog -ErrorAction Ignore)){ #region Download update Write-Output "Downloading Updates" Foreach ($item in $Result){ - $DateFolderName=($result | where Product -eq $item.Product | where ReleaseType -ne ServicingStackUpdate).Date | Get-Date -Format "dd-MMM-yy" - $Path="C:\temp\$($item.Product)\$DateFolderName" + $DateFolderName=($result | Where-Object Product -eq $item.Product | where ReleaseType -ne ServicingStackUpdate).Date | Get-Date -Format "dd-MMM-yy" + $Path="$folder\$($item.Product)\$DateFolderName" New-Item -Path $Path -ItemType Directory -ErrorAction Ignore $UpdateCandidate=Get-MSCatalogUpdate -Search $item.kb | Where-Object Title -Like "*x64*" if ($UpdateCandidate.count -eq 1){ @@ -132,11 +131,11 @@ Foreach ($item in $Result){ }elseif ($item.Product -like "Azure Stack*"){ $UpdateCandidate | Where-Object Products -Like "*Azure Stack*" | Save-MSCatalogUpdate -UseBits -Destination $Path }elseif ($item.Product -like "*Windows Server*"){ - $update=$UpdateCandidate | Where Title -Like "*Windows Server*" + $update=$UpdateCandidate | Where-Object Title -Like "*Windows Server*" if ($update.count -eq 1){ $update | Save-MSCatalogUpdate -UseBits -Destination $Path }else{ - $update | Where-Object Title -Like "*$($item.Version)*" | Save-MSCatalogUpdate + $update | Where-Object Title -Like "*$($item.Version)*" | Save-MSCatalogUpdate -UseBits -Destination $Path } } } From 8921c5d5a058bfa83b476d32af576c17ca8f2b78 Mon Sep 17 00:00:00 2001 From: Jaromir Kaspar Date: Fri, 2 Apr 2021 01:27:11 +0200 Subject: [PATCH 12/17] url fix --- Tools/DownloadLatestCUs.ps1 | 42 ++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/Tools/DownloadLatestCUs.ps1 b/Tools/DownloadLatestCUs.ps1 index def5ad36..284f6f3f 100644 --- a/Tools/DownloadLatestCUs.ps1 +++ b/Tools/DownloadLatestCUs.ps1 @@ -10,7 +10,7 @@ if(!$folder){$folder=$PSScriptRoot} #do you want preview? $preview=Read-Host -Prompt "Do you want to download preview updates? Y/N, default N" -if($preview -eq "y"){$ +if($preview -eq "y"){ $preview = $true }else{ $preview=$false @@ -18,8 +18,8 @@ if($preview -eq "y"){$ #URLs with list of latest updates $URLs=@() -$URLs+=@{Product="Windows10";URL="https://support.microsoft.com/en-us/topic/release-notes-for-azure-stack-hci-64c79b7f-d536-015d-b8dd-575f01090efd"} -$URLs+=@{Product="AzureStackHCI";URL="https://support.microsoft.com/en-us/topic/windows-10-update-history-7dd3071a-3906-fa2c-c342-f7f86728a6e3"} +$URLs+=@{Product="AzureStackHCI";URL="https://support.microsoft.com/en-us/topic/release-notes-for-azure-stack-hci-64c79b7f-d536-015d-b8dd-575f01090efd"} +$URLs+=@{Product="Windows10";URL="https://support.microsoft.com/en-us/topic/windows-10-update-history-7dd3071a-3906-fa2c-c342-f7f86728a6e3"} $UpdatesList=@() $Titles=@() @@ -37,16 +37,15 @@ foreach ($url in $urls){ #clean white space $CleanedList=@() Foreach ($item in $UpdatesList){ + $item=$item.Replace(" "," ") $CleanedList+=$item.Trim() } -#remove initial win10 -$Titles=$Titles | Where-Object {$_.textcontent -notlike "*initial version*"} - #clean white space $CleanedListTitles=@() Foreach ($Title in $Titles){ - $CleanedListTitles+=$Title.TextContent.Trim() + $Title=$Title.textcontent.Replace(" "," ") + $CleanedListTitles+=$Title.Trim() } #Process data @@ -54,7 +53,7 @@ Write-Output "Processing data" $i=0 $Output=@() foreach ($item in $CleanedList){ - if ($item -match $CleanedListTitles[$i]){ + if ($item -eq $CleanedListTitles[$i]){ $Title=$CleanedListTitles[$i] $i++ }else{ @@ -74,16 +73,25 @@ foreach ($item in $CleanedList){ }else{ $ReleaseType="Standard" } - $Product=$Title.Replace(", version","").Replace(" update history","").Replace(", and"," and") + if ($title -like "*initial*"){ + $Version="Initial Release" + }else{ + $Version=([Regex]::Match($Title,"(?<=version\ )\w{4}")).Value + } + $Product=$Title.Replace(", version $version and Windows Server, version $version update history"," $Version").Replace(", version 1809, Windows Server, version 1809,"," 1809").Replace(", version $version"," $version").Replace(" update history","") #$Product="$(([Regex]::Match($Title,'^.+?(?=,)')).Value)$(([Regex]::Match($Title,'\ and\ .+?(?=,)')).value) $(([Regex]::Match($Title,"(?<=version\ )\w{4}")).Value)" - $Output += [PSCustomObject]@{ - "Product"=$Product - "Version"=([Regex]::Match($Title,"(?<=version\ )\w{4}")).Value - "NavCategoryTitle"=$Title - "Date"= $Date - "KB" = ([Regex]::Match($item,'KB\d*')).Value - "Build" = ([Regex]::Match($item,'\d*\.\d*')).Value - "ReleaseType" = $ReleaseType + #skip mobile + if ($item -notlike "*Windows 10 Mobile*"){ + $Output += [PSCustomObject]@{ + "Product"=$Product + "Version"=$Version + "Date"= $Date + "KB" = ([Regex]::Match($item,'KB\d*')).Value + "Build" = ([Regex]::Match($item,'\d*\.\d*')).Value + "ReleaseType" = $ReleaseType + "NavCategoryTitle"=$Title + "NavArticle"=$item + } } } } From d77444b03cc2a4677053e77ea5c61b984f114ab9 Mon Sep 17 00:00:00 2001 From: Jaromir Kaspar Date: Sat, 3 Apr 2021 02:49:18 +0200 Subject: [PATCH 13/17] complete redesign --- Tools/DownloadLatestCUs.ps1 | 149 ++++++++---------------------------- 1 file changed, 30 insertions(+), 119 deletions(-) diff --git a/Tools/DownloadLatestCUs.ps1 b/Tools/DownloadLatestCUs.ps1 index 284f6f3f..0dd80bbf 100644 --- a/Tools/DownloadLatestCUs.ps1 +++ b/Tools/DownloadLatestCUs.ps1 @@ -1,8 +1,10 @@ -If ((Get-ExecutionPolicy) -ne "RemoteSigned"){ - Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force -} - -#region variables +$Products=@() +$Products+=@{Product="Azure Stack HCI 20H2";SearchString="Cumulative Update for Azure Stack HCI, version 20H2" ;PreviewSearchString="Cumulative Update Preview for Azure Stack HCI" ;SSUSearchString="Servicing Stack Update for Azure Stack HCI, version 20H2 for x64-based Systems"} +$Products+=@{Product="Windows Server 2019" ;SearchString="Cumulative Update for Windows Server 2019 for x64-based Systems" ;PreviewSearchString="Cumulative Update Preview for Windows Server 2019 for x64-based Systems" ;SSUSearchString="Servicing Stack Update for Windows Server 2019 for x64-based Systemss"} +$Products+=@{Product="Windows Server 2016" ;SearchString="Cumulative Update for Windows Server 2019 for x64-based Systems" ;PreviewSearchString="Cumulative Update Preview for Windows Server 2019 for x64-based Systems" ;SSUSearchString="Servicing Stack Update for Windows Server 2019 for x64-based Systemss"} +$Products+=@{Product="Windows 10 20H2" ;SearchString="Cumulative Update for Windows 10 Version 20H2 for x64-based Systems";PreviewSearchString="Cumulative Update Preview for Windows 10 Version 20H2 for x64-based Systems";SSUSearchString="Servicing Stack Update for Windows 10 Version 20H2 for x64-based Systems"} +$Products+=@{Product="Windows 10 2004" ;SearchString="Cumulative Update for Windows 10 Version 2004 for x64-based Systems";PreviewSearchString="Cumulative Update Preview for Windows 10 Version 2004 for x64-based Systems";SSUSearchString="Servicing Stack Update for Windows 10 Version 2004 for x64-based Systems"} +$Products+=@{Product="Windows 10 1909" ;SearchString="Cumulative Update for Windows 10 Version 1909 for x64-based Systems";PreviewSearchString="Cumulative Update Preview for Windows 10 Version 1909 for x64-based Systems";SSUSearchString="Servicing Stack Update for Windows 10 Version 1909 for x64-based Systems"} #grab folder to download to $folder=Read-Host -Prompt "Please type path to download. For example `"c:\temp`" (if nothing specified, $PSScriptRoot is used)" @@ -16,100 +18,8 @@ if($preview -eq "y"){ $preview=$false } -#URLs with list of latest updates -$URLs=@() -$URLs+=@{Product="AzureStackHCI";URL="https://support.microsoft.com/en-us/topic/release-notes-for-azure-stack-hci-64c79b7f-d536-015d-b8dd-575f01090efd"} -$URLs+=@{Product="Windows10";URL="https://support.microsoft.com/en-us/topic/windows-10-update-history-7dd3071a-3906-fa2c-c342-f7f86728a6e3"} - -$UpdatesList=@() -$Titles=@() -#endregion - -#region process -#download content -Write-Output "Downloading content of latest update sites" -foreach ($url in $urls){ - $content=Invoke-WebRequest -Uri $url.url - $UpdatesList+=($content.ParsedHtml.getElementsByClassName("supLeftNavArticle") | Select-Object OuterText).OuterText - $Titles+=$content.ParsedHtml.getElementsByClassName("supLeftNavCategoryTitle") | Select-Object textcontent -} - -#clean white space -$CleanedList=@() -Foreach ($item in $UpdatesList){ - $item=$item.Replace(" "," ") - $CleanedList+=$item.Trim() -} - -#clean white space -$CleanedListTitles=@() -Foreach ($Title in $Titles){ - $Title=$Title.textcontent.Replace(" "," ") - $CleanedListTitles+=$Title.Trim() -} - -#Process data -Write-Output "Processing data" -$i=0 -$Output=@() -foreach ($item in $CleanedList){ - if ($item -eq $CleanedListTitles[$i]){ - $Title=$CleanedListTitles[$i] - $i++ - }else{ - $DateString=([Regex]::Match($item,'\w*\ \d*,\ \d*')).Value - if (($DateString -split " ")[1].Length -eq 3){ - $format="MMMM dd, yyyy" - }else{ - $format="MMMM d, yyyy" - } - $Date=([datetime]::ParseExact($DateString,$format,[Globalization.CultureInfo]::CreateSpecificCulture('en-US'))) - if ($item -like "*Preview*"){ - $ReleaseType="Preview" - }elseif ($item -like "*Out-Of-Band*"){ - $ReleaseType="Out-Of-Band" - }elseif ($item -like "*servicing*"){ - $ReleaseType="ServicingStackUpdate" - }else{ - $ReleaseType="Standard" - } - if ($title -like "*initial*"){ - $Version="Initial Release" - }else{ - $Version=([Regex]::Match($Title,"(?<=version\ )\w{4}")).Value - } - $Product=$Title.Replace(", version $version and Windows Server, version $version update history"," $Version").Replace(", version 1809, Windows Server, version 1809,"," 1809").Replace(", version $version"," $version").Replace(" update history","") - #$Product="$(([Regex]::Match($Title,'^.+?(?=,)')).Value)$(([Regex]::Match($Title,'\ and\ .+?(?=,)')).value) $(([Regex]::Match($Title,"(?<=version\ )\w{4}")).Value)" - #skip mobile - if ($item -notlike "*Windows 10 Mobile*"){ - $Output += [PSCustomObject]@{ - "Product"=$Product - "Version"=$Version - "Date"= $Date - "KB" = ([Regex]::Match($item,'KB\d*')).Value - "Build" = ([Regex]::Match($item,'\d*\.\d*')).Value - "ReleaseType" = $ReleaseType - "NavCategoryTitle"=$Title - "NavArticle"=$item - } - } - } -} - - -$Products=$Output | Select-Object Product -Unique | Out-GridView -Title "Please select Products you want to download latest updates for" -OutputMode Multiple - -$Result=@() -Foreach ($Product in $products){ - if ($preview -eq $true){ - $result+=$Output | Where-Object {$_.Product -eq $Product.Product -and $_.ReleaseType -notlike "ServicingStackUpdate"} | Select-Object -First 1 - $result+=$Output | Where-Object {$_.Product -eq $Product.Product -and $_.ReleaseType -eq "ServicingStackUpdate"} | Select-Object -First 1 - }else{ - $result+=$Output | Where-Object {$_.Product -eq $Product.Product -and $_.ReleaseType -eq "Standard"} | Select-Object -First 1 - $result+=$Output | Where-Object {$_.Product -eq $Product.Product -and $_.ReleaseType -eq "ServicingStackUpdate"} | Select-Object -First 1 - } -} -#endregion +#let user choose products +$SelectedProducts=$Products.Product | Out-GridView -OutputMode Multiple -Title "Please select products to download Cumulative Updates and Servicing Stack Updates" #region download MSCatalog module Write-Output "Checking if MSCatalog PS Module is Installed" @@ -127,27 +37,28 @@ if (!(Get-InstalledModule -Name MSCatalog -ErrorAction Ignore)){ #endregion -#region Download update -Write-Output "Downloading Updates" -Foreach ($item in $Result){ - $DateFolderName=($result | Where-Object Product -eq $item.Product | where ReleaseType -ne ServicingStackUpdate).Date | Get-Date -Format "dd-MMM-yy" - $Path="$folder\$($item.Product)\$DateFolderName" - New-Item -Path $Path -ItemType Directory -ErrorAction Ignore - $UpdateCandidate=Get-MSCatalogUpdate -Search $item.kb | Where-Object Title -Like "*x64*" - if ($UpdateCandidate.count -eq 1){ - $UpdateCandidate | Save-MSCatalogUpdate -UseBits -Destination $Path - }elseif ($item.Product -like "Azure Stack*"){ - $UpdateCandidate | Where-Object Products -Like "*Azure Stack*" | Save-MSCatalogUpdate -UseBits -Destination $Path - }elseif ($item.Product -like "*Windows Server*"){ - $update=$UpdateCandidate | Where-Object Title -Like "*Windows Server*" - if ($update.count -eq 1){ - $update | Save-MSCatalogUpdate -UseBits -Destination $Path - }else{ - $update | Where-Object Title -Like "*$($item.Version)*" | Save-MSCatalogUpdate -UseBits -Destination $Path - } - } +#region download products +Foreach($SelectedProduct in $SelectedProducts){ + $item=$Products | Where-Object product -eq $SelectedProduct + #Download CU + If ($preview){ + $update=Get-MSCatalogUpdate -Search $item.previewsearchstring | Select -First 1 + $DestinationFolder="$folder\$SelectedProduct\$($update.title.Substring(0,7))" + New-Item -Path $DestinationFolder -ItemType Directory -ErrorAction Ignore | Out-Null + Write-Output "Downloading $($update.title) to $destinationFolder" + $update | Save-MSCatalogUpdate -Destination "$folder\$DateFolder" -UseBits + }else{ + $update=Get-MSCatalogUpdate -Search $item.searchstring | where Title -like "*$($item.SearchString)*" | Select -First 1 + $DestinationFolder="$folder\$SelectedProduct\$($update.title.Substring(0,7))" + New-Item -Path $DestinationFolder -ItemType Directory -ErrorAction Ignore | Out-Null + Write-Output "Downloading $($update.title) to $destinationFolder" + $update | Save-MSCatalogUpdate -Destination "$folder\$DateFolder" -UseBits + } + #Download SSU + $update=Get-MSCatalogUpdate -Search $item.SSUSearchString | Select -First 1 + Write-Output "Downloading $($update.title) to $destinationFolder" + $update | Save-MSCatalogUpdate -Destination $DestinationFolder -UseBits } - #endregion Write-Host "Job finished. Press enter to continue" -ForegroundColor Green From f16208664f4623e49ee8b3351afbee738ad708c0 Mon Sep 17 00:00:00 2001 From: Jaromir Kaspar Date: Sat, 3 Apr 2021 03:02:24 +0200 Subject: [PATCH 14/17] typos fix --- Tools/DownloadLatestCUs.ps1 | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Tools/DownloadLatestCUs.ps1 b/Tools/DownloadLatestCUs.ps1 index 0dd80bbf..2709e4e8 100644 --- a/Tools/DownloadLatestCUs.ps1 +++ b/Tools/DownloadLatestCUs.ps1 @@ -39,25 +39,25 @@ if (!(Get-InstalledModule -Name MSCatalog -ErrorAction Ignore)){ #region download products Foreach($SelectedProduct in $SelectedProducts){ - $item=$Products | Where-Object product -eq $SelectedProduct - #Download CU - If ($preview){ - $update=Get-MSCatalogUpdate -Search $item.previewsearchstring | Select -First 1 + $item=$Products | Where-Object product -eq $SelectedProduct + #Download CU + If ($preview){ + $update=Get-MSCatalogUpdate -Search $item.previewsearchstring | Select-Object -First 1 $DestinationFolder="$folder\$SelectedProduct\$($update.title.Substring(0,7))" New-Item -Path $DestinationFolder -ItemType Directory -ErrorAction Ignore | Out-Null Write-Output "Downloading $($update.title) to $destinationFolder" - $update | Save-MSCatalogUpdate -Destination "$folder\$DateFolder" -UseBits - }else{ - $update=Get-MSCatalogUpdate -Search $item.searchstring | where Title -like "*$($item.SearchString)*" | Select -First 1 + $update | Save-MSCatalogUpdate -Destination "$DestinationFolder" -UseBits + }else{ + $update=Get-MSCatalogUpdate -Search $item.searchstring | Where-Object Title -like "*$($item.SearchString)*" | Select-Object -First 1 $DestinationFolder="$folder\$SelectedProduct\$($update.title.Substring(0,7))" New-Item -Path $DestinationFolder -ItemType Directory -ErrorAction Ignore | Out-Null Write-Output "Downloading $($update.title) to $destinationFolder" - $update | Save-MSCatalogUpdate -Destination "$folder\$DateFolder" -UseBits - } - #Download SSU - $update=Get-MSCatalogUpdate -Search $item.SSUSearchString | Select -First 1 - Write-Output "Downloading $($update.title) to $destinationFolder" - $update | Save-MSCatalogUpdate -Destination $DestinationFolder -UseBits + $update | Save-MSCatalogUpdate -Destination "$DestinationFolder" -UseBits + } + #Download SSU + $update=Get-MSCatalogUpdate -Search $item.SSUSearchString | Select-Object -First 1 + Write-Output "Downloading $($update.title) to $destinationFolder" + $update | Save-MSCatalogUpdate -Destination $DestinationFolder -UseBits } #endregion From 1209b3f6999fe72246e40b991ff1f3353cfbfc8d Mon Sep 17 00:00:00 2001 From: Jaromir Kaspar Date: Sat, 3 Apr 2021 03:06:32 +0200 Subject: [PATCH 15/17] searchstring fix --- Tools/DownloadLatestCUs.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/DownloadLatestCUs.ps1 b/Tools/DownloadLatestCUs.ps1 index 2709e4e8..e90fc7fe 100644 --- a/Tools/DownloadLatestCUs.ps1 +++ b/Tools/DownloadLatestCUs.ps1 @@ -1,7 +1,7 @@ $Products=@() $Products+=@{Product="Azure Stack HCI 20H2";SearchString="Cumulative Update for Azure Stack HCI, version 20H2" ;PreviewSearchString="Cumulative Update Preview for Azure Stack HCI" ;SSUSearchString="Servicing Stack Update for Azure Stack HCI, version 20H2 for x64-based Systems"} $Products+=@{Product="Windows Server 2019" ;SearchString="Cumulative Update for Windows Server 2019 for x64-based Systems" ;PreviewSearchString="Cumulative Update Preview for Windows Server 2019 for x64-based Systems" ;SSUSearchString="Servicing Stack Update for Windows Server 2019 for x64-based Systemss"} -$Products+=@{Product="Windows Server 2016" ;SearchString="Cumulative Update for Windows Server 2019 for x64-based Systems" ;PreviewSearchString="Cumulative Update Preview for Windows Server 2019 for x64-based Systems" ;SSUSearchString="Servicing Stack Update for Windows Server 2019 for x64-based Systemss"} +$Products+=@{Product="Windows Server 2016" ;SearchString="Cumulative Update for Windows Server 2016 for x64-based Systems" ;PreviewSearchString="Cumulative Update Preview for Windows Server 2016 for x64-based Systems" ;SSUSearchString="Servicing Stack Update for Windows Server 2016 for x64-based Systemss"} $Products+=@{Product="Windows 10 20H2" ;SearchString="Cumulative Update for Windows 10 Version 20H2 for x64-based Systems";PreviewSearchString="Cumulative Update Preview for Windows 10 Version 20H2 for x64-based Systems";SSUSearchString="Servicing Stack Update for Windows 10 Version 20H2 for x64-based Systems"} $Products+=@{Product="Windows 10 2004" ;SearchString="Cumulative Update for Windows 10 Version 2004 for x64-based Systems";PreviewSearchString="Cumulative Update Preview for Windows 10 Version 2004 for x64-based Systems";SSUSearchString="Servicing Stack Update for Windows 10 Version 2004 for x64-based Systems"} $Products+=@{Product="Windows 10 1909" ;SearchString="Cumulative Update for Windows 10 Version 1909 for x64-based Systems";PreviewSearchString="Cumulative Update Preview for Windows 10 Version 1909 for x64-based Systems";SSUSearchString="Servicing Stack Update for Windows 10 Version 1909 for x64-based Systems"} From 345e690d67ff7f2acaf82bf03f6e923c9ac43016 Mon Sep 17 00:00:00 2001 From: Jaromir Kaspar Date: Sat, 3 Apr 2021 03:22:19 +0200 Subject: [PATCH 16/17] Removed BITS because of inconsistent behavior --- Tools/DownloadLatestCUs.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tools/DownloadLatestCUs.ps1 b/Tools/DownloadLatestCUs.ps1 index e90fc7fe..6ad031ee 100644 --- a/Tools/DownloadLatestCUs.ps1 +++ b/Tools/DownloadLatestCUs.ps1 @@ -46,18 +46,18 @@ Foreach($SelectedProduct in $SelectedProducts){ $DestinationFolder="$folder\$SelectedProduct\$($update.title.Substring(0,7))" New-Item -Path $DestinationFolder -ItemType Directory -ErrorAction Ignore | Out-Null Write-Output "Downloading $($update.title) to $destinationFolder" - $update | Save-MSCatalogUpdate -Destination "$DestinationFolder" -UseBits + $update | Save-MSCatalogUpdate -Destination "$DestinationFolder" #-UseBits }else{ $update=Get-MSCatalogUpdate -Search $item.searchstring | Where-Object Title -like "*$($item.SearchString)*" | Select-Object -First 1 $DestinationFolder="$folder\$SelectedProduct\$($update.title.Substring(0,7))" New-Item -Path $DestinationFolder -ItemType Directory -ErrorAction Ignore | Out-Null Write-Output "Downloading $($update.title) to $destinationFolder" - $update | Save-MSCatalogUpdate -Destination "$DestinationFolder" -UseBits + $update | Save-MSCatalogUpdate -Destination "$DestinationFolder" #-UseBits } #Download SSU $update=Get-MSCatalogUpdate -Search $item.SSUSearchString | Select-Object -First 1 Write-Output "Downloading $($update.title) to $destinationFolder" - $update | Save-MSCatalogUpdate -Destination $DestinationFolder -UseBits + $update | Save-MSCatalogUpdate -Destination $DestinationFolder #-UseBits } #endregion From dac76443d231c48c0a8f8e45330f3ecdf07aa3eb Mon Sep 17 00:00:00 2001 From: Jaromir Kaspar Date: Sat, 3 Apr 2021 23:28:54 +0200 Subject: [PATCH 17/17] simplified a bit --- Tools/DownloadLatestCUs.ps1 | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/Tools/DownloadLatestCUs.ps1 b/Tools/DownloadLatestCUs.ps1 index 6ad031ee..899ab4e9 100644 --- a/Tools/DownloadLatestCUs.ps1 +++ b/Tools/DownloadLatestCUs.ps1 @@ -1,10 +1,10 @@ $Products=@() -$Products+=@{Product="Azure Stack HCI 20H2";SearchString="Cumulative Update for Azure Stack HCI, version 20H2" ;PreviewSearchString="Cumulative Update Preview for Azure Stack HCI" ;SSUSearchString="Servicing Stack Update for Azure Stack HCI, version 20H2 for x64-based Systems"} -$Products+=@{Product="Windows Server 2019" ;SearchString="Cumulative Update for Windows Server 2019 for x64-based Systems" ;PreviewSearchString="Cumulative Update Preview for Windows Server 2019 for x64-based Systems" ;SSUSearchString="Servicing Stack Update for Windows Server 2019 for x64-based Systemss"} -$Products+=@{Product="Windows Server 2016" ;SearchString="Cumulative Update for Windows Server 2016 for x64-based Systems" ;PreviewSearchString="Cumulative Update Preview for Windows Server 2016 for x64-based Systems" ;SSUSearchString="Servicing Stack Update for Windows Server 2016 for x64-based Systemss"} -$Products+=@{Product="Windows 10 20H2" ;SearchString="Cumulative Update for Windows 10 Version 20H2 for x64-based Systems";PreviewSearchString="Cumulative Update Preview for Windows 10 Version 20H2 for x64-based Systems";SSUSearchString="Servicing Stack Update for Windows 10 Version 20H2 for x64-based Systems"} -$Products+=@{Product="Windows 10 2004" ;SearchString="Cumulative Update for Windows 10 Version 2004 for x64-based Systems";PreviewSearchString="Cumulative Update Preview for Windows 10 Version 2004 for x64-based Systems";SSUSearchString="Servicing Stack Update for Windows 10 Version 2004 for x64-based Systems"} -$Products+=@{Product="Windows 10 1909" ;SearchString="Cumulative Update for Windows 10 Version 1909 for x64-based Systems";PreviewSearchString="Cumulative Update Preview for Windows 10 Version 1909 for x64-based Systems";SSUSearchString="Servicing Stack Update for Windows 10 Version 1909 for x64-based Systems"} +$Products+=@{Product="Azure Stack HCI 20H2";SearchString="Cumulative Update for Azure Stack HCI, version 20H2" ;SSUSearchString="Servicing Stack Update for Azure Stack HCI, version 20H2 for x64-based Systems"} +$Products+=@{Product="Windows Server 2019" ;SearchString="Cumulative Update for Windows Server 2019 for x64-based Systems" ;SSUSearchString="Servicing Stack Update for Windows Server 2019 for x64-based Systemss"} +$Products+=@{Product="Windows Server 2016" ;SearchString="Cumulative Update for Windows Server 2016 for x64-based Systems" ;SSUSearchString="Servicing Stack Update for Windows Server 2016 for x64-based Systemss"} +$Products+=@{Product="Windows 10 20H2" ;SearchString="Cumulative Update for Windows 10 Version 20H2 for x64-based Systems";SSUSearchString="Servicing Stack Update for Windows 10 Version 20H2 for x64-based Systems"} +$Products+=@{Product="Windows 10 2004" ;SearchString="Cumulative Update for Windows 10 Version 2004 for x64-based Systems";SSUSearchString="Servicing Stack Update for Windows 10 Version 2004 for x64-based Systems"} +$Products+=@{Product="Windows 10 1909" ;SearchString="Cumulative Update for Windows 10 Version 1909 for x64-based Systems";SSUSearchString="Servicing Stack Update for Windows 10 Version 1909 for x64-based Systems"} #grab folder to download to $folder=Read-Host -Prompt "Please type path to download. For example `"c:\temp`" (if nothing specified, $PSScriptRoot is used)" @@ -42,18 +42,15 @@ Foreach($SelectedProduct in $SelectedProducts){ $item=$Products | Where-Object product -eq $SelectedProduct #Download CU If ($preview){ - $update=Get-MSCatalogUpdate -Search $item.previewsearchstring | Select-Object -First 1 - $DestinationFolder="$folder\$SelectedProduct\$($update.title.Substring(0,7))" - New-Item -Path $DestinationFolder -ItemType Directory -ErrorAction Ignore | Out-Null - Write-Output "Downloading $($update.title) to $destinationFolder" - $update | Save-MSCatalogUpdate -Destination "$DestinationFolder" #-UseBits + $update=Get-MSCatalogUpdate -Search $item.searchstring | Select-Object -First 1 }else{ $update=Get-MSCatalogUpdate -Search $item.searchstring | Where-Object Title -like "*$($item.SearchString)*" | Select-Object -First 1 - $DestinationFolder="$folder\$SelectedProduct\$($update.title.Substring(0,7))" - New-Item -Path $DestinationFolder -ItemType Directory -ErrorAction Ignore | Out-Null - Write-Output "Downloading $($update.title) to $destinationFolder" - $update | Save-MSCatalogUpdate -Destination "$DestinationFolder" #-UseBits } + $DestinationFolder="$folder\$SelectedProduct\$($update.title.Substring(0,7))" + New-Item -Path $DestinationFolder -ItemType Directory -ErrorAction Ignore | Out-Null + Write-Output "Downloading $($update.title) to $destinationFolder" + $update | Save-MSCatalogUpdate -Destination "$DestinationFolder" #-UseBits + #Download SSU $update=Get-MSCatalogUpdate -Search $item.SSUSearchString | Select-Object -First 1 Write-Output "Downloading $($update.title) to $destinationFolder"