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
}