#
Intune-BulkSync.ps1
Forcing Intune sync for devices is a nightmare. The pages and blades make selecting devices a pain in the behind.
So I write a command line UI to speed up that process significantly.
#
Table of Contents
Table of Contents Purpose Dependencies Function Usage Inputs Variables Command Line Flags Outputs Notes
#
Purpose
Performs bulk, OS-specific, group-based, or single device synchronisation of devices in Microsoft Intune, using an interactive menu. Handles module checks, authentication, and robust user feedback.
#
Dependencies
- PowerShell 7
- [Require-Pwsh7.ps1] (custom module, dot-sourced)
- Microsoft.Graph.Intune
- Microsoft.Graph.DeviceManagement
- Microsoft.Graph.Authentication
- Connect-MgGraph
#
Function
- Imports and enforces PowerShell 7 usage via a custom module.
- Checks for and installs required Microsoft Graph modules if missing.
- Authenticates the user to Microsoft Graph with required permissions.
- Presents an interactive menu to:
- Sync all Windows, Android, or iOS devices
- Sync all devices (all OS)
- Sync a single device by name (with partial match and selection)
- Sync all devices in defined test groups
- End the script
- For each sync, retrieves devices and initiates a sync via Microsoft Graph.
- Provides user feedback, error handling, and confirmation dialogs throughout.
- Handles script exit and cleanup gracefully.
#
Usage
Note: Ensure PS7 is being used to run the script, otherwise you will need the custom module to ensure the script is launched in PS7.
Run directly to launch the menu:
./Intune-BulkSync.ps1
Follow the prompts to select the sync type and target devices.
#
Inputs
- User selection via interactive menu (no command-line parameters).
- Prompts for device name (for single device sync) and menu choices.
#
Variables
$modulePath
: Path to the required PowerShell 7 enforcement module.$moduleNames
: Array of required Microsoft Graph modules.$devices
,$device
,$partialMatches
,$deviceIds
,$groups
,$members
: Used for device and group management.$choice
,$repeat
: User menu selections.
#
Command Line Flags
None (all interaction is via menu and prompts).
#
Outputs
- Initiates device syncs in Intune and logs results to the console.
- Provides pop-up and console feedback for success, errors, and completion.
- Exits gracefully with user confirmation.
#
Notes
- Requires PowerShell 7 and Microsoft Graph modules.
- Custom module
Require-Pwsh7.ps1
must be present and accessible. - All output is accessible and uses EN-AU spelling.
- See project standards for robust root-based module import and error handling.