VMware Cloud Community
JHurlstone
Contributor
Contributor

vCO Powershell Plugin and x86 Modules

Hi.

I am looking for some help in initiating an x86 Powershell session via the vCO Powershell plugin.

The Powershell module and its associated cmdlets I need to use are only available to me as x86 ONLY.

By default the vCO Powershell Plugin initiates a x64 Powershell session.

After some searching the only way I have at the moment is to get the native x64 Powershell to spawn a x86 Powershell instance, I was hoping that someone would know if there was a way of configuring the vCO Powershell plugin to use the x86 Powershell instance by default.

Any help would be appreciated, many thanks in advance.

Tags (4)
0 Kudos
3 Replies
SpasKaloferov
VMware Employee
VMware Employee

HI,

For example i can open a x64 bit Powershell and run the following commands:

[Environment]::Is64BitProcess

Enter-PSSession -ComputerName localhost -ConfigurationName Microsoft.PowerShell32

[Environment]::Is64BitProcess

I’m using [Environment]::Is64BitProcess just to determine if my powershell is x64 or not. As you can see when you execute this, at the beginning you will start with x64 bit powershell and then chang to x86 powershell .

Having this said whan you can run form vRO lets say if you want to add the SCCM Administrator Console modules :

Enter-PSSession -ComputerName localhost -ConfigurationName Microsoft.PowerShell32

Cd 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin”

Import-Module .\ConfigurationManager.psd1

If it has to be on one line command, it will look like this:

Enter-PSSession -ComputerName localhost -ConfigurationName Microsoft.PowerShell32; Cd 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin” ; Import-Module .\ConfigurationManager.psd1

Note: Depending how they call it from vRO they should keep note about the escape characters.

Note2: If powershell returns an error that the session doesn’t exists run new-PSSession and then enter-PSSession, but i don't think you will need this.


Best Regards,

Spas Kaloferov

0 Kudos
SpasKaloferov
VMware Employee
VMware Employee

HI

At this point there is no possibility to do this from vRO, but this has been raised as feature request.

BR,

Spas Kaloferov

0 Kudos
SpasKaloferov
VMware Employee
VMware Employee

HI,

The New-PSession is a bit picky and might result in error when used in scripts so you can use invoke-command instead. I’ve tested this in vRO and it works. Invoke command requires credentials to be supplied to the command. The credentials from the other hand require credSSP to be enabled on the powershell host. To enable credSSP you might visit,

Using CredSSP with the vCO PowerShell Plugin

http://kaloferov.com/blog/using-credssp-with-the-vco-powershell-plugin/

In the example here I’ve again run the [Environment]::Is64BitProcess command but this time used the Invoke-command and specified that I want to execute in a 32-bit session.

$psUsername = <username>;

$psPassword = <password>;

$psCred = New-Object System.Management.Automation.PSCredential -ArgumentList @($psUsername,(ConvertTo-SecureString -String $psPassword -AsPlainText -Force)) ;

Invoke-Command -ComputerName localhost -ConfigurationName Microsoft.PowerShell32 -ScriptBlock { [Environment]::Is64BitProcess } -Authentication CredSSP -credential $psCred

Command on one line:

$psUsername = <username>; $psPassword = <password>; $psCred = New-Object System.Management.Automation.PSCredential -ArgumentList @($psUsername,(ConvertTo-SecureString -String $psPassword -AsPlainText -Force)) ; Invoke-Command -ComputerName localhost -ConfigurationName Microsoft.PowerShell32 -ScriptBlock { [Environment]::Is64BitProcess } -Authentication CredSSP -credential $psCred

After execution you should see a result of False indicating that you run a 32-bit session.

pastedImage_1.png

I’ve also written a workflow that simplifies the credSSP in scripts. If interested , visit:

Introducing the Add CredSSP to a PowerShell script (vROCmdlet) workflow

http://kaloferov.com/blog/introducing-the-add-credssp-to-a-powershell-script-vrocmdlet-workflow/


I will be adding the possibility to execute 32-bit session commands in the next version of the workflow.


Best Regards,

Spas Kaloferov

0 Kudos