Hi,
Since Get-localgroupmember -Group "administrators"
returns only local users, there are no domain users or groups in your local administrators group. You have to run your script as administrator or you'll see the "Access denied" error.
If you want to run Remove-LocalGroupMember on remote computers, you can try Invoke-Command like below
$userlist=import-csv 'D:\powershell test\testremove.CSV'
Invoke-Command -ComputerName $computer -ScriptBlock{ Remove-LocalGroupMember -Group administrators -Member $using:userlist.samaccountname } -Credential ''
Before using Invoke-Command to run commands on a remote computer, read about_Remote.
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.