Welcome › Forums › General PowerShell Q&A › Existing SMB Connection Doesn’t Exist and Can’t Be Disconnected
- This topic has 1 reply, 2 voices, and was last updated 1 month, 3 weeks ago by
Participant.
-
AuthorPosts
-
-
November 25, 2020 at 10:46 pm #274224
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?!”
PowerShell12PS C:\WINDOWS\system32> whoamimydomain\dougIn the above, you can see who I am as I run this experiment.
PowerShell12345PS C:\WINDOWS\system32> Get-SmbConnectionServerName ShareName UserName Credential Dialect NumOpens---------- --------- -------- ---------- ------- --------filecab drawer1 MYDOMAIN\doug MYDOMAIN\doug 2.0.2 1In 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.
PowerShell12PS C:\WINDOWS\system32> Test-Path "\\filecab\drawer1"TrueIn the above you can see that, yep, there’s a SMB connection. But when I try to disconnect it…
PowerShell12345678PS 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 theproperty 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-SmbMappingIf 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!
-
November 27, 2020 at 8:17 am #274575
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
-
-
AuthorPosts
- You must be logged in to reply to this topic.