[macos] skip Sonoma updates for Monterey (#8985)

This commit is contained in:
ilia-shipitsin
2023-12-10 21:12:26 +01:00
committed by GitHub
parent 6130ddb3c3
commit d4f6993ac9

View File

@@ -100,14 +100,14 @@ function Invoke-SoftwareUpdate {
$command = "sw_vers" $command = "sw_vers"
$guestMacosVersion = Invoke-SSHPassCommand -HostName $ipAddress -Command $command $guestMacosVersion = Invoke-SSHPassCommand -HostName $ipAddress -Command $command
switch -regex ($guestMacosVersion[1]) { switch -regex ($guestMacosVersion[1]) {
'12.\d' { $nextOSVersion = 'macOS Ventura' } '12.\d' { $nextOSVersion = 'macOS Ventura|macOS Sonoma' }
'13.\d' { $nextOSVersion = 'macOS Sonoma' } '13.\d' { $nextOSVersion = 'macOS Sonoma' }
} }
# Make an array of updates # Make an array of updates
$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("$nextOSVersion") -and (-not [String]::IsNullOrEmpty($newupdate))) { if ($newupdate.Contains("Action: restart") -and !($newupdate -match $nextOSVersion) -and (-not [String]::IsNullOrEmpty($newupdate))) {
Write-Host "`t[*] Sleep 120 seconds before the software updates have been installed" Write-Host "`t[*] Sleep 120 seconds before the software updates have been installed"
Start-Sleep -Seconds 120 Start-Sleep -Seconds 120
@@ -119,7 +119,7 @@ function Invoke-SoftwareUpdate {
# Check software updates have been installed # Check software updates have been installed
$updates = Get-SoftwareUpdate -HostName $ipAddress $updates = Get-SoftwareUpdate -HostName $ipAddress
if ($updates.Contains("Action: restart") -and !$updates.Contains("$nextOSVersion")) { if ($updates.Contains("Action: restart") -and !($newupdate -match $nextOSVersion)) {
Write-Host "`t[x] Software updates failed to install: " Write-Host "`t[x] Software updates failed to install: "
Show-StringWithFormat $updates Show-StringWithFormat $updates
exit 1 exit 1