PowerShell Remove Users from Ad Group CSV

Write-Host “Removing users from an AD group.” Import-Csv “Path\to\file\users.csv” | ForEach-Object { $user =$_.email $aduserinfo = Get-ADUser -Filter “EmailAddress -eq ‘$user’” Remove-ADGroupMember -Identity “GroupName” -Members $aduserinfo -Confirm:$false Write-Host “User \$user successfully removed from the AD group” }

The action ‘Set-DistributionGroup’, ‘HiddenFromAddressListsEnabled’, can’t be performed on the object ‘Office of Vice Chancellor – Group’ because the object is being synchronized from your on-premises organization. This action should be performed on the object in your on-premises organization.

Error The action ‘Set-DistributionGroup’, ‘HiddenFromAddressListsEnabled’, can’t be performed on the object ‘Office of Vice Chancellor – Group’ because the object is being synchronized from your on-premises organization. This action should be performed on the object in your on-premises organization. When trying to edit (Hide this group from address lists) property using office365 exchange. You can…