Recently Adam Gross from A Square Dozen wrote a blog post on how to pin Microsoft Edge profile shortcuts to the taskbar and that got me thinking into how I could do this automatically. Unfortunately I couldn’t find a way to pin to the taskbar without a third party tool so I came up with the following solution that will create shortcuts for each of your profiles automatically on the desktop instead. The script will scan through %LOCALAPPDATA%\Microsoft\Edge\UserData and locate any custom profiles that you may have created (Example: %LOCALAPPDATA%\Microsoft\Edge\UserData\Profile 1). It will then query each profile’s preference file and locate the name of the profile so it can be used for the shortcut name (Example: Edge – Jose). At the end of the script, it will also create a shortcut for your default profile.

Keep in mind this script will only work with the regular Edge channel and not the DEV,Beta or Canary channel since the “C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe” is hard coded in the script. Hopefully this will help someone and if there is a way to pin to the taskbar by just using Powershell, please let me know!

$EdgeProfiles = Get-ChildItem "$env:LOCALAPPDATA\Microsoft\Edge\User Data" | Where-Object { $_.Name -like "Profile *"}

ForEach($EdgeProfile in $EdgeProfiles.Name) {

    # Get Profile Name
    $Preferences = "$env:LOCALAPPDATA\Microsoft\Edge\User Data\$EdgeProfile\Preferences"
    $Data = (ConvertFrom-Json (Get-content $Preferences -Raw))
    $ProfileName = $Data.Profile.Name

    # Create Shortcut on Desktop
    $TargetPath =  "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
    $ShortcutFile = "$env:USERPROFILE\Desktop\Edge - $ProfileName.lnk"
    $WScriptShell = New-Object -ComObject WScript.Shell
    $Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
    $Shortcut.IconLocation = "$env:LOCALAPPDATA\Microsoft\Edge\User Data\$EdgeProfile\Edge Profile.ico, 0"
    $Shortcut.Arguments =  "--profile-directory=""$EdgeProfile"""
    $Shortcut.TargetPath = $TargetPath
    $Shortcut.Save()

}

# Get Profile Name
$Preferences = "$env:LOCALAPPDATA\Microsoft\Edge\User Data\Default\Preferences"
$Data = (ConvertFrom-Json (Get-content $Preferences -Raw))
$ProfileName = $Data.Profile.Name

If($ProfileName -eq "Person 1") {

    $ProfileName = "Default"

}

# Create Shortcut on Desktop
$TargetPath =  "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
$ShortcutFile = "$env:USERPROFILE\Desktop\Edge - $ProfileName.lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.IconLocation = "$env:LOCALAPPDATA\Microsoft\Edge\User Data\Default\Edge Profile.ico, 0"
$Shortcut.Arguments =  "--profile-directory=""Default"""
$Shortcut.TargetPath = $TargetPath
$Shortcut.Save()