Adding an item to the Network Locations in Windows Explorer

Recently I was asked if we could automate adding an item to the Network Locations area in Windows Explorer. At first I thought that this would be as simple as putting a shortcut in the right folder. Well, that folder turns out to be %AppData%\Microsoft\Windows\Network Shortcuts on Windows 10. I created the shortcut there and whilst it did appear and I could choose icons etc, it didn’t look like the links that were already displayed.

On closer inspection they were actually a folder that contained hidden and system files. The combination of these files went together to make the link that you were used to. The script below contains a PowerShell cmdlet that you can use to create these items.

Once imported you can use the cmdlet like so: –

New-NetworkLocation -Name "MediaDrive" -Target "\\\media" -Verify

This will create a network location called MediaDrive pointing to the location specified by the Target parameter. The Verify parameter will check that Target exists and that Name does not exist.