2017-11-30 3 views
0

コマンドレットTest-NetConnectionがServer 2012にインストールされていないことに気づきました。Server 2012にはPowerShellバージョン3が付属しているので、最新のバージョン5.1に更新することができます。PowerShellコマンドレットTest-NetConnectionを利用できません

私は更新を行いましたが、コマンドレットTest-NetConnectionはまだ利用できません。

Test-Connectionのみが存在しますが、ポートをテストするにはTest-NetConnectionが必要です。

Test-NetConnectionを今すぐ入手するにはどうすればよいですか?

 
PS C:\Windows\system32> $PSVersionTable 

Name       Value 
----       ----- 
PSVersion      5.1.14409.1005 
PSEdition      Desktop 
PSCompatibleVersions   {1.0, 2.0, 3.0, 4.0...} 
BuildVersion     10.0.14409.1005 
CLRVersion      4.0.30319.34209 
WSManStackVersion    3.0 
PSRemotingProtocolVersion  2.3 
SerializationVersion   1.1.0.1 


PS C:\Windows\system32> Get-Command Test-NetConnection 
Get-Command : The term 'Test-NetConnection' is not recognized as the name of a cmdlet, 
function, script file, or operable program. Check the spelling of the name, or if a path 
was included, verify that the path is correct and try again. 
At line:1 char:1 
+ Get-Command Test-NetConnection 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : ObjectNotFound: (Test-NetConnection:String) [Get-Command], CommandNotFoundException 
    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand 

答えて

1

多くのコマンドレットが使用できるかどうかは、PowerShellのバージョンではなく、Windowsのバージョンに依存します。あなたの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() 
    } 
} 
+0

あまりにも悪いです。私は今のところそれに固執する必要があります。このコマンドレットは、特別なインストールが不要なため、非常に便利です。私は非常に感謝yor機能、魅力のように動作します!ありがとうございました! –

関連する問題