PowerShell2.0之Windows排错(六)检查网络故障
2011年01月21日
网络故障对于用户来说是很复杂的问题,因为它可能涉及很多方面的知识,不容易查找和解决。
为检查网络故障,创建名为“GetActiveNicAndConfig.ps1”的脚本,其代码如下:
param($computer = $env:computername, [switch]$full, [switch]$help)
function funline ($strIN)
{
$strLine= "=" * $strIn.length
Write-Host -ForegroundColor yellow $strIN
Write-Host -ForegroundColor darkYellow $strLine
}
function funHelp()
{
$helpText=@"
DESCRIPTION:
NAME: GetActiveNicAndConfig.ps1
Displays
PARAMETERS:
-computer the name of the computer
-full prints complete information
-help prints help file
SYNTAX:
GetActiveNicAndConfig.ps1 -computer WebServer
Displays network adapter info and network adapter configuration info on a computer
named WebServer
GetActiveNicAndConfig.ps1
Displays network adapter info and network adapter configuration info on the local machine
GetActiveNicAndConfig.ps1 -computer WebServer -full
Displays full network adapter info and full network adapter configuration info on a computer named WebServer
GetActiveNicAndConfig.ps1 -help ?
Displays the help topic for the script
"@
$helpText
exit
}
if($help){ "Obtaining help ..." ; funhelp }
New-Variable -Name c_netConnected -value 2 -option constant
$nic = Get-WmiObject -Class win32_networkadapter -computername $computer `
-filter "NetConnectionStatus = $c_netConnected"
$nicConfig = Get-WmiObject -Class win32_networkadapterconfiguration `
-filter "interfaceindex = $($nic.interfaceindex)"
if($full)
{
funline("Full Network adapter information for $($computer)")
format-list -InputObject $nic -property [a-z]*
funline("Full Network adapter configuration for $($computer)")
format-list -InputObject $nicConfig -property [a-z]*
}
ELSE
{
funline("Basic Network adapter information for $($computer)")
format-list -InputObject $nic
funline("Basic Network adapter configuration for $($computer)")
format-list -InputObject $nicConfig
}
该脚本中使用param语句定义了3个参数,即-computer、-full和-help,其中将-computer变量设置为系统环境变量中的计算机名称。
funline函数获得输入字符串的长度,并用这个长度来生成分隔线。结果保存在$strLine变量中,然后输出带下画线的字符串。
随后的代码“New-Variable
发表评论
-
http://www.cnblogs.com/yungboy/archive/2010/05/28/1746376.html
2012-01-20 09:36 996http://www.cnblogs.com/yungboy/ ... -
MyEclipse 8.6.1 Android开发环境配置
2012-01-20 09:36 1019MyEclipse 8.6.1 Android开发 ... -
再一次在Eclipse下配置Android
2012-01-20 09:36 625再一次在Eclipse下配置And ... -
visual studio 2010 之二 修改WindowsSdkDir宏
2012-01-20 09:35 876visual studio 2010 之二 修改Windows ... -
MyEclipse无法自动编译解决方案
2012-01-19 14:39 789MyEclipse无法自动编译解 ... -
用MyEclipse建立Web Service工程(下)
2012-01-19 14:38 627用MyEclipse建立Web Service工程(下) 2 ... -
如何向MyEclipse导入已有项目
2012-01-19 14:38 1140如何向MyEclipse导入已有项目 2011年06月18日 ... -
OpenGL的安装
2012-01-19 14:38 624OpenGL的安装 2010年06月20 ... -
(转)关于OpenGL的安装
2012-01-19 14:38 560(转)关于OpenGL的安装 201 ... -
JavaScript中两种类型的全局对象/函数
2012-01-17 04:25 543JavaScript中两种类型的全 ... -
JAVASCRIPT 技巧
2012-01-17 04:25 612JAVASCRIPT 技巧 2011年05月 ... -
[转载]JQUERY刷新页面
2012-01-17 04:25 698[转载]JQUERY刷新页面 201 ... -
python的异常
2012-01-17 04:25 744python的异常 2011年07月04日 Python ... -
100多个很有用的JavaScript函数以及基础写法汇总
2012-01-17 04:25 516100多个很有用的JavaScript函数以及基础写法汇总 ... -
赞美词语鼓励词句
2012-01-16 03:14 2608赞美词语鼓励词句 2009年10月02日 赞美容貌的词语 ... -
赞美女性的词语大全
2012-01-16 03:14 586赞美女性的词语大全 2010年07月18日 温柔、体贴 ... -
赞美女性的词语
2012-01-16 03:14 829赞美女性的词语 2010年05月21日 温 ... -
赞美女性的词语大全
2012-01-16 03:14 616赞美女性的词语大全 2009年09月22日 赞美女性的词 ...
相关推荐
Windows Management Framework Release Candidate Windows PowerShell 2.0 and WinRM 2.0 Localized Package with Release Notes For x86 versions of Windows XP SP3.
Windows Server 2003的32位PowerShell2.0下载
微软发布了Windows PowerShell.PowerShell.是微软的下一代命令解释器的Shell程序,能够让管理员自动化和控制Windows桌面及服务器。PowerShell原来的开发代号是Monad,原计划是用以替代Windows中的命令行工具,但是后来...
Windows Powershell 2.0,编程资源
WindowsXP-KB968930-x86-CHS(Windows PowerShell 2.0).rar
微软出的《Windows PowerShell 2.0 图形帮助文件》
Windows PowerShell 2.0 开发之命令别名 (1) Windows PowerShell 2.0语言的内置类型系统 Windows PowerShell 2.0语言之字面类型系统 Windows PowerShell 2.0语言之分支语句讲解 Windows PowerShell 2.0命令别名技巧...
Windows Server 2008 r2 中 将PowerShell2.0 升级到 PowerShell3.0,希望能帮助到你。
Windows PowerShell 2.0
Microsoft Windows PowerShell 是一种新的命令行外壳和脚本语言,用于进行系统治理和自动化。Windows PowerShell 建立在 .NET Framework 的基础上,IT 专业人员可通过命令或脚本来治理计算机,从而通过系统自动化来...
windows powershell 2.0 安装包
xp 下 powershell2.0 被微软支持的最后一个版本,完整版,带winrm 不需要单独安装。powershell可以进行远程命令行配置服务和计划,配合脚本完成复杂操作
书名wilson e. - windows powershell 2.0. best practices - 2010就表明一切! 适合高级读者!!!
powershell 2.0 CTP,安装时机器中不能能安装早期的1.0版本,安装时需要WS management.
之所以造成一些混淆是因为微软不再单独提供PowerShell 2.0,而是将其整合到了Windows管理架构(Management Framework)中。 微软工程师Jeffrey Snover表示:“这一混淆是我们造成的,因为它的重新发布不再称为...
Chapter 1: PowerShell Scripting Methods and Creating Custom Commands 7 Introduction 7 Setting up your Virtual Machine and running a test script 8 Authoring, debugging, and executing script accessing ...
安装EFCodeFirst之前必先安装的服务
Microsoft.Press.Windows.PowerShell.2.0.Administrators.Pocket.Consultant.May.2009.rar
Windows 2003 安装Powershell 2.0 Windows 2003 安装Powershell 2.0需要在系统安装SP2才可正确安装. Powershell 2.0 和Powershell 1.0版本不存在冲突,因此,安装1.0的同学不用特意卸载之后再安装. Powershell ...
powershell4.0完整升级包(windows powershell升级补丁系统4.0版本) windows08R2 powershell升级到4.0的完整升级包,包含所有需要的依赖包。 注意:只适用于08R2系统; 另外:powershell4.0功能强大 可以批量添加AD域...