Using 64-bit PowerShell Code with Automox

Using 64-bit PowerShell Code with Automox 

By default, the Automox agent runs 32-bit PowerShell because it is a 32-bit application. However, certain tasks may require 64-bit PowerShell. This guide explains how to pass 64-bit PowerShell code through an Automox Worklet using a scriptBlock.

Script Format

To execute 64-bit PowerShell code, use the following script format:

$scriptBlock = { YOURCODEHERE }

$exitCode = & "$env:SystemRoot\sysnative\WindowsPowerShell\v1.0\powershell.exe" `

    -ExecutionPolicy Bypass `

    -WindowStyle Hidden `

    -NoProfile `

    -NonInteractive `

    -Command $scriptBlock

Explanation

  • $scriptBlock:
    This is where you define the PowerShell commands or script that you want to execute. Replace YOURCODEHERE with the actual commands.
  • Calling 64-bit PowerShell:
    The path $env:SystemRoot\sysnative\WindowsPowerShell\v1.0\powershell.exe ensures the 64-bit version of PowerShell is invoked, even though the Automox agent runs as a 32-bit application. The sysnative directory provides a way for 32-bit processes to access 64-bit system files.
  • PowerShell Flags:
    • ExecutionPolicy Bypass: Allows the script to run regardless of the system’s PowerShell execution policy settings.
    • WindowStyle Hidden: Prevents the PowerShell window from appearing during execution.
    • NoProfile: Runs PowerShell without loading any user profiles, ensuring a clean environment.
    • NonInteractive: Prevents the script from prompting the user for input, ensuring automated execution.
Was this article helpful?
0 out of 0 found this helpful