Configuring the default search engine for Microsoft Edge through initial_preferences so that it actually works

Microsoft Edge, since some time now based on Google’s Chromium, supports a similar mechanism to configure (not enforce!) default preferences through a file called initial_preferences. But when it comes to configuring the default search engine, neither Microsoft’s documentation nor their downloadable Microsoft Edge policy templates are of any help. In fact, I couldn’t find a single example on the Internet that shows how this can be done, so this blog post is one of the rare moments where I can actually contribute something unique.

System administrators regularly want to preconfigure Microsoft Edge in an attempt to tame Microsoft’s totally messed up defaults. As part of this, they often want to configure a different search engine such as Google or DuckDuckGo instead of Microsoft’s Bing. You can do this through Intune/group policies, even with a “Recommended” setting so that users still can overwrite your setting. But there are scenarios where you can’t or don’t want to use policies, such as when you’re preparing a standalone system for a customer, where you would want to use the initial_preferences mechanism instead.

Even then there’s the binding limitation that because Microsoft likes to f*ck with system admins, Microsoft Edge regards both policies and the initial_preferences mechanism only when the system is either Active Directory-joined or MDM managed. Luckily, Gunnar Haslinger found a way to fake MDM enrollment which you can apply for the time of Edge configuration and undo afterwards, provided your scripting runs with elevated privileges.

Ok, with that out of the way, how do we configure the default search engine (or search provider, as it’s called in Edge’s terminology) through the initial_preferences file?

The official documentation only has a table of “currently supported preferences settings” that contains an entry default_search_provider but without any usable documentation:

"default_search_provider": "[default_search_provider] enabled"

But what about the downloadable Microsoft Edge policy templates? Unfortunately no documentation there either and their example initial_preferences contains a block that doesn’t even work:

"default_search_provider" block with two directives, "enabled" = true and "search_url": "www.bing.com"

Edge will still have Bing as default search engine, even if you change search_url to www.google.com. Damn!

So what does work?

In order to find that out, I digged into the generated Edge user profile found at %LocalAppData%\Microsoft\Edge\User Data and there the Default\Secure Preferences file. When you changed the search engine manually within Edge, this file will contain a block similar to the following:

    "default_search_provider_data": {
        "template_url_data": {
            "alternate_urls": [
                "{google:baseURL}#q={searchTerms}",
                "{google:baseURL}search#q={searchTerms}",
                "{google:baseURL}webhp#q={searchTerms}",
                "{google:baseURL}s#q={searchTerms}",
                "{google:baseURL}s?q={searchTerms}"
            ],
            [...]
            "short_name": "Google",
            "short_name_lang": "en",
            [...]
            "url": "{google:baseURL}search?q={searchTerms}&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchboxStats}{google:searchFieldtrialParameter}{google:iOSSearchLanguage}{google:prefetchSource}{google:searchClient}{google:sourceId}{google:contextualSearchVersion}ie={inputEncoding}"
            [...]
        }
    }

This block is what needs to go into your initial_preferences file, as simple as that!

But, in fact, if you just want to change to one of the default search engines already included with Edge such as Google, it is even simpler. This is an initial_preferences file with the minimum set of parameters needed to configure Google as the default search engine:

{
    "default_search_provider_data": {
        "template_url_data": {
            "keyword": "google.com",
            "short_name": "Google",
            "synced_guid": "485bf7d3-0215-45af-87dc-538868000003",
            "url": "{google:baseURL}search?q={searchTerms}&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchboxStats}{google:searchFieldtrialParameter}{google:iOSSearchLanguage}{google:prefetchSource}{google:searchClient}{google:sourceId}{google:contextualSearchVersion}ie={inputEncoding}"
        }
    }
}

Hope this helps but please do not contact me if this doesn’t work for you or you didn’t understand details, I don’t do Microsoft stuff for a living and have no time to help every junior out of in the world, sorry.