Hello everyone,
In my Invoke-AppDeployToolkit.ps1 script, I have a 64-bit DLL that crashes when I deploy it via Intune because Intune uses 32-bit PowerShell. So, it does not execute correctly when run from a 32-bit PowerShell session on a 64-bit operating system.
I've tried the following code inside PSADT script to check if PowerShell is running in 32-bit and to restart it as a 64-bit process, but it didn't work:
If([Environment]::Is64BitOperatingSystem){
Write-ADTLogEntry -Message "Running 32-bit Powershell on 64-bit OS, Restarting as 64-bit Process..." -Severity 2
$Arguments = "-NoProfile -ExecutionPolicy ByPass -WindowStyle Hidden -File `"" + $MyInvocation.MyCommand.Path + "`""
$Path = (Join-Path $Env:SystemRoot -ChildPath "\sysnative\WindowsPowerShell\v1.0\powershell.exe")
Start-Process $Path -ArgumentList $Arguments -Wait
Write-ADTLogEntry -Message "Finished Running x64 version of PowerShell"
Exit
}Else{
Write-ADTLogEntry -Message "Running 32-bit Powershell on 32-bit OS"
}
}
I've also found the Invoke-ADTRegSvr32 command and I'm about to try it out. Is there a simpler way to run the entire script in 64-bit?
If anyone has encountered a similar issue or has a simpler solution for running the script in 64-bit PowerShell, I would greatly appreciate your help!
Thank you in advance!