This week I’m going to show an example of how to collect the Windows AutoPilot device information of existing Microsoft Intune managed (Windows 10) devices. That could be useful, for example, when an organization wants one similar deployment experience for all devices. For now and in the future. In that case it can be very useful to gather the device information and upload that information. That will provide future deployments of those existing devices with the same company branded deployment experience as new devices. Also, another reason for this post is the simple fact that I’ve received this request multiple times now.
This example will use an Azure storage account that will be used to store the Windows AutoPilot device information and it will use the Get-WindowsAutoPilotInfo script to collect the information. In this post I’ll show high over the steps to create the Azure storage account, followed by an overview of the PowerShell script to collect the information and write the information to the storage account. I’ll end this post with the Microsoft Intune configuration and a quick peak at the results. After that simply collect the information and upload it via Microsoft Intune or the Microsoft Store for Business (or the Partner portal).
Create storage account
The first step is to create a storage account in Azure. The following four steps walk through the high over steps to create a storage account including a file share. That file share will be used to store the Windows AutoPilot device information.
|1||Open the Azure portal and navigate to Storage accounts;|
|2||Add a storage account of the Storage (general purpose v1) kind and make sure that Secure transfer required is enabled (remember the storage account name);|
|3||Navigate to Files and add a file share (remember the file share name);|
|4||Navigate to Access keys and view the available keys (remember the key) ;|
Note: Be aware that not every ISP allows access from port 445 to Azure (for an overview see: https://social.technet.microsoft.com/wiki/contents/articles/32346.azure-summary-of-isps-that-allow-disallow-access-from-port-445.aspx).
Create PowerShell script
The second step is to create a PowerShell script to upload the Windows AutoPilot device information to the file share in the just created storage account.
This PowerShell script is created for usage within Microsoft Intune. Currently the PowerShell script functionality within Microsoft Intune can’t work with input variables, which means that the values of the different variables have to be available in the script. That means that in the variables block on top of the script (see script snippet section) the following values should be adjusted.
- <StorageAccountKey>: This should be the access key of the created storage account (step 4);
- <StorageAccountName>: This should be the name of the created storage account (step 2);
- <ShareName>: This should be the name of the share of the created storage account (step 3).
The PowerShell script contains a few actions that it should perform to complete the required activities. It contains the following actions that can be found in the different try-catch blocks (see script snippet section).
- Create a drive with the created Azure storage account;
- Download the available script from PowerShell Gallery;
- Set the location to the location of the downloaded script;
- Install the downloaded script;
- Run the installed script and use the created drive for the output;
- Remove the downloaded script and the created drive.
The PowerShell script is shown below.
[gist https://gist.github.com/pvanderwoude/09f4e1354a41a40e5a6f98bd826333c7 /]
Note: Be aware that downloading PowerShell Gallery items requires PowerShellGet and that PowerShellGet requires the NuGet provider to work with the PowerShell Gallery (for more information see: https://docs.microsoft.com/en-us/powershell/gallery/psgallery/psgallery_gettingstarted).
Configure PowerShell script
The third step is to configure the PowerShell script in Microsoft Intune. To upload the script, follow the next five steps. After uploading the script, simply assign the script to the required users and/or devices.
|1||Open the Azure portal and navigate to Intune > Device configuration > PowerShell scripts;|
|2||On the Device configuration – PowerShell scripts blade, click Add script to open the Script Settings blade;|
|3||On the Add PowerShell script blade, provide the following information and click Settings to open the Script Settings blade;
Note: The script must be less than 10 KB (ASCII) or 5 KB (Unicode).
|4||On the Script Settings blade, provide the following configuration and click OK to return to the PowerShell script blade;
Note: Configure Run the script using the logged on credentials to No means that the PowerShell script will run in SYSTEM context;
|5||Back on the Add PowerShell script blade, click Create.|
Now let’s end this post by looking at the results. The share in the created storage accounts will start filling with CSV-files of the different Windows 10 devices that are managed by Microsoft Intune. That means that it will start to look like something as shown below.
As the required device information is available now, within the file share of the storage account, it can be downloaded and imported via for example Microsoft Intune. Of course it’s possible to use PowerShell to merge these CSV-files into one big CSV-file. This is relatively easy by simply using something like Get-Content and always grab the second line of the CSV-files.