You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I work in education so might be a bit different in my needs but I made a couple of adjustments that I thought I would share, but I don't know how to do pull requests, etc.
We needed to add to multiple groups (dependent on being a staff device or pupil device) - nothing major and might not affect businesses in the same way.
# Add the device to the specified AAD group
if ($AddToGroup) {
foreach ($ADGroup in $AddToGroup){
$aadGroup = Get-MgGroup -Filter "DisplayName eq '$ADGroup'"
if ($aadGroup) {
$autopilotDevices | ForEach-Object {
$uri = "https://graph.microsoft.com/beta/devices?`$filter=deviceId eq '" + $_.azureActiveDirectoryDeviceId + "'"
$aadDevice = (Invoke-MgGraphRequest -Uri $uri -Method GET -OutputType PSObject -SkipHttpErrorCheck).value
if ($aadDevice) {
Write-Host "Adding device $($aadDevice.displayName) to group $ADGroup"
New-MgGroupMember -GroupId $aadGroup.Id -DirectoryObjectId $aadDevice.id
}
else {
Write-Error "Unable to find Azure AD device with ID $($aadDevice.deviceId)"
}
}
Write-Host "Added devices to group '$ADGroup' ($($aadGroup.Id))"
}
else {
Write-Error "Unable to find group $ADGroup"
}
}
} #to deal with the array
Just might be useful for someone else hopefully! Please delete or move as not an issue!
The text was updated successfully, but these errors were encountered:
Hi,
I work in education so might be a bit different in my needs but I made a couple of adjustments that I thought I would share, but I don't know how to do pull requests, etc.
We needed to add to multiple groups (dependent on being a staff device or pupil device) - nothing major and might not affect businesses in the same way.
I altered the following:
[Parameter(Mandatory = $False, ParameterSetName = 'Online')] [String[]] $AddToGroup = "", #(to accept an array)
and:
Just might be useful for someone else hopefully! Please delete or move as not an issue!
The text was updated successfully, but these errors were encountered: