I think I found solution, it requires to be AzureAD in the name of the account:
Remove-LocalGroupMember -Group $administratorsGroupName -Member AzureAD\intunetest5 -Confirm:$False
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
when we enroll computer manually to Intune and Azure AD using Settings > Accounts... our account is added to Administrators group and it becomes local admin on the machine.
I would like to remove that account from Administrators group using powershell script in Endpoint analytics > Proactive remediations.
Script successfully removes all accounts from Administrators group except the default, Administrator and AzureAD default accounts with SIDs(that is what we want).
But, it is not able to remove AzureAD\intunetest5 account, error "Principal Intunetest5 was not found"
However, if I run script locally on that computer it removes it successfully.
From Intune logs:
<![LOG[error from script =Remove-LocalGroupMember : Principal Intunetest5 was not found.
At C:\Windows\IMECache\HealthScripts\2c2ccb13-58f8-41ea-bb92-e8ea3e96450b_4\detect.ps1:48 char:32
Did anyone have similar issue?
Thanks
I think I found solution, it requires to be AzureAD in the name of the account:
Remove-LocalGroupMember -Group $administratorsGroupName -Member AzureAD\intunetest5 -Confirm:$False