Skip to content

Set-IntunePrimaryUsers script - Azure RunBook - Errors #41

@joshuaswift1

Description

@joshuaswift1

I setup the Azure Automation account and Azure Runbook as described in your article ( https://www.tbone.se/2025/03/31/set-intune-primary-user-with-azure-automation/ ) using the latest VERSION 7.4.6 script, but when I set it in TEST mode and run it, nothing displays in the Runbook "Output" tab and the "All Logs" tab shows the below messages... I can't really tell what its doing and why I'm getting the below errors.

4/13/2026, 14:29:04
Output
4/13/2026, 14:34:44
Warning
Request failed (Retry attempt 1/3): Response status code does not indicate success: BadRequest (Bad Request).
4/13/2026, 14:34:44
Error
Bad request (400). Error: Response status code does not indicate success: BadRequest (Bad Request).
4/13/2026, 14:34:44
Warning
Chunk Windows_20260314_20260321 failed: BadRequest
4/13/2026, 14:45:10
Warning
Request failed (Retry attempt 1/3): Response status code does not indicate success: BadRequest (Bad Request).
4/13/2026, 14:45:10
Error
Bad request (400). Error: Response status code does not indicate success: BadRequest (Bad Request).
4/13/2026, 14:45:10
Warning
Chunk Windows_20260328_20260404 failed: BadRequest
4/13/2026, 14:57:29
Output
4/13/2026, 14:29:04
Output
4/13/2026, 14:34:44
Warning
Request failed (Retry attempt 1/3): Response status code does not indicate success: BadRequest (Bad Request).
4/13/2026, 14:34:44
Error
Bad request (400). Error: Response status code does not indicate success: BadRequest (Bad Request).
4/13/2026, 14:34:44
Warning

looks like maybe due to number of users/devices we have... hitting a memory limit

Chunk Windows_20260329_20260405 failed: Request failed after 3 retries. Last error: Exception of type 'System.OutOfMemoryException' was thrown.
Request failed (Retry attempt 1/3): Exception of type 'System.OutOfMemoryException' was thrown.
Non-HTTP error. Waiting 1000 milliseconds before retrying. Error: Exception of type 'System.OutOfMemoryException' was thrown.
Request failed (Retry attempt 2/3): Exception of type 'System.OutOfMemoryException' was thrown.
Non-HTTP error. Waiting 2000 milliseconds before retrying. Error: Exception of type 'System.OutOfMemoryException' was thrown.
Request failed (Retry attempt 3/3): Exception of type 'System.OutOfMemoryException' was thrown.
Non-HTTP error. Waiting 4000 milliseconds before retrying. Error: Exception of type 'System.OutOfMemoryException' was thrown.
Request failed (Retry attempt 4/3): Exception of type 'System.OutOfMemoryException' was thrown.
Non-HTTP error. Waiting 8000 milliseconds before retrying. Error: Exception of type 'System.OutOfMemoryException' was thrown.

====================================================================

Is it possible to update the script to include an optional parameter to only process devices enrolled within the last X days? Such as 30 days? This should help us cut down on the amount of objects queried in the script.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions