Skip to content

Instantly share code, notes, and snippets.

@HighLibrarian
Created April 16, 2024 07:59
Show Gist options
  • Save HighLibrarian/ce3b6c7ba3bf23e8aa99774e70b61057 to your computer and use it in GitHub Desktop.
Save HighLibrarian/ce3b6c7ba3bf23e8aa99774e70b61057 to your computer and use it in GitHub Desktop.
Add-DevicesToEntraGroup
$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