'Powershell hashtables values output Assembly not Value

Hi I'm trying to get vnet peering property using a Powershell script.

But I keep getting these values in teh table below, but when I print to screen they print fine.

These are values I keep getting: RemoteVirtualNetwork Microsoft.Azure.Commands.Network.Models.PSResourceId

RemoteVirtualNetworkAddressSpace Microsoft.Azure.Commands.Network.Models.PSAddressSpace

Error

#Login-AzAccount
$Subs = Get-AzSubscription

foreach ( $Sub in $Subs ) {
    Set-AzContext -Subscription $Sub | Out-Null
    $SubName = $sub.name

      $vnets=get-azvirtualnetwork

      foreach ($azvnet in $vnets){
           $peer=get-AzVirtualNetworkPeering -VirtualNetworkName $azvnet.name -ResourceGroup $azvnet.ResourceGroupName | select-object ResourceGroupName,VirtualNetworkName,PeeringState,AllowVirtualNetworkAccess,AllowGatewayTransit,UseRemoteGateways,RemoteVirtualNetwork,RemoteVirtualNetworkAddressSpace
           
    

           ForEach-Object{

           New-Object PSObject -Property @{
           
                 ResourceGroupName = $peer.ResourceGroupName
                 VirtualNetworkName= $peer.VirtualNetworkName
                 PeeringState = $peer.PeeringState
                 PeeringSyncLevel = $peer.PeeringSyncLevel
                 AllowVirtualNetworkAccess = $peer.AllowVirtualNetworkAccess
                 AllowForwardedTraffic = $peer.AllowForwardedTraffic
                 AllowGatewayTransit = $peer.AllowGatewayTransit
                 UseRemoteGateways = $peer.UseRemoteGateways
                 RemoteVirtualNetwork = $peer.RemoteVirtualNetwork.Id.Split("/")[-1]  
                 RemoteGateways = $peer.RemoteGateways
                 PeeredRemoteAddressSpace = $peer.PeeredRemoteAddressSpace
                 RemoteVirtualNetworkAddressSpace = $peer.RemoteVirtualNetworkAddressSpace | Select-Object -ExpandProperty AddressPrefixes 

               }
           }

           $peer|export-csv -path c:\personal\peers04.csv 
      }

}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source