You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Test-NetConnection cmdlet is missing from PowerShell Core 6.0.1 release #6932
Test-Connection was added in 5328 but it appears that Test-NetConnection is still missing.
Steps to reproduce
Get-CommandTest-NetConnection
Expected behavior
CommandType Name Version Source
----------- ---- ------- ------
Function Test-NetConnection 1.0.0.0 NetTCPIP
Actual behavior
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
Environment data
>$PSVersionTable
Name Value
---------
PSVersion 6.1.0-preview.2
PSEdition Core
GitCommitId v6.1.0-preview.2
OS Microsoft Windows 10.0.14393
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
I'm a little unclear, does that mean that Powershell 6 will not have Test-NetConnection? I would expect the ability to check a specific port on a system would be of even more interest to unix admins.
My assumption was that, like Test-Connection, Test-NetConnection had also been overlooked. If that was an incorrect assumption, then perhaps this should be re-labeled as a feature request. Otherwise, I believe this is a bug.
However, when I try running Test-Connection with the -TCPPort flag, it does seem to function. So I believe this is mostly a problem with that enhancement being undocumented in the latest current release (6.1.0-preview.2)
In my eyes this is breaking all compatibility with no understand from my side, why not implement Test-NetConnection...
It would be really wise to implement it .
This is again one of the commands where I have if/else for what it is running on. and worse enough, it has to be a check for 5.1/7.x, Windows/Linux (5.1 does not support -TCPPort, Linux does not support Test-NetConnection)
is this the type of Multi-Plattform-Support Microsoft is aiming at?
Please reconsider this, as it really breaks scripts that do network checks and should run on multiple plattforms or be easy to port.
See above; you should be able to use Test-Connection for most of the use cases that Test-NetConnection covered in earlier versions. If you have a specific use case that the current implementation doesn't cover, I suggest you open a feature / improvement request for that cmdlet instead. 🙂
Rain Sallow (/u/ta11ow) (@vexx32) But as said above. This breaks scripts to be compatible on multiple plattforms. And that because of a really bad reason, in my eyes, as Test-NetConnection could be easily built as the functionality is present in parts in test-connection.
I have to disagree, since I wrote quite a lot of the current implementation of Test-Connection. Many of the features Test-NetConnection had are simply not available in .NET itself currently. Even the things that are there largely only work on Windows, from what I've been able to determine.
It's probably possible with a third-party library, but I'm not familiar enough in that area to know what would be useful to look at, nor would I expect the maintainers to want to pull it in as a permanent dependency.
Test-NetConnection is simply not cross-platform compatible; some of the things it does on WIndows simply don't have direct analogues on other platforms, as far as I am able to tell. Test-Connection is, to the best of our current ability, the closest we have and is available even back in WinPS 5.1 (with some minor differences from the current implementation; it too had to be rewritten completely, in the end).
If you'd like to expand what it can do, feel free; I have no doubt that useful functionality would likely be welcomed as a PR. 🙂
But exactly thats the current problem. Test-Connection does not support eg. TCPPort in 5.1
So there is no way currently to write code that can be used on 5.1 + 7.x on multiple plattforms, other then doing stuff like.
if ($IsLinux) ..... etc. In my script I am doing this:
if ($IsLinux) {
if (-Not (Test-Connection -TargetName $url -TcpPort $port)) {
Write-Host "Warning! Synology cannot be reached!!!" -ForegroundColor Red
}
}
else {
if (-Not (Test-NetConnection -ComputerName $url -Port $port)) {
Write-Host "Warning! Synology cannot be reached!!!" -ForegroundColor Red
}
}
I mean, if you ensure you're using the same version of PowerShell on both, you can skip the check. Beyond that, I don't know what you can really expect, they're two different software packages.
I know this discussion has been closed, but I wanted to provide an important takeaway.
I am using mac and installed powershell for it. brew install --cask powershell
I access it using pwsh command.
First i logged in with Az login , and it was successful.
But i faced an issue with Get-AzStorageAccount command. Get-AzStorageAccount: The term 'Get-AzStorageAccount' is not recognized as a name of a cmdlet, function, script file, or executable program.
So installed Az module Install-Module Az
But still there was an issue with port connectivity check
PS /Users/whosecode> Test-NetConnection -ComputerName ([System.Uri]::new($storageAccount.Context.FileEndPoint).Host) -Port 445
Test-NetConnection: The term 'Test-NetConnection' is not recognized as a name of a cmdlet, function, script file, or executable program.
So I came across a note about Test-Connection instead of Test-NetConnection , and it seems returning right result.
Activity
iSazonov commentedon May 24, 2018
We added
Test-Connection- this is new ported cmdlet.Test-NetConnection- this is Windows PowerShell cmdlet from nettcpip module.cassie-nahar commentedon May 24, 2018
I'm a little unclear, does that mean that Powershell 6 will not have Test-NetConnection? I would expect the ability to check a specific port on a system would be of even more interest to unix admins.
My assumption was that, like Test-Connection, Test-NetConnection had also been overlooked. If that was an incorrect assumption, then perhaps this should be re-labeled as a feature request. Otherwise, I believe this is a bug.
iSazonov commentedon May 25, 2018
@kevinlrak Current
Test-Connectionported implementation was enhanced. Please seehelp Test-Connection.You can to check a specific port too.
.Net Core has still bugs in APIs and not all in Test-Connection works on Unix.
Feel free to test and feedback.
Nettcpip module is not in the repo (another MSFT team is owner) and it is not ported.
cassie-nahar commentedon May 25, 2018
Ilya (@iSazonov) what version are you running? I'm on the 6.1.0-preview.2, but my help Test-Connection does not match what you put above. Neither does the online help page for Test-Connection in Powershell 6.
Here is what I get:
SYNTAX Test-Connection [-ComputerName] <String[]> [-AsJob] [-BufferSize <Int32>] [-Count <Int32>] [-Delay <Int32>] [-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}] [-ThrottleLimit <Int32>] [-TimeToLive <Int32>] [-DcomAuthentication <AuthenticationLevel>] [-Protocol <String>] [-WsmanAuthentication <String>] [<CommonParameters>] Test-Connection [-ComputerName] <String[]> [-Source] <String[]> [-AsJob] [-BufferSize <Int32>] [-Count <Int32>] [-Credential <PSCredential>] [-Delay <Int32>] [-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}] [-ThrottleLimit <Int32>] [-TimeToLive <Int32>] [-DcomAuthentication <AuthenticationLevel>] [-Protocol <String>] [-WsmanAuthentication <String>] [<CommonParameters>] Test-Connection [-ComputerName] <String[]> [-BufferSize <Int32>] [-Count <Int32>] [-Delay <Int32>] [-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}] [-Quiet] [-TimeToLive <Int32>] [-DcomAuthentication <AuthenticationLevel>] [-Protocol <String>] [-WsmanAuthentication <String>] [<CommonParameters>]However, when I try running Test-Connection with the -TCPPort flag, it does seem to function. So I believe this is mostly a problem with that enhancement being undocumented in the latest current release (6.1.0-preview.2)
iSazonov commentedon May 25, 2018
@kevinlrak It is a trick :-) or bug. You catch Windows PowerShell help. You can find where it is by:
I get
After I rename folder
C:\Users\sie\Documents\PowerShell\HelpI get the right help.corretge commentedon May 29, 2018
In PowerShell 6.0.2, version installed through HomeBrew on a Mac, both commands are missing:
iSazonov commentedon May 29, 2018
Àlex Corretgé (@corretge) You'll get Test-Connection in 6.1 version or you can use 6.1 Preview2 or current dev builds.
MrFly72 commentedon Mar 13, 2022
In my eyes this is breaking all compatibility with no understand from my side, why not implement Test-NetConnection...
It would be really wise to implement it .
This is again one of the commands where I have if/else for what it is running on. and worse enough, it has to be a check for 5.1/7.x, Windows/Linux (5.1 does not support -TCPPort, Linux does not support Test-NetConnection)
is this the type of Multi-Plattform-Support Microsoft is aiming at?
Please reconsider this, as it really breaks scripts that do network checks and should run on multiple plattforms or be easy to port.
claytonolley commentedon Apr 4, 2022
I just came across this today and could really use Test-NetConnection in pwsh on Mac!
vexx32 commentedon Apr 4, 2022
See above; you should be able to use
Test-Connectionfor most of the use cases thatTest-NetConnectioncovered in earlier versions. If you have a specific use case that the current implementation doesn't cover, I suggest you open a feature / improvement request for that cmdlet instead. 🙂MrFly72 commentedon Apr 5, 2022
Rain Sallow (/u/ta11ow) (@vexx32) But as said above. This breaks scripts to be compatible on multiple plattforms. And that because of a really bad reason, in my eyes, as Test-NetConnection could be easily built as the functionality is present in parts in test-connection.
vexx32 commentedon Apr 5, 2022
I have to disagree, since I wrote quite a lot of the current implementation of Test-Connection. Many of the features Test-NetConnection had are simply not available in .NET itself currently. Even the things that are there largely only work on Windows, from what I've been able to determine.
It's probably possible with a third-party library, but I'm not familiar enough in that area to know what would be useful to look at, nor would I expect the maintainers to want to pull it in as a permanent dependency.
Test-NetConnection is simply not cross-platform compatible; some of the things it does on WIndows simply don't have direct analogues on other platforms, as far as I am able to tell.
Test-Connectionis, to the best of our current ability, the closest we have and is available even back in WinPS 5.1 (with some minor differences from the current implementation; it too had to be rewritten completely, in the end).If you'd like to expand what it can do, feel free; I have no doubt that useful functionality would likely be welcomed as a PR. 🙂
MrFly72 commentedon Apr 5, 2022
But exactly thats the current problem. Test-Connection does not support eg. TCPPort in 5.1
So there is no way currently to write code that can be used on 5.1 + 7.x on multiple plattforms, other then doing stuff like.
if ($IsLinux) ..... etc. In my script I am doing this:
vexx32 commentedon Apr 5, 2022
I mean, if you ensure you're using the same version of PowerShell on both, you can skip the check. Beyond that, I don't know what you can really expect, they're two different software packages.
ClaytonOlleyNutrien commentedon Apr 5, 2022
Test-Connection is icmp only... I specifically needed something to test a tcp port connection. I just ended up using netcat instead.
MrFly72 commentedon Apr 5, 2022
With -TCPPort Parameter it is a TCP-Connection?
ClaytonOlleyNutrien commentedon Apr 5, 2022
My apologies, I missed that. The documentation could use some updating it seems. Thanks, and sorry to bother!
shaheerxt commentedon Oct 27, 2022
I know this discussion has been closed, but I wanted to provide an important takeaway.
I am using mac and installed powershell for it.
brew install --cask powershellI access it using pwsh command.
First i logged in with Az login , and it was successful.
But i faced an issue with Get-AzStorageAccount command.
Get-AzStorageAccount: The term 'Get-AzStorageAccount' is not recognized as a name of a cmdlet, function, script file, or executable program.So installed Az module
Install-Module AzBut still there was an issue with port connectivity check
So I came across a note about Test-Connection instead of Test-NetConnection , and it seems returning right result.
ahaleiii commentedon Nov 30, 2022
Test-NetConnectionhas aSourceAddressproperty on the response, from which I can get the sourceIPAddress.Test-Connectionhas aSourceproperty on the response, but this only appears to be thehostname.Is there a way to replicate the
Test-NetConnectionbehavior to getSourceAddresson Linux?