Run PowerShell scripts in 64-bit mode using SCCM Package

SCCM Packages run in 32-bit context, which forces System32 to be redirected to SysWOW64 on a 64-bit system. Even the SCCM CB version Packages run in 32-bit mode. So you might have faced difficulties in running powershell scripts in 64-bit mode.
The fix for this is to ensure your batch file has the following lines:

%SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File YourScript.ps1

“sysnative” here is like a virtual folder or variable that helps you access the otherwise inaccessible 64-bit System32 in 32-bit CMD.
You can try it out on your own system by opening CMD.exe from the SysWOW64 folder as shown below.

I still wonder why SCCM packages still run in 32-bit mode and I hope MS implements an option to disable 64-bit redirection for packages too.

CategoriesIT

Leave a Reply

Your email address will not be published.