user3281582
user3281582

Reputation: 21

Unable to Create a table of Array of Objects in Powershell

I need help with the following. I am trying to list the Adapter Name and NetbiosOption value in a table format. Any help will be appreciated.

  $nac = gwmi win32_networkadapterconfiguration -filter 'ipenabled="true"' 
  $na = $nac | %{$_.GetRelated('win32_networkadapter')}
  $prop = @{'Name' = $na.NetConnectionID;
        'NetBios' = $nac.TcpipNetbiosOptions
         }
  $obj = New-Object -TypeName PSObject -Property $prop
  $obj

I am getting the result like this and not in table format

Name                                                                                       NetBios                                                                                   
----                                                                                       -------                                                                                   
{Wireless Network Connection, VirtualBox Host-Only Network}                                {0, 0}  

Upvotes: 0

Views: 41

Answers (1)

Dave Sexton
Dave Sexton

Reputation: 11188

Try this:

$nac = gwmi win32_networkadapterconfiguration -filter 'ipenabled="true"' 
$nac | %{
  New-Object PSObject -Property @{
   Name = $_.GetRelated('win32_networkadapter')
   NetBios = $_.TcpipNetbiosOptions
  }
}

Upvotes: 1

Related Questions