$Infors = Get-Content ports01.txt
$Temp_PortStatustxt = "C:\Windows\Temp\PortStatustxt.txt"
$Temp_PortStatushtm = "C:\Windows\Temp\PortStatushtm.htm"

$Domainname = $Infors[0].Split(",")[0]
$IP = [System.Net.Dns]::GetHostAddresses($Domainname)[0]
Start-Sleep -Milliseconds 500
$Address = [System.Net.IPAddress]::Parse($IP)
$IPstring = $Address.IPAddressToString

Function Port-Test ($Address,$Port)
{
$Timeout = 1000
$Socket = New-Object System.Net.Sockets.TCPClient
$Connect = $Socket.BeginConnect($Address,$Port,$null,$null)
Start-Sleep -Milliseconds 500
If ( $Connect.IsCompleted )
{
$Wait = $Connect.AsyncWaitHandle.WaitOne($TimeOut,$false)
If(!$Wait)
{
$Socket.Close()
Return $false
}
Else{
$Socket.EndConnect($Connect)
$Socket.Close()
Return $true
}
}
Else{Return $false}

}

$Server = $Domainname + " : " + $IPstring
"Port,Status"|Out-File $Temp_PortStatustxt -Append
Foreach ($infor in $Infors)
{
$port = $Infor.Split(",")[1]
$Status= Port-Test $Address $port
$port + "," + $Status |Out-File $Temp_PortStatustxt -Append
}
$csv = Import-Csv $Temp_PortStatustxt
$csv|Select Port,Status | ConvertTo-Html `
-head '<style type="text/css"> body,table,td,th {font-family:Tahoma; color:Black; Font-Size:20pt} body {text-align:center} </style>' `
-Title "Port Monitor" `
-Body "<H4>$server</H4>" | `
ForEach{$_ -replace "<table>","<table align=center>"} |`
ForEach{$_ -replace "<tr>","<tr bgcolor=cyan>"} | `
Foreach{
If($_ -like "*<td>false</td>*")
{$_ -replace "<tr bgcolor=cyan>","<tr bgcolor=red>"}
Elseif($_ -like "*<td>true</td>*")
{$_ -replace "<tr bgcolor=cyan>","<tr bgcolor=green>"}
Else{$_}
} >>$Temp_PortStatushtm

Remove-Item $Temp_PortStatustxt

Invoke-Item $Temp_PortStatushtm

HTML输出 二 控制行背景颜色的更多相关文章

  1. HTML输出 一 控制列背景颜色

    #将需要读取的域名和端口列表保存在名为ports01.txt.ports02的文件中,文件与脚本位于相同目录下$CurrentPath = $MyInvocation.MyCommand.Path.s ...

  2. C# GridControl 行背景颜色

    使用C# DevExpress_gridControl 行号行样式显示行背景颜色,必须取消自动变换行色属性 取消Focus变色,属性为OptionSelection--EnableAppearance ...

  3. Android特效专辑(二)——ViewPager渲染背景颜色渐变(引导页)

    Android特效专辑(二)--ViewPager渲染背景颜色渐变(引导页) 首页:http://blog.csdn.net/qq_26787115/article/details/50439020 ...

  4. 雷林鹏分享:jQuery EasyUI 数据网格 - 条件设置行背景颜色

    jQuery EasyUI 数据网格 - 条件设置行背景颜色 本教程将向您展示如何根据一些条件改变数据网格(datagrid)组件的行样式.当 listprice 值大于 50 时,我们将为该行设置不 ...

  5. [ASP.NET] [JS] GridView点击高亮当前选择行,并在点击另一行时恢复上一选择行背景颜色

    在ASP.NET中的gridview控件里面可以通过设定其OnRowDataBound事件来进行实现高亮当前行的操作 前端控件的设置: 只要设置好OnRowDataBound属性即可,会自动在.cs文 ...

  6. Silverlight DataGrid数据行背景颜色控制

    sdk:DataGrid数据绑定后,部分特殊的行需要用不同的背景颜色来显示.(注册DataGrid的LoadingRow事件) private void radGridView_LoadingRow( ...

  7. EasyUI 条件设置行背景颜色

    数据网格(datagrid)的 rowStyler 函数的设计目的是允许您自定义行样式. rowStyler 函数需要两个参数: rowIndex:行的索引,从 0 开始. rowData:该行相应的 ...

  8. jQuery EasyUI 数据网格 - 条件设置行背景颜色

    $('#tt').datagrid({ rowStyler:function(index,row){ if (row.listprice>50){ return 'color:blue;font ...

  9. ext js 4.0 grid表格根据列值的不同给行设置不同的背景颜色

    Code: Ext.create('Ext.grid.Panel', { ... viewConfig: { getRowClass: function(record) { return record ...

随机推荐

  1. ssl选购

    上机实践,参考了: http://www.lovelucy.info/nginx-ssl-certificate-https-website.html http://nginx.org/cn/docs ...

  2. Java [Leetcode 155]Min Stack

    题目描述: Design a stack that supports push, pop, top, and retrieving the minimum element in constant ti ...

  3. LeetCode: divideInteger

    Title: Divide two integers without using multiplication, division and mod operator. If it is overflo ...

  4. vc/mfc获取rgb图像数据后动态显示及保存图片的方法

    vc/mfc获取rgb图像数据后动态显示及保存图片的方法 该情况可用于视频通信中获取的位图数据回放显示或显示摄像头捕获的本地图像 第一种方法 #include<vfw.h> 加载 vfw3 ...

  5. 深入学习Oracle分区表及分区索引

    关于分区表和分区索引(About Partitioned Tables and Indexes)对于10gR2而言,基本上可以分成几类: •       Range(范围)分区 •       Has ...

  6. order by调优的一些测试

    表结构信息:mysql> show create table tb\G*************************** 1. row *************************** ...

  7. linux-LINUX试题

    ylbtech-doc:linux-LINUX试题 LINUX试题 1.A,LINUX试题返回顶部 01.{Linux题目}在使用匿名登录ftp时,用户名为(  )? (选择1项) A) login ...

  8. Java动态代理机制详解(JDK 和CGLIB,Javassist,ASM)

    class文件简介及加载 Java编译器编译好Java文件之后,产生.class 文件在磁盘中.这种class文件是二进制文件,内容是只有JVM虚拟机能够识别的机器码.JVM虚拟机读取字节码文件,取出 ...

  9. How to Calculate difference between two dates in C# z

    Do you need to find the difference in number of days, hours or even minute between the two date rang ...

  10. 学习笔记 - 深究Bitmap压缩避免OOM的核心inSampleSize的最佳取值

    /** * 测试代码,通过在SDCard根目录放置几种不同大小的图片, 来自动测试压缩方式是否有效同时看是否会内存不够. * * @since * By:AsionTang * At:2014年3月2 ...