Automatically create Microsoft Edge profile shortcuts

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()

11 Comments

  1. Élisson Góis Gallas

    Hi, thanks for your post, it helped me a lot. I coudn’t find any answer in microsoft’s hub. I’ve tested that code in PowerShell and it just worked very well.

  2. wow, your doing good work

    tks bro

  3. Such a great script, thanks for sharing

  4. It worked like charm. Thank you

  5. Thanks for this, really helpful. One thing I found was that the theme of my secondary profile was reverted back to ‘light’ from ‘dark after I’d run the script. That doesn’t make any sense to me as to why but there you go. Great job, thanks

  6. Doesn’t work.

    • Jose Espitia

      June 7, 2021 at 6:43 pm

      What error do you get when you run the script? As you can tell from the comments, the script works 🙂

    • If you’re getting “DirectoryNotFoundException” then that’s probably because your desktop is syncing to OneDrive. In this case, replace the two instances of “\Desktop” with “\OneDrive\Desktop” and it should work fine.

Leave a Reply