能否在Microsoft Intune(Endpoint Manager)中批量创建100台虚拟设备用于MS Intune Graph API分页测试?
Absolutely! You can create simulated virtual devices in Microsoft Intune specifically for testing pagination with the Graph API—no physical devices required. Here are the most straightforward methods to pull this off:
Method 1: Batch Create Simulated Devices with PowerShell
This is the fastest way to generate 100+ test devices. You’ll use the Microsoft Graph PowerShell module to automate the creation:
Install the required module (if you haven’t already):
Install-Module Microsoft.Graph.Intune -Force -AllowClobberConnect to Microsoft Graph with the necessary permissions:
Connect-MgGraph -Scopes "DeviceManagementManagedDevices.ReadWrite.All"You’ll need to authenticate with an account that has Intune device creation permissions (e.g., Intune Administrator role).
Run the batch creation script:
This script will generate 100 devices with sequential names, along with basic OS/device type details:# Define a template for your test devices $deviceTemplate = @{ accountEnabled = $true displayName = "Test-Virtual-Device-" operatingSystem = "Windows" operatingSystemVersion = "10.0.19045" deviceType = "Desktop" } # Loop to create 100 devices for ($i=1; $i -le 100; $i++) { $deviceParams = $deviceTemplate.Clone() $deviceParams.displayName += $i.ToString("000") # Adds leading zeros for clean numbering New-MgDeviceManagementManagedDevice -BodyParameter $deviceParams }
Key Notes About These Simulated Devices
- These are non-managed, simulated devices—they won’t actually connect to Intune or require device licenses, but they will appear in your Intune device list and be returned by Graph API queries just like physical devices.
- They’re perfect for testing pagination: when you query the
managedDevicesendpoint, Intune will paginate results once you exceed the default page size (usually 100 items), so your 100+ devices will trigger the pagination behavior you need to validate. - To clean up later, you can batch delete them with this command:
Get-MgDeviceManagementManagedDevice -Filter "displayName starts with 'Test-Virtual-Device'" | Remove-MgDeviceManagementManagedDevice
Method 2: Direct Graph API Calls (For Custom Workflows)
If you prefer working directly with the Graph API, you can send POST requests to the https://graph.microsoft.com/v1.0/deviceManagement/managedDevices endpoint. You can use tools like Postman to automate bulk requests, or write a script in your preferred language (Python, C#, etc.) to loop through and create the devices. The payload structure matches the parameters used in the PowerShell script above.
内容的提问来源于stack exchange,提问作者Arun Joseph

