Created
April 16, 2024 07:59
-
-
Save HighLibrarian/ce3b6c7ba3bf23e8aa99774e70b61057 to your computer and use it in GitHub Desktop.
Add-DevicesToEntraGroup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$GroupId = "" | |
$devicelist = get-content .\devicelist.csv | ConvertFrom-Csv | |
foreach ($device in $devicelist) | |
{ | |
write-host "adding $($device.devicename) to our group" | |
$DeviceID = $device.MicrosoftEntradeviceID | |
$EntraDeviceID = Get-MgDevice -Filter "DeviceId eq '$DeviceID'" | Select-Object -ExpandProperty id | |
New-MgGroupMember -groupid $GroupId -DirectoryObjectId $EntraDeviceID | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment