$list = get-content "C:\Remote\ip.txt"
foreach ($ip in $list)
{
$result = New-Object psObject
Write-Host "Trying $($ip)" -ForegroundColor White
Try {
$IPComputer = Test-Connection $ip -Count 1 -ErrorAction Stop | Select -ExpandProperty ipv4Address | `
Select -ExpandProperty ipAddressToString
$Sucess = Write-Host "Success" -ForegroundColor Green
Add-Content $IndexPage "<tr><td>$IP</td><td>$Sucess</td><td>$Failed</td><tr></table>"
}
catch
{
$Failed = Write-Host "Down" -ForegroundColor Red
}
}
$Date = Get-Date -Format "dddd dd MMMM yyyy"
$Time = Get-Date -Format "hh:mm:ss"
$IndexPage = "C:\Remote\Index.html" # This Creates The Index Page
New-Item -ItemType file $IndexPage -Force # Creates The Page
Add-Content $IndexPage "<table width='auto' align='center' border-collapse='collapse'>"
Add-Content $IndexPage "<tr bgcolor='#D0E6FF'>"
Add-Content $IndexPage "<td colspan='4' height='25' align='center'>"
Add-Content $IndexPage "<font face='tahoma' color='#000000' size='2'><b>Router Checker</b></font><BR>"
Add-Content $IndexPage "<font face='Arial' color='#000000' size='2'><b>Date: $Date</b><BR>"
Add-Content $IndexPage "<font face='Arial' color='#00000' size='2'><b>Time: $Time</b>"
Add-Content $IndexPage "</td>"
Add-Content $IndexPage "</tr>"
Add-Content $IndexPage "</table>"
Add-Content $IndexPage '<table id="main" class="sortable" <width="auto" align="center">'
Add-Content $IndexPage "<tr bgcolor='#D0E6FF'>"
#Add-Content $IndexPage "<td width='auto' align='center'>Client</td>"
Add-Content $IndexPage "<td width='auto' align='center'>IP Address</td>"
Add-Content $IndexPage "<td width='auto' align='center'>Up</td>"
Add-Content $IndexPage "<td width='auto' align='center'>Down</td>"
Add-Content $IndexPage "</tr>"
Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.
TRUSTED BY
ASKER