Home > Software engineering >  Test-NetConnection: The term 'Test-NetConnection' is not recognized as a name of a cmdlet,
Test-NetConnection: The term 'Test-NetConnection' is not recognized as a name of a cmdlet,

Time:04-21

I would like to connect to a file share from the azure portal to my windows laptop. However, the related error is shown below.

$connectTestResult = Test-NetConnection -ComputerName storagetestmy3.file.core.windows.net -Port 445
if ($connectTestResult.TcpTestSucceeded) {
    # Save the password so the drive will persist on reboot
    cmd.exe /C "cmdkey /add:`"storagetestmy3.file.core.windows.net`" /user:`"localhost\storagetestmy3`" /pass:`"ZvWYXdvAkX112rT8k2MxQLqlcDi1oA EZNNoGeQ2Bv88DDUWFdtcmbXXfKk/mHNMlw1TDVX3Vrkb AStoh/kOQ==`""
    # Mount the drive
    New-PSDrive -Name Z -PSProvider FileSystem -Root "\\storagetestmy3.file.core.windows.net\fileshare3" -Persist
} else {
    Write-Error -Message "Unable to reach the Azure storage account via port 445. Check to make sure your organization or ISP is not blocking port 445, or use Azure P2S VPN, Azure S2S VPN, or Express Route to tunnel SMB traffic over a different port."
}

Error: Test-NetConnection: The term 'Test-NetConnection' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Please help me to solve it. Thanks.

CodePudding user response:

Open the Latest Version of PowerShell in your Windows Laptop and run the Test-NetConnection command.

The cmdlet is working successfully:

enter image description here

  • Related