Link to home
Start Free TrialLog in
Avatar of itnifl
itniflFlag for Norway

asked on

Want to create a 32 bit remote powershell session

This is what I do:

. E:\VMWare\scriptWithMyFunction.ps1	
$username = "username";
$password = ConvertTo-SecureString -String "password" -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
$session = New-PSSession -Credential $cred -ComputerName "serverdnsname"
$a = Invoke-Command -Session $session -ScriptBlock ${function:myFunction} -ArgumentList $var1, $var2, $var3

Open in new window


However, this starts a 64 bit powershell session and when loading the VMware.VimAutomation.Core snapin, an error message gets thrown that states: "This cmdlet requires 32bit process."

So how can I make a 32 bit process and still do the above?
Avatar of Dale Harris
Dale Harris
Flag of United States of America image

Try opening the Powershell (x86) version on your computer, then run the script again.  See if that's the key.
Avatar of itnifl

ASKER

I run the script from System Center Orchestrator, which by default starts 32-bit Powershell 2.0. When Invoke-Command is used, this starts a 64-bit powershell 4.0 session. This source says 3.0, but I am jumping to the assumption that 4.0 was not there at the time? http://windowsitpro.com/orchestrator/call-windows-powershell-orchestrator
Avatar of Qlemo
You'll need to call Invoke-Command (or in your case New-PsSession) with –ConfigurationName Microsoft.PowerShell32 to start a 32bit session.
Avatar of itnifl

ASKER

Yeah, if that would only work. I have only seen documentation on Invoke-Command for PS 3.0 and PS4.0, not PS2.0 that Orchestrator uses by default. I have seen those suggestions on the internet/google, and it has not worked:

The error is simple when using the suggestion:
Invoke-Command : Parameter set cannot be resolved using the specified named parameters.

I have tried to out all the code in a function, then run invoke-command to run the function in PS4.0 64bit, then run invoke-command again inside that function remoting to the host with the following:

Invoke-Command -Session $session  –ConfigurationName Microsoft.PowerShell32 -ScriptBlock ${function:myFunction} -ArgumentList $var1, $var2, $var3,

Open in new window


Results in same error as above.
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of itnifl

ASKER

Thanks, would wish the error message was that specific..