1
2
3
4
5
6
7
8
9
|
<#
Script Editor: Snail Yu
Date: 2014-11-29
#>
$IISsetting
=
Get-Content
"C:\windows\system32\inetsrv\config\applicationHost.config"
$BindingInformation
=(((
$IISsetting
-match
"bindinginformation"
) -split
"information="
)
-replace
'"'
,"")
-match
":
"
$BindingPort=(($BindingInformation -split "
:
") -match "
[0-9]$
") -notmatch "
\."
echo
$BindingPort
|sort
-unique
|
IIS的配置文档是"C:\windows\system32\inetsrv\config\applicationHost.config";
参数说明:
split: 以引号中的文本参数来分割整行文本,并返回分割后的结果文本;
match: 匹配包含文本所在的行,并显示匹配的行;
notmatch:匹配包含文本所在的行,并显示不匹配的行;
-replace 'var1',"var2" :用var2来替代文本中的var1,并返回替代后的文本;
sort: 排序;“-unique”返回唯一值,避免重复显示;
本文转自 bannerpei 51CTO博客,原文链接:http://blog.51cto.com/281816327/1584534,如需转载请自行联系原作者