Skip to content

Instantly share code, notes, and snippets.



Created Nov 4, 2020
What would you like to do?
Sync network drive mapping when run "PowerShell (admin)"
### 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