NOTE: I can't test this not having Intune but when I ran it I was prompted to input MS credentials which I assume it needs for admin functions.
Needless to say, try a test first.
May help, may not.
This information is from these URLs:
https://smsagent.blo...mgr-with-powershell/https://social.techn...he-list-of-computersYou need to install dependencies which you can do as follows in a PowerShell Admin console.
For Intune you need: Microsoft.Graph.Intune
For AzureAD you need: AzureAD
Below is the commands with the output you can expect:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\Users\ItsMe> Install-Module -name Microsoft.Graph.Intune
NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet
provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or
'C:\Users\ItsMe\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running
'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import
the NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its
InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): Y
PS C:\Users\ItsMe> Install-Module -name AzureAD
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its
InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): Y
PS C:\Users\ItsMe>
With the code from the site you create the
Delete-AutopilotedDeviceRecords.ps1 script in a dir, (I've attached the script but you'll probably need to change it's security properties for it to run).
Then, in theory, you should be able to:
.\Delete-AutopilotedDeviceRecords.ps1 -ComputerName <computer name> -IntuneFor multiple computers, create a CSV with one per line, for example:
computername
pc01
pc02
pc03
pc04
And then this short script should run through them all:
$computer = Import-Csv .\test.csv
$computer | ForEach-Object {
.
/Delete
-AutopilotedDeviceRecords.ps1
-ComputerName $_.computername
-Intune
}