Existing SMB Connection Doesn't Exist and Can't Be Disconnected

After deciding (perhaps wrongly) that “net use” is not the Powershell way, and that New-PSDrive is the non-preferred older way, I’m trying to use New-SmbMapping to map a drive, but it keeps failing with an existing remembered connection. So I’m doing experiments, as below, and am reduced to finding no explanation and having to ask here … “Why am I seeing the following behavior?!”

PS C:\WINDOWS\system32> whoami

In the above, you can see who I am as I run this experiment.


PS C:\WINDOWS\system32> Get-SmbConnection

ServerName ShareName UserName       Credential      Dialect NumOpens
---------- --------- --------       ----------      ------- --------
filecab    drawer1   MYDOMAIN\doug  MYDOMAIN\doug   2.0.2   1

In the above, you can see there’s an existing connection to \filecab\drawer1. I’m unsure how this connection is being established, although it’s possible I connected to this share at some time in the past, but I can find no evidence via the GUI of being connected.


PS C:\WINDOWS\system32> Test-Path "\\filecab\drawer1"

In the above you can see that, yep, there’s a SMB connection. But when I try to disconnect it…


PS C:\WINDOWS\system32> Remove-SmbMapping -RemotePath "\\filecab\drawer1"
Remove-SmbMapping : No MSFT_SmbMapping objects found with property 'RemotePath' equal to '\\filecab\drawer1'. Verify the value of the
property and retry.
At line:1 char:1
+ Remove-SmbMapping -RemotePath "\\filecab\drawer1"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (\\filecab\drawer1:String) [Remove-SmbMapping], CimJobException
+ FullyQualifiedErrorId : CmdletizationQuery_NotFound_RemotePath,Remove-SmbMapping

If I understand the above, it says the connection that exists doesn’t really exist.

I don’t understand. Hopefully someone here can enlighten me as to what I’m doing wrong. Thanks!

The Powershell drives are here:

> Get-PSDrive

The UNC Drives are here:

> net use


I Think you have stored the Password in Windows:

The WindowsPasswords for UNC Path (and others) are here:

> rundll32.exe keymgr.dll, KRShowKeyMgr