@@ -33,8 +33,9 @@ function Invoke-IntuneWin32AppTest {
3333 # uninstalled before this app installs, an update target stays (W32-SUP-OLD-A, W32-SUP-OLD-B)
3434 [hashtable []]$Supersedes ,
3535
36+ # Left out: the device's 64-bit host (x64, or arm64 on Windows on ARM), the agent's default
3637 [ValidateSet (' x86' , ' x64' , ' arm64' )]
37- [string ]$Architecture = ' x64 ' ,
38+ [string ]$Architecture ,
3839
3940 [ValidateSet (' User' , ' System' )]
4041 [string ]$Context = ' User' ,
@@ -64,6 +65,9 @@ function Invoke-IntuneWin32AppTest {
6465 [switch ]$EnforceSignatureCheck
6566 )
6667 Write-Verbose " Starting $ ( $MyInvocation.MyCommand.Name ) for $ ( $PSBoundParameters.Keys -join ' , ' ) "
68+ # The agent's default host is the device's 64-bit one: arm64 on Windows on ARM, where no x64
69+ # host exists, and x64 elsewhere
70+ if (-not $Architecture ) { $Architecture = Get-IslHostArchitecture }
6771
6872 if (-not $DetectionPath -and -not $DetectionRule ) {
6973 throw ' Give a detection script (-DetectionPath), detection rules (-DetectionRule), or both'
@@ -132,11 +136,29 @@ function Invoke-IntuneWin32AppTest {
132136 # cmd.exe, as the agent's own 32-bit process does
133137 function Invoke-ContentCommand {
134138 param ([string ]$Phase , [string ]$Content , [string ]$CommandLine )
135- if ($CommandLine -match ' (?i)(^|[\s"])powershell(\.exe)?([\s"]|$)' ) {
139+ $source = (Resolve-Path - LiteralPath $Content ).ProviderPath
140+ $hostPattern = ' (?i)(^|[\s"])powershell(\.exe)?([\s"]|$)'
141+ if ($CommandLine -match $hostPattern ) {
136142 $warnings.Add (" powershell.exe in the $Phase command runs the 32-bit host (the agent is a 32-bit " +
137143 ' process); HKLM:\SOFTWARE and Program Files are redirected there' )
138144 }
139- $source = (Resolve-Path - LiteralPath $Content ).ProviderPath
145+ else {
146+ # The same host hides inside a batch file the command line names: install.cmd calling
147+ # powershell.exe runs it 32-bit too, from the agent's 32-bit cmd.exe, without the
148+ # command line showing it
149+ $first = if ($CommandLine -match ' ^\s*"([^"]+)"' ) { $Matches [1 ] }
150+ else { ($CommandLine.Trim () -split ' \s+' , 2 )[0 ] }
151+ $batch = if ($first -match ' (?i)\.(cmd|bat)$' ) { Join-Path - Path $source - ChildPath $first }
152+ else { $null }
153+ if ($batch -and (Test-Path - LiteralPath $batch - PathType Leaf)) {
154+ $hit = Select-String - LiteralPath $batch - Pattern $hostPattern | Select-Object - First 1
155+ if ($hit ) {
156+ $warnings.Add (" powershell.exe in $first (line $ ( $hit.LineNumber ) ), which the $Phase " +
157+ ' command runs through the 32-bit cmd.exe, is the 32-bit host (the agent is a 32-bit ' +
158+ ' process); HKLM:\SOFTWARE and Program Files are redirected there' )
159+ }
160+ }
161+ }
140162 $runId = [guid ]::NewGuid().ToString(' N' )
141163 # Another account cannot reach the caller's temp folder; its copy lives under ProgramData
142164 $cache = if ($Credential ) {
0 commit comments