VMware Cloud Community
tough_siberian_
Enthusiast
Enthusiast

Orchestrator and VMware View PowerCLI

Hello,

Can anybody help me with an issue?

I'm trying to get some information about VMware View environment by using View PowerCLI cmdlets in Orchestrator via PowerShell session (using official VMware Powershell plugin).

Command invocation works fine, but I have problems in processing results:

If I use getHostOutput() method on result object, I receive text representation of the information produced by corresponding command.

However, when I try to get Object representation of same info (using sample workflows as example and using powershell plugin guide) then it doesn't work. More specifically:

var cmdResult = viewConnectionServer.invokeScript("Add-PSSnapin VMware.View.Broker; Get-Pool");

var objList;

var strOutput = cmdResult.getHostOutput();  // This returns textual output - same as if executed from PowerCLI console.

var rootObject = cmdResult.getResults().getRootObject();

if (rootObject instanceof Array) objList = rootObject;

else objList = [rootObject];

var poolId = objList[0].getProperty('pool_id'); // This returns null !!!

So any property I try to get from any PSObject in the array just returns "null" value. The object itself is serialized properly - if I check getResults().getXml() then all properties are there. And if I try the same approach with "dir" command - the properties are extracted properly.

What am I doing wrong?

0 Kudos
6 Replies
igaydajiev
VMware Employee
VMware Employee

1. Can you provide the output of getResults().getXml()

2. Try enumerating the items with something like

for (idx in rootObject ){

     var item = rootObject [idx];
     System.log( item.getProperty('pool_id') );
}
0 Kudos
tough_siberian_
Enthusiast
Enthusiast

I have tried to access properties multiple ways (including the way proposed by you). All return "null" for any property.

I also compared XMLs got from View PowerCLI command invocation and from "dir" command invocation and noticed one difference in XML tree structure. With View cmdlet there's an additional Complex <Obj> element under <LST><Obj>. And this is not valid according to Powershell object serialization schema provided in MSDN documents: "Complex object can contain TypeName, ToString, Enum, Extended Primitive Object, known Container (List, Queue, Stack, Dictionaries), Adapted (<Prop>) or Extended (<MS>) properties". Complex Object is not mentioned as possible content of another Complex Object.

I don't know how exactly Orchestrator processes PSObject deserialization, but I suspect that this could be the reason for the failure.

0 Kudos
igaydajiev
VMware Employee
VMware Employee

Yes, Complex <Obj> element under <LST><Obj> looks wierd.


Could you try exporting the pool list directly from powershll console using ConvertTo-XML cmdlet and compare the results (http://technet.microsoft.com/en-us/library/ff730921.aspx)

Which version of powershell are you using ?

0 Kudos
tough_siberian_
Enthusiast
Enthusiast

Here is version information:

Windows Server R2 Enterprise SP1 64-bit

Powershell version: CLR - 2.0.50727.5466; Build - 6.1.7601.17514 (from $PSVersionTable) 64-bit

.NET Frameworks: 1.0.3705 (32-bit); 1.1.4322 (32-bit); 2.0.50727 (32/64 bit); 3.0 (32/64 bit); 3.5 (32/64 bit)

Vmware View version 5.1 (will check with 5.2 tomorrow)

PowershellServiceCmdlets.dll version: 5.1.2.16119 (DLL with VMware View PowerCLI cmdlets)

Here are samples from XML documents:

Get-Pool | Convert-ToXML:

<?xml version="1.0"?>
<Objects>
  <Object Type="vmware.view.powershell.cmdlets.Pool">
    <Property Name="pool" Type="System.String">0</Property>
    <Property Name="pool_id" Type="System.String">Manual</Property>
    <Property Name="description" Type="System.String" />
    <Property Name="displayName" Type="System.String">Manual</Property>
    <Property Name="enabled" Type="System.String">true</Property>

Get-Pool | Export-CliXML (comment is added by me):

<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">

<!-- Absent declaration of initial Obj/LST/ nodes -->
  <Obj RefId="0">
    <TN RefId="0">
      <T>vmware.view.powershell.cmdlets.Pool</T>
      <T>vmware.view.powershell.cmdlets.ViewObject</T>
      <T>System.Object</T>
    </TN>
    <ToString>vmware.view.powershell.cmdlets.Pool</ToString>
    <Obj RefId="1">
      <TNRef RefId="0" />
      <ToString>vmware.view.powershell.cmdlets.Pool</ToString>
      <MS>
        <S N="pool">0</S>
        <S N="pool_id">Manual</S>
        <S N="description"></S>
        <S N="displayName">Manual</S>
        <S N="enabled">true</S>

As you can see second sample is almost the same as XML document in file I sent you. It just misses declaration of ArrayList Object.

Hope this helps.

0 Kudos
igaydajiev
VMware Employee
VMware Employee

Thanks for the info.

Looks like the problem is not in powershell plugin.

Checked once more Power Shell Remoting Protocol specification and can not find there such a case.

What i can suggest is to use directly the xml output and extract the info from there.

0 Kudos
tough_siberian_
Enthusiast
Enthusiast

This is what I do for now.

I just was hoping that there is a way to get the content of that nested object as another PSObject and use its getProperty() method to read properties.

0 Kudos