One of the recent great features that currently is in preview is the Endpoint Analytics which you can use together with Intune or ConfigMgr (ConfigMgr needs to be Cloud attached) which gives you data on
the performance of your devices and much more.
For more information about Endpoint Analytics can be found here:
https://techcommunity.microsoft.com/t5/configuration-manager-blog/endpoint-analytics-is-now-available-in-public-preview/ba-p/1490040
https://docs.microsoft.com/en-us/mem/analytics/overview
Once you have more than 10 devices enrolled in to Endpoint Analytics you will be able to create new baselines. A baseline is a snapshot of the current state of the data you see in the portal at the time of creating a new baseline. With this feature we can create new baselines on demand but if we take it one step further we can actually schedule and create new baselines when we want them automatically using powershell, graph and an runbooks in azure automation.
In my lab enviroment I want to create a new baseline every month to be able to compare between the months to see how much the score changes over time, either in a positive way or negative where I need to take action to get better perfromance for my users and devices.

Prereqs
If you want to create the runbook and run the script like I do in this article you need to have the Intune Graph SDK Installed and have configured application authentication for Graph. you can follow these articles to get startated
The first one is on how you can import the Intune powershell SDK in to your Automation account
The second thing you need to do is to configure Application permissions to be able to do App based authentication and Michael Niehaus has a great article on how to set that up that you can find here:
and of course you also need to have all the prereqs in place to use Endpoint Analytics which can be found here:
https://docs.microsoft.com/en-us/mem/analytics/overview#bkmk_prereq
The script
The powershell script we will be using is fairly simple and we use the Intune powershell SDK together with Application permissions to do the authentication towards Microsoft Graph, more on that later.
When the script runs it checks which month it is right now and sends a URL request to Graph to create a new Baseline named after that month. For example May or June.
$tenant = “viacompany.onmicrosoft.com”
$authority = “https://login.windows.net/$tenant”
$clientId = Get-AutomationVariable -Name 'ClientID'
$clientSecret = Get-AutomationVariable -Name 'ClientSecret'
$Resource = "deviceManagement/userExperienceAnalyticsBaselines"
$graphApiVersion = "Beta"
$uri = "https://graph.microsoft.com/$graphApiVersion/$($resource)"
$CurrentMonth = (Get-UICulture).DateTimeFormat.GetMonthName((Get-Date).Month)
Update-MSGraphEnvironment -AppId $clientId -Quiet
Update-MSGraphEnvironment -AuthUrl $authority -Quiet
Connect-MSGraph -ClientSecret $ClientSecret -Quiet
$JSONName = @"
{
"displayName":"$($CurrentMonth)"
}
"@
Invoke-MSGraphRequest -HttpMethod POST -Url $uri -Content $JSONName | out-null
Do not forget to change the $tenant varible in the script to your Azure tenant
Implementation
Head over to your Azure runbooks, create a new one andd give it a name


Make sure you have the Microsoft.Graph.Intune imported like i mentioned in the prereqs. And that you have the variables for ClientID and ClientSecret available for your script to use.



Schedule – When the script will run


You can either choose an existing schedule or create a new one, this schedule determines when the script will run on an occuring basis.

Here’s how my Monthly schedule looks like


The end result will look something like this, each time the script runs on its schedule it will create a new baseline with the name of the month when it was created. This will enable us to compare how the state of our envirorment between different times.


That it for this time, let me know if there any topics or questions you want me to cover in a upcoming article.
Don’t forget to follow me on twitter @timmyitddotcom
Great idea, thanks for the writeup. 🙂
Thank you for explaining Endpoint Analytics baseline!