- 1 year ago
How to disable connection previously created with `connect`?
Comment
1 / 1
To disable a previously created connection using the Connect
command in PowerShell, you can use the Disconnect
command. The Disconnect
command is used to terminate an existing network connection.
Here's an example of how to disable a connection:
powershellDisconnect-NetConnection -Name "ConnectionName"
Replace "ConnectionName"
with the name of the connection you want to disable. You can find the connection name by running the Get-NetConnectionProfile
command.
Here's a complete example:
powershell# Get the connection name
$connection = Get-NetConnectionProfile | Where-Object {$_.Name -eq "ConnectionName"}
# Disconnect the connection
Disconnect-NetConnection -InterfaceIndex $connection.InterfaceIndex
Replace "ConnectionName"
with the name of the connection you want to disable.
Please note that the Disconnect-NetConnection
command may require administrative privileges to execute successfully.