[Anka] Exclude upgrade to Sonoma (#8551)

This commit is contained in:
Alexey-Ayupov
2023-10-13 14:20:43 +02:00
committed by GitHub
parent c138066e21
commit 53d0847239
2 changed files with 14 additions and 5 deletions

View File

@@ -90,7 +90,7 @@ function Invoke-SoftwareUpdate {
Write-Host "`t[*] Fetching Software Updates ready to install on '$TemplateName' VM:" Write-Host "`t[*] Fetching Software Updates ready to install on '$TemplateName' VM:"
Show-StringWithFormat $newUpdates Show-StringWithFormat $newUpdates
$listOfNewUpdates = $($($newUpdates.Split("*")).Split("Title") | Where-Object {$_ -match "Label:"}).Replace("Label: ", '') | Where-Object {$_ -notmatch "macOS Sonoma"} $listOfNewUpdates = $($($newUpdates.Split("*")).Split("Title") | Where-Object {$_ -match "Label:"}).Replace("Label: ", '')
Write-Host "`t[*] Installing Software Updates on '$TemplateName' VM:" Write-Host "`t[*] Installing Software Updates on '$TemplateName' VM:"
Install-SoftwareUpdate -HostName $ipAddress -listOfUpdates $listOfNewUpdates -Password $Password | Show-StringWithFormat Install-SoftwareUpdate -HostName $ipAddress -listOfUpdates $listOfNewUpdates -Password $Password | Show-StringWithFormat
@@ -99,7 +99,7 @@ function Invoke-SoftwareUpdate {
$listOfNewUpdates = $newUpdates.split('*').Trim('') $listOfNewUpdates = $newUpdates.split('*').Trim('')
foreach ($newupdate in $listOfNewUpdates) { foreach ($newupdate in $listOfNewUpdates) {
# Will be True if the value is not Venture, not empty, and contains "Action: restart" words # Will be True if the value is not Venture, not empty, and contains "Action: restart" words
if ($newupdate.Contains("Action: restart") -and (!$newupdate.Contains("macOS Ventura") -or !$newupdate.Contains("macOS Sonoma")) -and (-not [String]::IsNullOrEmpty($newupdate))) { if ($newupdate.Contains("Action: restart") -and !$newupdate.Contains("macOS Ventura") -and !$newupdate.Contains("macOS Sonoma") -and (-not [String]::IsNullOrEmpty($newupdate))) {
Write-Host "`t[*] Sleep 60 seconds before the software updates have been installed" Write-Host "`t[*] Sleep 60 seconds before the software updates have been installed"
Start-Sleep -Seconds 60 Start-Sleep -Seconds 60

View File

@@ -244,9 +244,10 @@ function Install-SoftwareUpdate {
[array] $listOfUpdates, [array] $listOfUpdates,
[string] $Password [string] $Password
) )
$osVersion = [Environment]::OSVersion # If an update is happening on macOS 12 or 13 we will use the prepared list of updates, otherwise, we will install all updates.
# If an update is happening on macOS 12 we will use the prepared list of updates, otherwise, we will install all updates. $command = "sw_vers"
if ($osVersion.Version.Major -eq "12") { $guestMacosVersion = Invoke-SSHPassCommand -HostName $HostName -Command $command
if ($guestMacosVersion[1] -match "12") {
foreach ($update in $listOfUpdates){ foreach ($update in $listOfUpdates){
# Filtering updates that contain "Ventura" word # Filtering updates that contain "Ventura" word
if ($update -notmatch "Ventura") { if ($update -notmatch "Ventura") {
@@ -254,6 +255,14 @@ function Install-SoftwareUpdate {
Invoke-SSHPassCommand -HostName $HostName -Command $command Invoke-SSHPassCommand -HostName $HostName -Command $command
} }
} }
} elseif ($guestMacosVersion[1] -match "13") {
foreach ($update in $listOfUpdates){
# Filtering updates that contain "Sonoma" word
if ($update -notmatch "Sonoma") {
$command = "sudo /usr/sbin/softwareupdate --restart --verbose --install '$($update.trim())'"
Invoke-SSHPassCommand -HostName $HostName -Command $command
}
}
} else { } else {
$osArch = $(arch) $osArch = $(arch)
if ($osArch -eq "arm64") { if ($osArch -eq "arm64") {