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.
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
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
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.