Windows Autopilot device association Companion App for the QR Code

Since there is currently no way for OEMs or Partners to associate devices with Autopilot device preparation and there is a nice QR Code presented in the OOBE flow for the device association, I wanted to make it easier for IT Pros to do the association. There is already a cool solution available to use the QR Code. https://autopilotqr.app/, however I want it to be available in my Companion App rather than relying on a public website or have to host my own instance on a webserver.

If you want to skip the technical explanation on how we can use the QR Code, you can jump directly to the part on how to import the Companion App: here

Looking into the QR Code

When trying to associate a new device we get presented a QR Code that looks interesting:

If we look at what is inside the QR Code, it looks something like this:

This looks quite different to what is usually in the devicelink.csv that we normally use to associate our devices:

That one is usually just base64 encoded and can be converted easily to see what is inside:

That is not the case for the data field in the QR Code…

First, it contains chars that are not part of the base64 standard but it looks URL safe encoded by converting ‘/’ and ‘+’ to ‘%2B’ and ‘%2F’

So, if we URL Decode these chars first, we start to get some data:

Which very much looks like some kind of binary and after some research we found the magic bytes for a gzip file:

Which we can inflate back to see the included data:

While at first glance it looks like we now can simply use that to create our device association, but I guess to save space in the QR Code (which is AFAIK limited to around 3kb of data) the properties are shortened:

Compared to the same data in the deviceLink.csv file which looks like this:

We need to rename the properties to the full names, convert the Unix Timestamps to the ISO time format and add the “-” to the GUIDs in KeyID, SmbiosUuid and LinkID:

Fortunately, we can have a look at the Autopilot QR Project to see how the file should look like: https://github.com/Simsen/AutopilotQR/blob/main/src/lib/devicelink.ts

PowerAutomate

One challenge to do convert the QR Code in our Companion App is, there is no built in way to gunzip data in PowerAutomate, fortunately there is a way to create a custom connector that allows us to do that with some C# code as described in this post: https://medium.com/@vandanrohatgi/extract-gzip-files-with-power-automate-0387cf3ca0e3

We can simply create our own custom connector for gunzip:

That we can use in our PowerAutomate Flow to throw the corrected base64 string at to get our inflated data:

Companion App

Similar to the Companion App for Corporate Identifiers that I posted about two years ago: https://mikemdm.de/2024/07/28/new-autopilot-companion-app-for-corporate-identifiers/ I wanted an easy to use App, which can be used on your smartphone to add new devices or assign Autopilot polices to an associated device:

Custom gunzip Connector

Before we can import the App, we need to create the custom connector for gunzip. To do that we go in make.powerapps.com to more:

And in Discover all to custom connectors:

Where we create a new connector from blank:

Give it a name:

Enter a dummy name for the Host:

Keep security set to “No authentication”:

And add a new action:

Give it an operation id like “gunzip”

And add a Request with the “Import from sample”, select “POST”, give it a dummy URL like “local” and enter a json body:

{
"file": ""
}

Go next to 4. Code, and copy the custom inflate code from GitHub: Autopilot-Companion/PowerApp/Gunzip Connector.txt at main · mmeierm/Autopilot-Companion

Click on “Create Connector” to finalize the setup:

Now we just need to create a connection to it:

Import

To import the App and the PowerAutomate flows, you can use the export package from GitHub: Autopilot-Companion/PowerApp/AutopilotDeviceAssociationCompanion_20261101121423.zip at main · mmeierm/Autopilot-Companion

To do that, we go to Apps and click on “Import app”:

Here we can select our .zip file:

And Select our Gunzip Connector:

And the previously created connection:

And select Import:

Entra ID

To allow our PowerAutomate Flows to authenticate against Entra ID, we need to create an App Registration (If you already have one from the older Autopilot Companion App, you can reuse it and just adjust the permissions and jump directly to the PowerAutomate part: here)

In entra.microsoft.com, we go to “App registrations”

And create a new single tenant registration, give it a name:

Now we can add the Graph API Permissions and grant it for the Org:

Now we can create our App Secret:

Copy the Value, as you can’t view it later.

Power Automate

Now that we have all Information available, we can now edit our new flows, which were imported together with the Power App. https://make.powerautomate.com

We have to edit each Flow, enable it and modify all HTTP actions to adjust the Tenant ID, the Client ID and secret from the App Registration:

Save it and enable the flow:

So, it should look like this:

Power Apps

Now we can go back to Power Apps to test our App:

If you get an error for the PowerAutomate Connections, you may need to re-add the PowerAutomate Connections in the App:

IT Pro Experience:

The IT Pro on the phone can now simply open the PowerApps App:

Grant Access to the Camera:

Add the new device:

Select the preferred AP Profile:

And Scan the QR Code to add the device:

Conclusion

Using the QR Code instead of working with the csv file highly simplifies the process to associate a device and until there is a way for OEMs or Partners to automatically associate devices like they are able for classic Autopilot.


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *