Pau*_*ith 10 powershell windows-server-2012
我注意到 cmdletTest-NetConnection未安装在 Server 2012 上。由于 Server 2012 附带 PowerShell 版本 3,因此我认为更新到最新版本 5.1 可能会有所帮助。
我进行了更新,但 cmdletTest-NetConnection仍然不可用。
OnlyTest-Connection存在,但我需要Test-NetConnection测试端口。
我Test-NetConnection现在怎样才能得到?
PS C:\Windows\system32> $PSVersionTable
名称值
---- -----
PS版本 5.1.14409.1005
PS版桌面
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
构建版本 10.0.14409.1005
CLR 版本 4.0.30319.34209
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
序列化版本 1.1.0.1
PS C:\Windows\system32> Get-Command Test-NetConnection
Get-Command :术语“Test-NetConnection”未被识别为 cmdlet 的名称,
函数、脚本文件或可运行的程序。检查名称的拼写,或者是否有路径
包含在内,请验证路径是否正确,然后重试。
在行:1 字符:1
+ 获取命令测试网络连接
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Test-NetConnection:String) [Get-Command], CommandNotFoundException
+ FullQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
许多 cmdlet 的可用性与 Windows 版本相关,而不是 PowerShell 版本。如果你不能升级你的 Windows 版本,你就不能拥有Test-NetConnection.
您可以使用命令行端口扫描器(如nmap或scanline)进行端口测试,或者您可以自己连接到端口:
function Test-Port($server, $port) {
$client = New-Object Net.Sockets.TcpClient
try {
$client.Connect($server, $port)
$true
} catch {
$false
} finally {
$client.Dispose()
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
27419 次 |
| 最近记录: |