Network Information with IP Adddress

Hi I need your help

Creating a report where I need the information of each network adapter that is enabled and within this network the IP information of that adapter.

here what I have so far

$ComputerName = “wfcp5606i.wf.local”
$cred = Get-Credential -Message “User Info for Domain Server is in” -UserName “wf\u413628-a”

$data = Get-WmiObject -Computer $ComputerName Win32_Networkadapter -Credential $cred -Filter “NetEnabled=True”
$data | select *

$adapter = 0

foreach($network in $data){

$adapter += 1

$obj = New-Object -TypeName psobject

$props = [ordered]@{ Adapter = $adapter
                    Manufacturer = $network.Manufacturer
                   AdapterDescription = $network.Description
                   Connection = $network.NetConnectionID
                   'Speed GB' = $network.Speed/1000/1000/1000 }

$obj = New-Object -TypeName psobject -Property $props  

$ipdata = Get-WmiObject win32_networkadapterconfiguration  -ComputerName $ComputerName -Credential $cred -Filter "IPEnabled=True"

foreach ($IPinfo in $ipdata){
    Add-Member -InputObject $obj -MemberType NoteProperty -Name 'IPAddress' -Value $IPinfo.IPAddress
    Add-Member -InputObject $obj -MemberType NoteProperty -Name 'Submask' -Value $IPinfo.IPSubnet
    Add-Member -InputObject $obj -MemberType NoteProperty -Name 'Gateway' -Value $IPinfo.DefaultIPGateway
    Add-Member -InputObject $obj -MemberType NoteProperty -Name 'DNSServers' -Value $IPinfo.DnsServerSearchOrder
    Add-Member -InputObject $obj -MemberType NoteProperty -Name 'WinServers' -Value $IPinfo.WinsPrimaryServer 
    Add-Member -InputObject $obj -MemberType NoteProperty -Name 'DaomainSuffixes' -Value $IPinfo.DNSDomainSuffixSearchOrder  

}     

}

Write-Output $obj

$adapter

$obj |ConvertTo-Html -as list |out-file C:\Scripts\nic.html

ii “C:\Scripts\nic.html”

As you can see, I started with for each adapter pull information and add it to a new object. then Pull the IP information for that adapter.

here is the output

TypeName: System.Management.Automation.PSCustomObject

Name MemberType Definition


Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Adapter NoteProperty System.Int32 Adapter=1
AdapterDescription NoteProperty System.String AdapterDescription=vmxnet3 Ethernet Adapter
Connection NoteProperty System.String Connection=Local Area Connection 6
DaomainSuffixes NoteProperty System.String DaomainSuffixes=System.String
DNSServers NoteProperty System.String DNSServers=System.String
Gateway NoteProperty System.String Gateway=System.String
IPAddress NoteProperty System.String IPAddress=System.String
Manufacturer NoteProperty System.String Manufacturer=VMware, Inc.
Speed GB NoteProperty System.UInt64 Speed GB=10
Submask NoteProperty System.String Submask=System.String
WinServers NoteProperty System.String WinServers=10.1.30.130

Adapter : 1
Manufacturer : VMware, Inc.
AdapterDescription : vmxnet3 Ethernet Adapter
Connection : Local Area Connection 6
Speed GB : 10
IPAddress : {10.222.161.175}
Submask : {255.255.255.0}
Gateway : {10.222.160.1, 10.222.161.1}
DNSServers : {10.222.160.26, 10.224.160.157}
WinServers : 10.1.30.130
DaomainSuffixes : {wf.local, wfroot.local, westcorp.com}

But I need to expand the properties of the ip setting.

can anyone help

thanks

Can you explain more about what you mean about expanding the properties of the IP settings? Looking at what you have put as your output I see what I would think is the properties of the IP settings like the IP address and Gateway, etc. Need a little more understanding of what you are trying to accomplish.

Yes, I need to expand the properties of the IP Setting.

specially, for extra ip address for Dns, Wins.

How can I expand all the setting at one time. Instead of expanding 1 by 1.

like

| select -expandproperty DNSServers, Wins, DNSSearchorder

how do i used the add-member in this situation.

this way for example

Add-Member -InputObject $obj -MemberType NoteProperty -Name ‘IPAddress’ -Value ($IPinfo.IPAddress -join ‘,’)

Thanks Max That work Like a charm