Further to my question / discussion about the PSADT Registry functions (Working with Registry keys using PSADT 4.1.x), I've found that my attempt to write to HKLM:\SOFTWARE\CompanyName\SSMS 21\ results in it actually being written to HKLM:\SOFTWARE\WOW6432Node\CompanyName\SSMS 21\.
I have realised that as a result of my Intune deployment command line:
Powershell.exe -ExecutionPolicy Bypass .\Invoke-AppDeployToolkit.ps1 -DeploymentType "Install"
is actually running PowerShell as 32-bit on my 64-bit OS machine - (I understand this is the default)
So, after reading the following (old) discussion:
I have realised that I could solve this by changing the PowerShell.exe path to:
%windir%\sysnative\WindowsPowershell\v1.0\Powershell.exe ....
However...
Alternatively, if put the following PowerShell architecture detection logic at the start of the Invoke-AppDeployToolkit.ps1 script:
# Relaunch in 64-bit PowerShell if running in 32-bit mode
if ($env:PROCESSOR_ARCHITECTURE -ne "AMD64") {
Write-Output "Re-launching script in 64-bit PowerShell..."
$scriptPath = $MyInvocation.MyCommand.Definition
Start-Process -FilePath "$env:SystemRoot\SysNative\WindowsPowerShell\v1.0\powershell.exe" -ArgumentList "-ExecutionPolicy Bypass -File `"$scriptPath`"" -Wait
exit
}
PowerShell would be relaunched if the Architecture is capable
IMHO The advantage to the above logic addition is the install (and uninstall) command line can be kept shorter (tidier) and the Invoke-AppDeployToolkit.ps1 script can be left to determine the correct OS architecture and relaunch PowerShell if required, therefore the command line would work for both 32-bit and 64-bit (Intel / AMD) architecture.
Question to the floor: Would it be better to leave the Install (and uninstall) command as default and use the logic or is there a valid reason why the detection logic shouldn't be included in the Invoke-AppDeployToolkit.ps1 script?
or for a bit of fun here's a poll:
- Leave Install (and Uninstall) Command line as default
PowerShell.exe - ExecutionPolicy...and add OS detection logic withinInvoke-AppDeployToolKit.ps1script - Change Install (and Uninstall) Command line to
%windir%\sysnative\WindowsPowershell\v1.0\powershell.exe -ExecutionPolicyand not add OS detection logic withinInvoke-AppDeployToolKit.ps1script