Hi to all
here is my project. Query a server and retrieve network information
- IP Address
- Submask
- Gateway
- DNS
-DNS Domain Suffixes
then put them into a html format list
hre is my code
$date = get-date -Format g
$htmlfilepath = "C:\Scripts\report.html"
$csspath = "C:\Scripts\style.css"
$servername = 'servername.com' #Read-host "Enter Server DNS Name l"
$cred = Get-Credential -Message "Enter your Domain Credentials" -UserName "your credentials"
#Network Information
$nwINFO = Get-WmiObject -Class win32_NetworkAdapterConfiguration -ComputerName $servername -Credential $cred |
Where-Object { $_.IPAddress -ne $null } |
fl DNSDomainSuffixSearchOrder,DNSServerSearchOrder,IPAddress,DefaultIPGateway,IPSubnet, MACAddress
$nwinfo2 = @{ 'IPAddress' = $nwINFO.IPAddress};
@{ 'Gateway' = $nwINFO.DefaultIPGateway};
@{ 'MacAddress' = $nwINFO.MACAddress};
@{ 'IPAddress' = $nwINFO.IPAddress};
$obj = New-Object -TypeName psobject -Property $nwinfo2
$obj |ConvertTo-Html -as List |Out-File "c:\temp\test.html"
on the screen i get this
IPAddress : {10.222.62.145}
DefaultIPGateway : {10.222.62.129}
IPSubnet : {255.255.255.192}
MACAddress : 00:50:56:81:52:00
but on the HTML I get
*: | System.String[] |
can anyone help me to get it right?
and explain what's going on