简体   繁体   中英

PowerShell mapped network drives not persisting after reboot

The command I'm running to map a network drive is:

New-PSDrive -Name "M" -PsProvider "FileSystem" -Root "\\\\domain.com\\filepath" -Persist -Scope Global -Credential $userCredentials

The command maps the drive and the connection persists after closing the script, but after rebooting the drive disappears. I'm under the impression that adding the global scope supersedes the need for dot-sourcing, which I'd rather not do for the sake of this script.

Thanks in advance for your suggestions/answers!

To anyone else who gets to this question: after the drive is mapped, in the user registry under HKCU\\Network[drive letter] there are two keys that need value changes BEFORE logging out and back in:

Change the DWORD value of ConnectionType to 1, and the DWORD value of DeferFlags to 4. This magically fixed it for me, so the drive persists!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM