update M365 deployment script to try not to depend on previous deployments
This commit is contained in:
@@ -545,7 +545,7 @@ try {
|
||||
& {
|
||||
function Get-OfficeSuiteInventory {
|
||||
$script:removalChecks++
|
||||
if ($script:removalMode -eq 'empty') { return }
|
||||
if ($script:removalMode -in @('empty','orphan')) { return }
|
||||
[pscustomobject]@{DisplayName='Microsoft Office Professional Plus 2016'; WindowsInstaller=1}
|
||||
if ($script:removalMode -eq 'msi-only') { return }
|
||||
if ($script:removalStarted -and $script:removalMode -eq 'read-error') { throw 'Office inventory is unreadable' }
|
||||
@@ -553,6 +553,7 @@ try {
|
||||
[pscustomobject]@{DisplayName='Microsoft Office Home and Business 2021 - en-us'}
|
||||
}
|
||||
}
|
||||
function Get-OfficeClickToRunState { [pscustomobject]@{Present=($script:removalMode -eq 'orphan')} }
|
||||
function Invoke-OfficeProcess {
|
||||
param($FilePath,$Arguments,$LogPrefix)
|
||||
$script:removalCalls++; $script:removalStarted=$true
|
||||
@@ -563,7 +564,7 @@ try {
|
||||
$removalPath = Join-Path $testRoot 'remove [literal].xml'
|
||||
(New-OfficeRemovalConfiguration ([pscustomobject]@{OfficeAppShutdown='Force'})).Save($removalPath)
|
||||
$media = [pscustomobject]@{Setup='inert-setup.exe'; RemovalConfig=$removalPath}
|
||||
foreach ($script:removalMode in @('empty','msi-only','mixed','delayed','remaining','read-error','fatal','reboot')) {
|
||||
foreach ($script:removalMode in @('empty','orphan','msi-only','mixed','delayed','remaining','read-error','fatal','reboot')) {
|
||||
$script:removalChecks=0; $script:removalCalls=0; $script:removalStarted=$false
|
||||
$script:removalCode = switch ($script:removalMode) { 'fatal' {1603}; 'reboot' {3010}; default {0} }
|
||||
if ($script:removalMode -eq 'remaining') {
|
||||
@@ -581,7 +582,7 @@ try {
|
||||
if ($script:removalMode -eq 'reboot') { Assert-OfficeTest ($script:removalChecks -eq 1) 'A required restart must be surfaced before demanding registration cleanup.' }
|
||||
}
|
||||
$expectedCalls = if ($script:removalMode -in @('empty','msi-only')) {0} else {1}
|
||||
Assert-OfficeTest ($script:removalCalls -eq $expectedCalls) 'Do not remove absent Click-to-Run Office, rerun failed removal, or launch a fallback scrubber.'
|
||||
Assert-OfficeTest ($script:removalCalls -eq $expectedCalls) 'Remove orphaned Click-to-Run state even without registered products, without rerunning failed removal or launching a fallback scrubber.'
|
||||
}
|
||||
}
|
||||
& {
|
||||
@@ -833,7 +834,7 @@ try {
|
||||
Assert-OfficeTest ((Get-Content -LiteralPath $Global:LogFile -Raw) -match 'Error: User cleanup task registration failed for unmapped \(C:\\Users\\defaultuser100000\)') 'Registration failures must reach the Tools diagnostic log.'
|
||||
}
|
||||
|
||||
# Validation can resolve small release metadata without keeping it or staging media.
|
||||
# Deployment resolves release metadata and deletes it on success or failure.
|
||||
& {
|
||||
$script:historyPaths=@()
|
||||
function Save-OfficeDownload {
|
||||
@@ -843,17 +844,103 @@ try {
|
||||
[IO.File]::WriteAllText($Path,$script:historyFixture)
|
||||
}
|
||||
$options=Get-OfficeDeploymentOptions @{OfficeSubscription='Microsoft 365 Business Premium'}
|
||||
Resolve-OfficeTargetVersion $options
|
||||
Resolve-OfficeTargetVersion $options $testRoot
|
||||
Assert-OfficeTest ($script:historyPaths.Count -eq 0 -and !$options.TargetOfficeVersion) 'Unpinned preflight must not download release metadata.'
|
||||
$options.OfficeFeatureRelease='2608'; $script:historyFixture=$releaseHistory
|
||||
Resolve-OfficeTargetVersion $options
|
||||
Resolve-OfficeTargetVersion $options $testRoot
|
||||
Assert-OfficeTest ($options.TargetOfficeVersion -eq '16.0.20326.20158' -and !(Test-Path -LiteralPath $script:historyPaths[-1])) 'Resolved metadata must be removed after successful preflight.'
|
||||
$script:historyFixture='<html>No build</html>'
|
||||
Assert-OfficeThrows { Resolve-OfficeTargetVersion $options } 'did not identify'
|
||||
Assert-OfficeThrows { Resolve-OfficeTargetVersion $options $testRoot } 'did not identify'
|
||||
Assert-OfficeTest (!(Test-Path -LiteralPath $script:historyPaths[-1])) 'Failed preflight retained release metadata.'
|
||||
}
|
||||
# Cleanup runs synchronously on every install exit. Downloads are temporary; pending-user
|
||||
# helpers have a separate durable folder and are never part of disposable media.
|
||||
# Assessment uses HEAD only, follows redirects, requires 200, and never saves data.
|
||||
& {
|
||||
$script:heads=@(); $script:headCode=200; $script:headFails=$false
|
||||
function Invoke-WebRequest {
|
||||
param([switch]$UseBasicParsing,$Method,$Uri,$MaximumRedirection,$TimeoutSec,$ErrorAction,[switch]$OutFile)
|
||||
Assert-OfficeTest ($Method -eq 'Head' -and $MaximumRedirection -eq 10 -and !$OutFile) 'Assessment must use HEAD with redirect handling and no output file.'
|
||||
$script:heads += $Uri
|
||||
if ($script:headFails) { throw 'HEAD unsupported' }
|
||||
[pscustomobject]@{StatusCode=$script:headCode}
|
||||
}
|
||||
function Save-OfficeDownload { throw 'Assessment must not download data.' }
|
||||
$options = Get-OfficeDeploymentOptions @{OfficeSubscription='Microsoft/Office 365 E3/E5 (no Teams)'}
|
||||
$checks = @(Test-OfficeDownloadLinks $options)
|
||||
Assert-OfficeTest ($checks.Count -eq 6 -and $checks.Count -eq $script:heads.Count) 'HEAD checks must cover ODT discovery, helper, CDN, and selected companions.'
|
||||
Assert-OfficeTest ((Get-OfficeDeploymentDefinitions).CompanionInstallers.Teams.Uri -notin $script:heads) 'No-Teams assessment must not probe the Teams download.'
|
||||
$options.InstallTeams=$true; $options.OfficeFeatureRelease='2608'; $script:heads=@()
|
||||
$checks = @(Test-OfficeDownloadLinks $options)
|
||||
Assert-OfficeTest ($checks.Count -eq 8 -and (Get-OfficeDeploymentDefinitions).OfficeReleaseHistory -in $script:heads) 'Windows 10 assessment must check history availability without resolving the build.'
|
||||
$script:headCode=204
|
||||
Assert-OfficeThrows { Test-OfficeDownloadLinks $options } 'returned 204; expected 200'
|
||||
$script:headFails=$true
|
||||
Assert-OfficeThrows { Test-OfficeDownloadLinks $options } 'HEAD check failed.*HEAD unsupported'
|
||||
$path = Join-Path $testRoot 'not-created\EmberkomOfficeDeployment'
|
||||
$before = @(Get-ChildItem -LiteralPath $testRoot -Force).Count
|
||||
$result = Assert-OfficeWritablePath $path
|
||||
Assert-OfficeTest (!(Test-Path -LiteralPath $path) -and $result.TestedDirectory -eq $testRoot -and @(Get-ChildItem -LiteralPath $testRoot -Force).Count -eq $before) 'Write checks must remove probes and never create deployment directories.'
|
||||
$file = Join-Path $testRoot 'not-a-directory'; Set-Content -LiteralPath $file -Value 'fixture'
|
||||
Assert-OfficeThrows { Assert-OfficeWritablePath $file } 'not a directory'
|
||||
}
|
||||
# Inspect persisted state without touching the actual registry or Office service.
|
||||
& {
|
||||
function Test-Path { return $true }
|
||||
function Get-Item { [pscustomobject]@{PSPath='fixture';Name='ClickToRun'} }
|
||||
function Get-ChildItem { }
|
||||
function Get-Service { [pscustomobject]@{Name='ClickToRunSvc'} }
|
||||
function Get-ItemProperty { [pscustomobject]@{WorkingConfiguration='old-guid';SourcePath='C:\Windows\SystemTemp\EmberkomOfficeDeployment\old\ODT';Platform='x64'} }
|
||||
$state = Get-OfficeClickToRunState
|
||||
Assert-OfficeTest ($state.Present -and $state.WorkingConfiguration[0] -eq 'old-guid' -and $state.SourceReferences.Count -eq 1) 'Interrupted Click-to-Run configuration must be detected without installed products.'
|
||||
Assert-OfficeThrows { Assert-OfficeFreshInstallState } 'still retains previous deployment state.*Installation stopped.*old-guid'
|
||||
function Get-ItemProperty { [pscustomobject]@{Platform='x64'} }
|
||||
$null = Assert-OfficeFreshInstallState
|
||||
function Get-ItemProperty { throw 'Registry access denied' }
|
||||
Assert-OfficeThrows { Assert-OfficeFreshInstallState } 'Registry access denied'
|
||||
}
|
||||
# Execute the real deferred action with only its live download replaced.
|
||||
& {
|
||||
$id='d'*32; $script:liveHelperId=$null
|
||||
function New-Object {
|
||||
param($TypeName)
|
||||
Assert-OfficeTest ($TypeName -eq 'Net.WebClient') 'Deferred cleanup must fetch its helper live.'
|
||||
$client=[pscustomobject]@{}
|
||||
$client | Add-Member ScriptMethod DownloadString { param($Uri) '# EmberkomOfficeUserCleanup-v5' + [Environment]::NewLine + 'param($DeploymentId) $script:liveHelperId=$DeploymentId' }
|
||||
$client | Add-Member ScriptMethod Dispose { }
|
||||
$client
|
||||
}
|
||||
$command=[Text.Encoding]::Unicode.GetString([Convert]::FromBase64String((New-OfficeUserCleanupCommand $id)))
|
||||
& ([scriptblock]::Create($command))
|
||||
Assert-OfficeTest ($script:liveHelperId -eq $id -and !$command.Contains('-File ')) 'Deferred cleanup must execute freshly fetched source in memory with the correct deployment ID.'
|
||||
}
|
||||
# A new deployment clears every previous GUID workspace, including legacy caches,
|
||||
# while preserving logs and refusing to race a previous installer or user task.
|
||||
& {
|
||||
$root=Join-Path $testRoot 'old-deployments'; $null=[IO.Directory]::CreateDirectory($root)
|
||||
$old=Join-Path $root ('e'*32); $null=[IO.Directory]::CreateDirectory((Join-Path $old 'ODT'))
|
||||
$legacyMetadata=Join-Path $testRoot ('OfficeReleaseHistory-' + ('e'*32) + '.html'); Set-Content -LiteralPath $legacyMetadata -Value 'abandoned metadata'
|
||||
foreach ($name in @('ODT\payload.dat','ODT\native.log','install.xml','remove.xml','options.json','media-cache.json','Office-UserCleanup.ps1','user-cleanup.lock','reinstall-started','result.log')) { Set-Content -LiteralPath (Join-Path $old $name) -Value 'old content, not reusable' }
|
||||
$unknown=Join-Path $root 'unrelated'; $null=[IO.Directory]::CreateDirectory($unknown); Set-Content -LiteralPath (Join-Path $unknown 'keep.txt') -Value 'untouched'
|
||||
function Get-OfficeDeploymentRoots { $root }
|
||||
$script:oldInstaller=$false; $script:oldTaskState='Running'; $script:oldTaskRemoved=$false
|
||||
function Get-CimInstance { if ($script:oldInstaller) { [pscustomobject]@{Name='OfficeClickToRun.exe';CommandLine='OfficeClickToRun.exe platform=x64'} } }
|
||||
function Get-ScheduledTask { if (!$script:oldTaskRemoved) { [pscustomobject]@{TaskName="Emberkom-OfficeCleanup-$('e'*32)-S-1-5-21-123";TaskPath='\';State=$script:oldTaskState} } }
|
||||
function Disable-ScheduledTask { Assert-OfficeTest ($script:oldTaskState -eq 'Ready') 'Only idle tasks may be retired.' }
|
||||
function Unregister-ScheduledTask { $script:oldTaskRemoved=$true }
|
||||
Assert-OfficeThrows { Clear-OfficePreviousDeploymentFiles } 'user cleanup is still running'
|
||||
Assert-OfficeTest (Test-Path -LiteralPath (Join-Path $old 'ODT\payload.dat')) 'Active user tasks must block old-cache cleanup.'
|
||||
$script:oldTaskState='Ready'; $script:oldInstaller=$true
|
||||
Assert-OfficeThrows { Clear-OfficePreviousDeploymentFiles } 'surviving installer'
|
||||
$script:oldInstaller=$false
|
||||
Clear-OfficePreviousDeploymentFiles
|
||||
$remaining=@(Get-ChildItem -LiteralPath $old -Recurse -File)
|
||||
Assert-OfficeTest ($script:oldTaskRemoved -and $remaining.Count -eq 2 -and @($remaining | Where-Object Extension -ne '.log').Count -eq 0) 'Previous cached downloads, options and scripts must be removed; nested logs must remain.'
|
||||
Assert-OfficeTest (!(Test-Path -LiteralPath $legacyMetadata)) 'Abandoned legacy assessment metadata must be removed too.'
|
||||
Assert-OfficeTest (Test-Path -LiteralPath (Join-Path $unknown 'keep.txt')) 'Cleanup must stay within GUID deployment folders.'
|
||||
Clear-OfficePreviousDeploymentFiles
|
||||
Assert-OfficeTest (@(Get-ChildItem -LiteralPath $old -Recurse -File).Count -eq 2) 'Cleanup must be repeatable with logs-only directories.'
|
||||
}
|
||||
# Cleanup runs synchronously on every install exit. Only logs survive in staging;
|
||||
# pending-user tasks retain synchronization state but fetch their helper live.
|
||||
& {
|
||||
$root = Join-Path $testRoot 'temporary-downloads'; $null = [IO.Directory]::CreateDirectory($root)
|
||||
$workspace = Join-Path $root ('c' * 32); $null = [IO.Directory]::CreateDirectory($workspace)
|
||||
@@ -870,7 +957,7 @@ try {
|
||||
}
|
||||
$media = [pscustomobject]@{Helper=(Join-Path $workspace 'Office-UserCleanup.ps1')}
|
||||
$userWorkspace = New-OfficeUserWorkspace $media $workspace
|
||||
Assert-OfficeTest ($media.Helper -eq (Join-Path $userWorkspace 'Office-UserCleanup.ps1') -and (Test-Path -LiteralPath $media.Helper)) 'User helper was not separated from staged installers.'
|
||||
Assert-OfficeTest (!(Test-Path -LiteralPath (Join-Path $userWorkspace 'Office-UserCleanup.ps1')) -and (Test-Path -LiteralPath (Join-Path $userWorkspace 'user-cleanup.lock'))) 'Pending tasks must retain only synchronization state, never cached code.'
|
||||
$script:cleanupTasks = $true; $script:cleanupProcess = $true
|
||||
function Get-CimInstance { if ($script:cleanupProcess) { [pscustomobject]@{CommandLine="setup.exe $workspace\install.xml"} } }
|
||||
function Get-ScheduledTask { if ($script:cleanupTasks) { [pscustomobject]@{TaskName="Emberkom-OfficeCleanup-$('c' * 32)-SID"; State='Ready'} } }
|
||||
@@ -880,7 +967,8 @@ try {
|
||||
$script:cleanupProcess = $false
|
||||
$warnings = Complete-OfficeDeploymentFiles $workspace $userWorkspace
|
||||
Assert-OfficeTest (!$warnings.Count -and !(Test-Path -LiteralPath (Join-Path $workspace 'ODT')) -and !(Test-Path -LiteralPath (Join-Path $workspace 'odt.exe')) -and (Test-Path -LiteralPath (Join-Path $workspace 'office-install.stdout.log'))) 'Completion must remove media and preserve diagnostics.'
|
||||
Assert-OfficeTest (Test-Path -LiteralPath $media.Helper) 'Temporary media cleanup deleted the pending-user helper.'
|
||||
Assert-OfficeTest (!(Test-Path -LiteralPath $media.Helper) -and @(Get-ChildItem -LiteralPath $workspace -File | Where-Object Extension -ne '.log').Count -eq 0) 'Deployment cleanup must leave only log files.'
|
||||
Assert-OfficeTest (Test-Path -LiteralPath (Join-Path $userWorkspace 'user-cleanup.lock')) 'Pending-user synchronization state must survive staging cleanup.'
|
||||
$script:cleanupTasks = $false
|
||||
$warnings = Complete-OfficeDeploymentFiles $workspace $userWorkspace
|
||||
Assert-OfficeTest (!$warnings.Count -and !(Test-Path -LiteralPath $userWorkspace)) 'Completed user cleanup left its helper folder behind.'
|
||||
@@ -922,6 +1010,11 @@ try {
|
||||
throw "Unexpected object requested by orchestration fixture: $TypeName"
|
||||
}
|
||||
function Assert-OfficeDeploymentHost { }
|
||||
function Assert-OfficeWritablePath { param($Path) [pscustomobject]@{Path=$Path} }
|
||||
function Test-OfficeDownloadLinks { [pscustomobject]@{StatusCode=200;Method='HEAD'} }
|
||||
function Get-OfficeClickToRunState { [pscustomobject]@{Present=$false;SourceReferences=@();WorkingConfiguration=@()} }
|
||||
function Clear-OfficePreviousDeploymentFiles { if ($script:mode -eq 'old-cache') { throw 'Previous artifacts are locked' }; $script:priorCleanupRuns++ }
|
||||
function Assert-OfficeFreshInstallState { if ($script:mode -eq 'stale-state') { throw 'Previous Click-to-Run state remains' } }
|
||||
function Assert-OfficeDiskSpace { param($Workspace,[switch]$DownloadingMedia) if ($script:mode -eq 'preflight-space') { throw 'Insufficient disk space before download' }; if ($script:mode -eq 'disk-space' -and !$DownloadingMedia) { throw 'Insufficient disk space after staging' } }
|
||||
function Resolve-OfficeTargetVersion { if ($script:mode -eq 'release') { throw 'Release metadata unavailable' } }
|
||||
function Complete-OfficeDeploymentFiles { param($Workspace,$UserWorkspace) $script:artifactCleanupRuns++; if ($script:mode -eq 'download-cleanup') { throw 'Synthetic cleanup failure' }; if ($script:mode -eq 'cleanup-warning') { return ,@('Synthetic file in use') }; return ,@() }
|
||||
@@ -952,7 +1045,7 @@ try {
|
||||
function Install-OfficeCompanionApps { param($Media,$Workspace,[bool]$InstallTeams) $script:teamsRequested=$InstallTeams; $script:events += 'install-companions'; if ($script:mode -eq 'install-companions') { throw 'companion install failure' }; [pscustomobject]@{ExitCode=$(if ($script:mode -eq 'companion-reboot') {3010} else {0}); Versions=@{NewOutlook='1'; OneDrive='1'}} }
|
||||
$script:removalStillRegistered=$false
|
||||
$options = Get-OfficeDeploymentOptions @{OfficeSubscription='Microsoft 365 Business Premium'; OfficeAppShutdown='Force'; ValidateBeforeChanges='false'; DeferReboot='false'}
|
||||
foreach ($script:mode in @('success','download','download-cleanup','disk-space','companions','remove-office','identity','user','phase','install','install-companions','pending','reboot','office-reboot','companion-reboot')) {
|
||||
foreach ($script:mode in @('success','download','download-cleanup','disk-space','companions','remove-office','stale-state','identity','user','phase','install','install-companions','pending','reboot','office-reboot','companion-reboot')) {
|
||||
$script:artifactCleanupRuns = 0
|
||||
$script:events = @(); $errorResult = $null; $result = $null
|
||||
try { $result = Invoke-OfficeDeployment $options } catch { $errorResult = $_ }
|
||||
@@ -979,7 +1072,10 @@ try {
|
||||
$options.ValidateBeforeChanges=$false
|
||||
$script:mode='cleanup-warning'; $script:events=@()
|
||||
$result = @(Invoke-OfficeDeployment $options)
|
||||
Assert-OfficeTest ($result.Count -eq 1 -and $result[0].ArtifactCleanupPending -and $result[0].ExitCode -eq 0 -and $result[0].OfficeDeploymentStatus -eq 'Installed') 'Artifact cleanup problems corrupted the receipt or failed a verified installation.'
|
||||
Assert-OfficeTest ($result.Count -eq 1 -and $result[0].ArtifactCleanupPending -and $result[0].ExitCode -eq 2 -and $result[0].OfficeDeploymentStatus -eq 'InstalledWithArtifactCleanupPending') 'Unremoved artifacts must report partial completion instead of clean success.'
|
||||
$script:mode='old-cache'; $script:events=@(); $script:workspaceCreates=0
|
||||
Assert-OfficeThrows { Invoke-OfficeDeployment $options } 'Previous artifacts are locked'
|
||||
Assert-OfficeTest ($script:events.Count -eq 0 -and $script:workspaceCreates -eq 0) 'Old artifacts must be cleared before creating or downloading a new deployment.'
|
||||
foreach ($script:mode in @('registration','registration-and-pending','registration-reboot')) {
|
||||
$script:events=@(); $script:artifactCleanupRuns=0
|
||||
function Install-OfficeMedia { $script:events += 'install'; if ($script:mode -eq 'registration-reboot') { return 3010 }; return 0 }
|
||||
@@ -1010,12 +1106,12 @@ try {
|
||||
Assert-OfficeTest (!$result.RestartRequired -and $result.ExitCode -eq 0) 'A clean deployment without restart requests must not demand a restart.'
|
||||
foreach ($shutdown in @('Abort','Force')) {
|
||||
foreach ($validate in @($null, '', 'true')) {
|
||||
$script:events=@(); $script:workspaceCreates=0; $script:artifactCleanupRuns=0
|
||||
$script:events=@(); $script:workspaceCreates=0; $script:artifactCleanupRuns=0; $script:priorCleanupRuns=0
|
||||
$options = Get-OfficeDeploymentOptions @{OfficeSubscription='Microsoft/Office 365 E3/E5 (no Teams)'; OfficeAppShutdown=$shutdown; ValidateBeforeChanges=$validate}
|
||||
$result = Invoke-OfficeDeployment $options
|
||||
Assert-OfficeTest ($result.OfficeDeploymentStatus -eq 'ValidationPassed' -and $result.ExitCode -eq 0 -and $result.ValidateBeforeChanges) 'Validation did not produce a distinct result.'
|
||||
Assert-OfficeTest ($result.OfficeRemovalMethod -eq 'SilentODT' -and $result.DeferReboot -is [bool] -and $result.DeferReboot) 'Validation must identify the silent removal method and Boolean restart selection.'
|
||||
Assert-OfficeTest ($script:events.Count -eq 0 -and $script:workspaceCreates -eq 0 -and $script:artifactCleanupRuns -eq 0 -and !$result.MediaDownloaded -and !$result.Workspace) 'Validation downloaded media, created a workspace or reached a deployment action.'
|
||||
Assert-OfficeTest ($script:events.Count -eq 0 -and $script:workspaceCreates -eq 0 -and $script:artifactCleanupRuns -eq 0 -and $script:priorCleanupRuns -eq 0 -and !$result.MediaDownloaded -and !$result.Workspace -and !$result.MetadataResolved) 'Validation downloaded media, created a workspace or reached a deployment action.'
|
||||
Assert-OfficeTest (!$result.TeamsSelected -and $result.ProfileCount -eq 1 -and $result.ExistingOffice[0] -eq 'Synthetic Office') 'Validation report lost the deployment plan.'
|
||||
}
|
||||
}
|
||||
@@ -1028,8 +1124,11 @@ try {
|
||||
Assert-OfficeThrows { Invoke-OfficeDeployment $options } 'Apps are running'
|
||||
Assert-OfficeTest ($script:events.Count -eq 0) 'Validation did not stop on an Abort prerequisite failure.'
|
||||
$options.OfficeAppShutdown='Force'; $script:mode='release'; $script:events=@()
|
||||
$result = Invoke-OfficeDeployment $options
|
||||
Assert-OfficeTest ($result.OfficeDeploymentStatus -eq 'ValidationPassed' -and !$result.MetadataResolved) 'Assessment must not request release metadata.'
|
||||
$options.ValidateBeforeChanges=$false
|
||||
Assert-OfficeThrows { Invoke-OfficeDeployment $options } 'Release metadata unavailable'
|
||||
Assert-OfficeTest ($script:events.Count -eq 0) 'Failed validation reached media downloads or mutations.'
|
||||
Assert-OfficeTest ($script:events.Count -eq 0) 'Failed release resolution reached media downloads or app removal.'
|
||||
$options.ValidateBeforeChanges='false'
|
||||
Assert-OfficeThrows { Invoke-OfficeDeployment $options } 'validated Boolean'
|
||||
$options.ValidateBeforeChanges=$false; $options.DeferReboot='false'; $script:events=@()
|
||||
@@ -1120,8 +1219,10 @@ __LAUNCH__
|
||||
Assert-OfficeTest ($probeExitCode -eq $case.Code) "Shim did not propagate workload exit $($case.Code): $probeOutput"
|
||||
$probeText = $probeOutput | Out-String
|
||||
if ($case.Mode -eq 'success') {
|
||||
Assert-OfficeTest ($probeText.IndexOf('{') -ge 0) "Main workload receipt is missing from shim output: $probeText"
|
||||
$receipt = $probeText.Substring($probeText.IndexOf('{')) | ConvertFrom-Json
|
||||
# Temp/log paths can contain GUID braces; locate the JSON object's line.
|
||||
$receiptStart = [regex]::Match($probeText, '(?m)^\s*\{\s*\r?$')
|
||||
Assert-OfficeTest $receiptStart.Success "Main workload receipt is missing from shim output: $probeText"
|
||||
$receipt = $probeText.Substring($receiptStart.Index) | ConvertFrom-Json
|
||||
Assert-OfficeTest ($receipt.ProductId -eq 'O365ProPlusEEANoTeamsRetail' -and $receipt.Company -ceq $probeValues.COMPANY -and $receipt.Activation -eq 'SharedComputer') 'Shim lost injected strings before main workload.'
|
||||
Assert-OfficeTest ($receipt.ValidateBeforeChanges -eq ($case.Validate -ne 'false')) 'Shim lost the validation gate.'
|
||||
Assert-OfficeTest ($receipt.DeferReboot -is [bool] -and !$receipt.DeferReboot) 'Shim/main entry lost or misparsed the injected false restart string.'
|
||||
@@ -1162,8 +1263,11 @@ exit $resultCode
|
||||
'@
|
||||
$nativeProbePath = Join-Path $testRoot 'host-probe.ps1'; Set-Content -LiteralPath $nativeProbePath -Value $nativeProbeTemplate.Replace('__ENTRY__', $entryText)
|
||||
$x86PowerShell = Join-Path $env:WINDIR 'SysWOW64\WindowsPowerShell\v1.0\powershell.exe'
|
||||
$ErrorActionPreference='Continue'
|
||||
$hostOutput = & $x86PowerShell -NoProfile -ExecutionPolicy Bypass -File $nativeProbePath 2>&1
|
||||
Assert-OfficeTest ($LASTEXITCODE -eq 2) '32-bit Syncro host lost the native-host exit code.'
|
||||
$hostExitCode = $LASTEXITCODE
|
||||
$ErrorActionPreference='Stop'
|
||||
Assert-OfficeTest ($hostExitCode -eq 2) '32-bit Syncro host lost the native-host exit code.'
|
||||
$hostText = $hostOutput | Out-String
|
||||
Assert-OfficeTest ($hostText -match 'Native host probe' -and $hostText -notmatch 'CLIXML') 'Native host messages must remain readable in Syncro.'
|
||||
$hostResult = $hostText.Substring($hostText.IndexOf('{')) | ConvertFrom-Json
|
||||
|
||||
Reference in New Issue
Block a user