I have a problem where my mapped network drive becomes unavailable after a restart, trying various solutions to make it persistent [/persistent:yes
when re-mapping via PowerShell, etc.]:
net use Z: "\\10.0.1.145\xyz"
connects the drive fine but doesn't persist past a restart
I wrote a script to automate this for me:
-
If ( !(Test-Path -Path "\\10.0.1.145\") ) { net use Z: "\\10.0.1.145\xyz" /persistent:yes }
- The odd thing is:
Test-Path -Path "\\\10.0.1.145\\"
=false
Test-Path -Path "\\\10.0.1.145\xyz"
=true
- The odd thing is:
net use Z: "\\10.0.1.145\xyz" /persistent:yes
gets the same result as the twoTest-Path
commands, with the only difference beingZ:
is accessible via CMD (Z:
has been accessible via Explorer all along)
How can I map Z:
persistently to 10.0.1.145
or reliably automate this if the former doesn't work?
New-PSDrive
? in my experience, using that with-Persist
and-Scope Global
results in a drive map that stays thru reboots.New-PSDrive -Name 'k' -PSProvider FileSystem -Root '\\MySysName\D$\Temp' -Scope 'Global' -Persist
<<< ///// for more detail, take a look atGet-Help New-PSDrive -Examples
.