# Network Information

**URL:** <https://forums.powershell.org/t/network-information/4748>\
**Category:** PowerShell Help\
**Created:** [August 24, 2015, 9:25am UTC](https://forums.powershell.org/t/network-information/4748 "2015-08-24T09:25:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![helder-guzman](https://avatars.discourse-cdn.com/v4/letter/h/d9b06d/32.png) [@helder-guzman](https://forums.powershell.org/u/helder-guzman)\
**Post date:** [August 24, 2015, 9:25am UTC](https://forums.powershell.org/t/network-information/4748/1 "2015-08-24T09:25:34Z")

</div>

Creating an HTML Report for combining two win32 classes.

info needed:

IP, Subnet Mask, Gateway, DNS Servers, Wins Server, sufixes, Connection, Speed, is IPV6 Enable.

This is what i got

$servername = “Wfcp5871i.wf.local” #Read-host “`nServer DNS Name ie. wfcp5777i.wf.local”  
$cred = Get-Credential -Message “User Info for Domain Server is in” -UserName “wf\u413628-a”

$network = Get-WmiObject Win32\_NetworkAdapter -ComputerName $servername -Credential $cred

$NetworkAdapter = Get-WmiObject Win32\_NetworkAdapterConfiguration -ComputerName $servername -Credential $cred -Filter "IpEnabled = ‘True’ " |  
Where-Object IPAddress -ne $null

foreach($adapter in $NetworkAdapter){

```
$props = [ordered]@{ 'IP Address' = [string]$adapter.IPAddress;
            'Subnet' = [string]$adapter.IPSubnet;
            'Gateway' = [string]$adapter.IPSubnet;
            'DNS Servers' = [string]$adapter.DNSServerSearchOrder ;
            'WINS Servers' = [string]$adapter.WINSPrimaryServer + "," + [string]$adapter.WINSsecondaryServer;
            'DNS Suffixes' = [string]$adapter.DNSDomainSuffixSearchOrder ;
            'Network Connection' = $network.NetConnectionID  
        
            }

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

write-output $obj 

```

}

$obj |ConvertTo-Html -Fragment -as List |Out-File C:\Scripts\dns.html

how can i add win32\_networkadapter part. Inside the foreach loop? or outside.

should I start from networkadapter first and then find the ipadress.

combine this two classes into an object.

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [August 24, 2015, 9:57am UTC](https://forums.powershell.org/t/network-information/4748/2 "2015-08-24T09:57:46Z")

</div>

First, the object has to be created and output inside the ForEach loop. Otherwise you’ll only get the most recent network adapter.

_Anything_ you want on the object is going to have to be added inside the ForEach loop, before the object is output.

And that’s one script (or function). You’d then run that script (or function), and pipe its output to ConvertTo-HTML. Piping $obj to ConvertTo-HTML is only giving you the last object created, regardless of what you output to the pipeline.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:44pm UTC](https://forums.powershell.org/t/network-information/4748/3 "2024-05-16T20:44:52Z")

</div>

Closed on May 16, 2024, 8:44pm UTC


