Invoke x86 Shell Session

Welcome Forums General PowerShell Q&A Invoke x86 Shell Session

This topic contains 3 replies, has 3 voices, and was last updated by

3 years, 2 months ago.

  • Author
  • #31180

    Points: 0
    Rank: Member

    How could I use invoke-command or a similar cmdlet to start a x86 session and then pass it a script to execute in a script block? I'm using a script that allows me to use the com object for the Active Directory Migration Toolkit and it needs to be elevated and running in a x86 shell session.

  • #31219

    Points: 24
    Team Member
    Rank: Member

    You will need to open a new PSSession and specify the 32-bit session configuration as shown below:

    $s = New-PSSession -ConfigurationName microsoft.powershell32 -ComputerName localhost
    Invoke-Command -Session $s -ScriptBlock { $env:PROCESSOR_ARCHITECTURE }

    However with ADMT it will probably not work because you'll run into the second/double-hop scenario.

    Without using Remoting you can run a 32-bit PowerShell session locally with the following command:

  • #31244

    Points: 5
    Rank: Member


    You can use this to have a script re-launch itself if it isn't running in the right type of session.

    Param ( [string]$YourParam1, [int]$YourParam2 )
    If ( [IntPtr]::Size * 8 -ne 32 )
        C:\Windows\SysWOW64\WindowsPowerShell\v1.0\PowerShell.exe -File $MyInvocation.MyCommand.Path -YourParam1 $YourParam1 -YourParam2 $YourParam2
        # Your code here

    You can read more about it here:

  • #31288

    Points: 0
    Rank: Member

    Appreciate the replies, I ended up getting the 32bit session to work by using the session options. However, I ran into a runspace issue with ADMT. I don't fully understand it yet, but by invoking the command on the box it's not able to connect to the domain controller in the source domain. Error shown below, not sure how to get around that yet.

    Unable to migrate users. Cannot get name of domain controller holding the RID master role in domain
    ''. Access is denied.

The topic ‘Invoke x86 Shell Session’ is closed to new replies.