Loading...

Using PowerShell and MS Graph to get the top 50 devices with BSOD

1 A+ A-


In this post I will show you a script allowing you to list top 50 (or other) devices with BSOD during last 30 days.


Context

You want to get a list of devices that have the most BSOD during last month.

You want to get the device name, model, count of BSOD, last BSOD date and code.


The solution

To get this list we will use PowerShell and MS Graph.

By default you can easily get this list through the Intune portal, here below:


With the developer mode of your browser you can easily get the Graph URL used behind.


This one is the the below one:

deviceManagement/userExperienceAnalyticsDevicePerformance?dtFilter=all&`$orderBy=blueScreenCount%20desc&`$top=50&`$filter=blueScreenCount%20ge%201%20and%20blueScreenCount%20le%2050"


To get more information about the developer mode, check my post here.


Get the script

Click on the below GitHub picture to get the script


How to use it ?

You can of course change the number of top devices by setting variable $Count.

By default, I configured it to 50 but you can set it using variable $Count.


There are 3 versions of the script depending of the Graph method you use:

- MSAL.PS

- Graph.Intune

- Microsoft.Graph


The script contains some parameters:

- CSV: allows you to export result to CSV

- GridView: allows you to sort results in Out-GridView

- CSV_Path: set the CSV path


What's next ?

In the next post, I will show you how to schedule this script with Azure Automation to send result with a Teams notification, as below:


slider 5210253502622450636

Enregistrer un commentaire

1 commentaire

Alex a dit…

I am trying to setup your microsoft graph connector script. I am getting the following error:

Cannot index into a null array.
At line:58 char:3
+ $Get_BSOD = ((Invoke-MgGraphRequest -Uri $StartupHistory_url ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray


Line 58: $Get_BSOD = ((Invoke-MgGraphRequest -Uri $StartupHistory_url -Method get).value | Where {$_.restartCategory -eq "blueScreen"})[-1]


Is this something you can help me with?

Accueil item

Award

Sponsors

You want to support me ?

Mes articles en français

Endpoint Manager award

Author of Books

Stats