VMware Cloud Community
platforminc
Enthusiast
Enthusiast

Powershell output has extra objects on VRO

Hi All,

I have a simple Ps script which just returns a name in the form of an object. what i am hoever finind is that extra objects are being returned by the Ps script when it gets to vro.

My PS script looks like this.

Param

(

[Parameter(Mandatory=$true)] [string] $ServerName

)

[CmdletBinding]

$myobject = New-Object -TypeName psobject

$myobject  | Add-Member -MemberType NoteProperty -Name FName -Value "Tom"

$myobject  | Add-Member -MemberType NoteProperty -Name Rank -Value "1"

$myobject

 

However on VRO, when I process the output which is of type PowershellRemotePSObject.

var x  = output.getRootObject();

var whatsmyname

for (idx in x) {

//each item is complex objec  having two properties (name,age)

//it is mapped to PowerShellPSObject

var obj = x[idx]

System.log("Name : " + obj.getProperty('FName') + " Rank : " + obj.getProperty('Rank'));

whatsmyname = obj.getProperty('FName');

}

I seem to be getting 2 rows, one is completely null and the other has the results from my script.

Is there a way to eliminate the null values, I also noticed tht my PS script brings back the following when executed from vro.

IsPublic IsSerial Name                                     BaseType                                                   

-------- -------- ----                                     --------                                                   

True     False    CmdletBindingAttribute                   System.Management.Automation.CmdletCommonMetadataAttribute 

FName : Tom

Rank  : 1

I suspect that this is the extra row being converted to null, is there a way to exclude them and only return the legitimate values ?

Param ([Parameter(Mandatory=$true)] [string] $ServerName

)[CmdletBinding]

$myobject = New-Object -TypeName psobject

$myobject  | Add-Member -MemberType NoteProperty -Name FName -Value "Tom"$myobject  | Add-Member -MemberType NoteProperty -Name Rank -Value "1"

$myobject

0 Kudos
0 Replies