While Remove-PSDrive can remove all kinds of drives including network drives, changes may not take effect until the system reboots. That’s of course ridiculous.
This task is a good example why it is useful that PowerShell made console applications equal citizen. In fact, even in year 2021 the most reliable way to remove a network drive is to use the old but proven net.exe. The example below removes network drive letter Z:
PS> net use z: /delete
z: was deleted successfully.
ReTweet this Tip!
It's interesting that the post...
... uses the PowerShell way and this one uses the DOS cmdline tool.
Using the PowerShell method
remove the multiple drives together then separate them by comma (,).
Remove-PSDrive K,M -Force -VerboseOr Get-PSDrive and pipeline Remove-PSDrive command to remove them.
Get-PSDrive K,M | Remove-PSDrive -Force -Verbose
Powered by IDERA