Created
November 4, 2020 17:21
-
-
Save GongT/fbe40710875249c4d0256fccd92bcc9d to your computer and use it in GitHub Desktop.
Sync network drive mapping when run "PowerShell (admin)"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### append this into $PROFILE.CurrentUserAllHosts | |
foreach ($info in Get-ChildItem -Path HKCU:/Network) { | |
$letter = Split-Path -Leaf -Path $info.Name -ErrorAction SilentlyContinue | |
if (-Not $letter) { continue } | |
if (Test-Path -Path "${letter}:/") { continue } | |
$remote = $info.GetValue('RemotePath') | |
if (-Not $remote) { continue } | |
New-PSDrive -Scope Global -PSProvider "FileSystem" -Name $letter -Root $remote -ErrorAction SilentlyContinue | Out-Null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment