Quickly create a new profile for Edge with PowerShell

Quickly create a new profile for Edge with PowerShell header image

Setting up a new machine is an awesome experience. And with Endpoint Manager and Winget a smooth experience. There is however one thing left that when doing consultancy is something you have to do quite often: Creating new Edge profiles. There is a wonderful write-up on launching Edge with different profiles using shortcuts that explains a bit of the why and how to create shortcuts for your profiles.

Multiple profiles

The basic premise is that you should have an Edge profile for each customer you are working for. By doing so you group everything together and you will not be slammed with authentication issues. Just open your browser for that customer or project and you are good to go. I have been using the same approach for quite a while and am quite happy with the results. I have two main profiles (company profile and MVP profile) to differentiate between work and the community stuff. And I create a new profile for each customer I am working on. That way I feel a bit safer when clicking the keep me logged in button. It also allows me to remove a profile once a project is over, and will clean up everything on my machine.

Creating profiles

The only downside with that approach is that I usually start working for a customer in the guest mode and a few weeks in remember to create a profile. It takes a few seconds to click through the UI and to finally clean them up. With that in mind I had a chore on my to do list for a long time. See if I could automate the creation of such profiles. After hitting Google (and Bing). I couldn’t really find a solution that worked for me except for samples using the command line. That did make sense, and lead to me deciding to write small PowerShell script. The goal was to call the script, pass in the customer’s name and open a new browser. I couldn’t find a way to rename the profile, so the current implementation does require me to manually change the profile name. For security reasons you cannot pass the edge://settings/profiles as a start up page. Other than that it does eliminate around three to four clicks depending on where I am in the workflow.

The script it self is straightforward, it is wrapping the edge startup command and use the Start-Process to execute it, as a reminder to rename the profile I added a Write-Output but thats all.

param ($customerName)

$profilePath = "profile-" + $customerName
$proc = Start-Process -FilePath "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" -ArgumentList "--profile-directory=$profilePath --no-first-run --no-default-browser-check"

Write-Output "Profile $customerName created, go to edge://settings/profiles"

You can call the script with .\createEdgeProfile.ps1 -customerName "NewCustomer" and the results are a new window with only one manual step left to go; renaming your profile!

Result of executing the PowerShell script: A new Edge profile

Perhaps this approach helps you as well, and if you have a way to rename a profile let me know! I did try to work with the preference json file that contains this info but updating that did not rename the profile..

Update: adding it as a function to your default PowerShell Profile

After blogging the solution Erwin Bieren pointed out you can even make life a bit easier by adding it to your default profile. Open PowerShell, execute notepad $profile and add the following snippet to the profile:

function New-EdgeProfile {
    [cmdletBinding()]
    param (
        [parameter(mandatory=$true)]$customerName
    )

$profilePath = "profile-" + $customerName
$proc = Start-Process -FilePath "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" -ArgumentList "--profile-directory=$profilePath --no-first-run --no-default-browser-check"

Write-Output "Profile $customerName created, go to edge://settings/profiles"
}

Restart your PowerShell window, and you are free to call the New-EdgeProfile whenever you like. Making it even easier to create new profiles.

Loading comments…