0

PowerShell - Add and Remove Users from Active Directory Group

by Jim 28. November 2011 13:17

I had a need to routinely update the members of a security group in Active Directory.  The users in an OU were to be added/removed from the security group on a scheduled basis.

  1. Import-Module ActiveDirectory
  2. Get-ADGroupMember -Identity "Some Security Group" | ForEach-Object { $Member = $_.SamAccountName; Remove-AdGroupMember -Identity "Some Security Group" -Members $Member -Confirm:$false }
  3. Get-User -OrganizationalUnit "Some OU" | ForEach-Object { Add-ADGroupMember -Identity "Some Security Group" -Members $_.SamAccountName }

This could be written into a powershell script file to be run on a schedule.

Tags: ,

PowerShell

0

PowerShell - Disable user access to mailbox while still alllowing mailbox to function.

by Jim Bouse 9. November 2011 15:47

After I migrated my hundreds of users, I had some that were refusing to quit using the old webmail address.  We were retiring the URL and therefore we couldn't just stick it on the new OWA server.  To fix this, I disabled ActiveSync (for phones), OWA, and MAPI (for Outlook).

The code is as follows:

Get-Mailbox -OrganizationalUnit "Some OU" -DomainController "Some DC" | Set-CASMailbox -OWAEnable:$false -ActiveSyncEnabled:$false -MAPIEnabled:$false

A few days after this change, a couple of the stragglers relunctantly started using the new OWA.... and liked it. 

Tags: , , , ,

PowerShell

Powered by BlogEngine.NET 2.5.0.6
Original Design by Laptop Geek, Adapted by onesoft