How can I delete multiple computer objects and hashes from intune with hostname with powershell

Russ 5 Reputation points
2024-02-22T19:24:53.43+00:00

we have lists of serial numbers and hostnames delivered by our desktop team when assets are ewasted usually a couple hundred at a time are delivered . I would like to get the intune objects and autopilot hashes removed from intune with a script fed by a csv or master list currently attempting to get Delete-AutopilotedDeviceRecords.ps1 to function for me and while I can format a list of hostnames for purge each item attempts to reconnect and re-auth to tennant creating timeouts and delays just wondering if there is a straightforward procedure for this that I have not stumbled upon yet

Windows for business Windows Server User experience PowerShell
Microsoft Security Intune Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. ZhoumingDuan-MSFT 17,165 Reputation points Microsoft External Staff
    2024-02-23T06:32:05.7033333+00:00

    @Russ,Thanks for posting in Q&A.

    From your description, I know want to delete multiple computer objects and hashes from Intune with hostname with PowerShell.

    For this issue, I will share you some information.

    Install-Module -Name WindowsAutoPilotIntune -RequiredVersion 5.0 #To remove the device from the Autopilot devices Connect-MSGraph Get-AutoPilotDevice | Where-Object SerialNumber -eq (Get-WmiObject -class Win32_Bios).SerialNumber | Remove-AutopilotDevice

    #To remove the device from Azure AD device

    Connect-Azuread Get-AzureADDevice | Where-Object DisplayName -Match $env:COMPUTERNAME | Remove-AzureADDevice

    Hope this can help you.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

  2. Russ 5 Reputation points
    2024-02-23T17:14:06.3533333+00:00

    so we got it working with Delete-AutopilotedDeviceRecords.ps1 by running the following cd to location of script $ComputerNames = (Get-content -path "place your path to text file here\ComputerNamestoDelete.txt") .\Delete-AutopilotedDeviceRecords.ps1 -ComputerName $ComputerNames -Intune -ConfigMgr -Autopilot hostnames can be dumped into text file and script will then purge out intune object autopilot hashes and sccm objects (script offers support to purge from AAD and AD as well) blog from original author of script here https://smsagent.blog/2020/03/17/delete-device-records-in-ad-aad-intune-autopilot-configmgr-with-powershell/

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.