
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to remove the mapped network drive using PowerShell?
To remove mapped drives from PowerShell on windows systems, you can use both PowerShell and cmd commands.
Using the cmd command
You can use the below command for a single mapped drive-by specifying the disk drive letter or by using the wildcard character (*).
To remove a single mapped drive.
Example
net use K: /delete
Output
PS C:\WINDOWS\system32> net use K: /delete K: was deleted successfully.
To remove multiple mapped drives together.
Example
net use * /delete
You need to confirm removing multiple mapped disks together.
Output
PS C:\WINDOWS\system32> net use * /delete You have these remote connections: K: \\remoteshare\shared M: \\remoteshare\shared folder Continuing will cancel the connections. Do you want to continue this operation? (Y/N) [N]: Y The command completed successfully.
Using the PowerShell method
To remove the mapped network drive with PowerShell command, you need to provide the drive letter in the cmdlet. If you want to remove the multiple drives together then separate them by comma (,).
Remove-PSDrive K,M –Force -Verbose PS C:\WINDOWS\system32> Remove-PSDrive K,M -Force -Verbose VERBOSE: Performing the operation "Remove Drive" on target "Name: K Provider: Microsoft.PowerShell.Core\FileSystem Root: K:\". VERBOSE: Performing the operation "Remove Drive" on target "Name: M Provider: Microsoft.PowerShell.Core\FileSystem Root: M:\".
Alternatively, you can get the mapped drive using Get-PSDrive and pipeline Remove-PSDrive command to remove them.
Get-PSDrive K,M | Remove-PSDrive -Force -Verbose
Output
PS C:\WINDOWS\system32> Get-PSDrive K,M | Remove-PSDrive -Force -Verbose VERBOSE: Performing the operation "Remove Drive" on target "Name: K Provider: Microsoft.PowerShell.Core\FileSystem Root: K:\". VERBOSE: Performing the operation "Remove Drive" on target "Name: M Provider: Microsoft.PowerShell.Core\FileSystem Root: M:\".
- Related Questions & Answers
- How to map the network drive using PowerShell?
- How to remove pagefile on the specific drive using PowerShell?
- How to get mapped drives using PowerShell?
- How to change the Drive letter using PowerShell?
- How to rename the drive letter in Windows using PowerShell?
- How to remove windows features using PowerShell?
- How to retrieve the Azure subnets connected to the virtual network using PowerShell?
- How to Remove the computer from the AD domain using PowerShell?
- How to remove windows folder sharing using PowerShell?
- How to retrieve the Azure VM network security group (NSG) using PowerShell?
- How to find a network adapter driver version using PowerShell?
- How to remove a member from the local group using PowerShell?
- How to get the Azure VM virtual Network and the Subnet name using PowerShell?
- How to remove connected remote desktop user sessions using PowerShell?
- How to overwrite or remove PowerShell alias?
Advertisements