Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Export resulting in System.Object[]

$
0
0

Hi guys, I have the below script which exports the endpoints on all my VMs in Azure. If the VM only has 1 endpoint then it works fine, if however it has 2 or more, the export shows System.Object[]. How can I expand this? I've read that I need to use the -join command but not really sure how to go about it.

foreach ($VMServiceName in $VMlist) {

     $obj = Get-AzureVM -ServiceName $VMServiceName.ServiceName -Name $VMServiceName.Name | Get-AzureEndpoint 

     $Output = New-Object PSObject 

    $Output | Add-Member VMName $VMServiceName.Name    

    $Output | Add-Member EndpointNames $obj.Name   

    $Output | Add-Member Endpoints $obj.LocalPort

$Output | Add-Member EndpointsName $obj.Acl.Rules.description

$Output | Add-Member EndpointsSubnet $obj.Acl.Rules.remotesubnet

  Write-Output $Output

    $Output | Export-Csv "c:\Temp\endpoints.csv" -append -NoTypeInformation

    }


Viewing all articles
Browse latest Browse all 6937

Trending Articles