Jump to content

Script To Add User To Group If User Has Mobile Phone Field Populated?


Recommended Posts

Posted

Hello,

 

I was wondering if anyone had a script that would add and remove users from a specified AD group if the mobile number is populated please?

 

I am trying to tidy our Office 365 signatures. Currently we populate them with phone numbers. If someone doesn't have a mobile phone it displays blank on the signature. Ideally I would like to remove any reference at all. Using the group I can have 2 signature templates.

 

Thanks

Posted

Groups would be MobleUsers and NonMObileUsers...

 

$mobileusers=get-aduser -filter {mobilephone -like "*"}

add-adgroupmember "Mobileusers" -members $mobileusers

$nonmobileusers=get-aduser -filter {mobilephone -notlike "*"}

add-adgroupmember "NonMobileusers" -members $nonmobileusers

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...