I've been trying al sorts of varieties of the following, trying to mount a network share in such a way it can be visible for both other shells and in File Explorer. According to the MS documentation of the related commands, saying one can use -Persistent
and -Scope Global
to make them "immediately visible to other shells", it just doesn't work.
$mDL = 'Z' # Mount to this Drive Letter
$dDesc = 'ML-DATA' # Description of PSDrive
$NLRoot = "\\somepath.windows.net\xxx"
$UserName = "localhost\someuser"
$cred = Get-Credential -Credential $UserName
New-PSDrive -Name $mDL -PSProvider "FileSystem" -Root $NLRoot -Credential $cred -Description $dDesc -Persist -Scope Global
The data container is in Azure, and everything seem to work apart from being visible from other parts in my system (Win10).
How can I make this drive visible from other PowerShell
instances and File Explorer?
UPDATE: 2022-07-06
My bad, the text was from the ss64 docs for New-SmbMapping, where it was stated:
When a drive mapping is created with New-SmbMapping the new drive will not be visible to any currently running processes (including Windows Explorer) until that process is restarted (or the machine is rebooted). The one exception to this is the PowerShell console, all PowerShell sessions on the machine will immediately get the new drive mappings.
It may also be that the MS documentation is not easily understood by non-specialists, because in the New-PSDrive docs, the following is stated in 2 places.
In
Example-4
:
The mapped drive can be viewed on the local computer in PowerShell sessions, File Explorer, and with tools such as net use.In the
Paramters
list under-Persist
:
Mapped network drives are saved in Windows on the local computer. They're persistent, not session-specific, and can be viewed and managed in File Explorer and other tools.
So how can I make this share user and session type agnostic, in such a way that Z:
is visible "everywhere" and for "everyone" in both in File Explorer and whatever powershell/cmd they want to use?
Useful References: