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.