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

 
Participant
3 years, 7 months ago.

  • Author
    Posts
  • #31180

    Participant
    Topics: 4
    Replies: 13
    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

    Moderator
    Topics: 2
    Replies: 525
    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:

    C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
    
  • #31244

    Participant
    Topics: 9
    Replies: 62
    Points: 6
    Rank: Member

    Duffney,

    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
        }
    Else
        {
        # Your code here
        }
    

    You can read more about it here: http://www.madwithpowershell.com/2015/06/64-bit-vs-32-bit-powershell.html

  • #31288

    Participant
    Topics: 4
    Replies: 13
    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
    'sourcedomain.targetdomain.org'. Access is denied.

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

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort