Jump to content

Recommended Posts

Posted

I want to create a powershell script to enable new users created in AD to have a mailbox on Exchange. I do this for all year 7's through powershell to create mailbox, set features and OWA policy.

 

I can successfully create a powershell script to enable a mailbox on all users in an OU and if they already have one, that's fine it just skips it.

 

However, as part of the new mailbox creation, I disable ActiveSync and also set a OWA Policy.

 

I can set the poweshell script to set the users in the OU with these settings, but it will modify any individual users where I may have previously enabled activesync or set a different policy.

 

Is there a way to apply the policy settings only to new mailboxes which are created so it doesn't revert the settings for any previously changed, and only on those ones newly created?

 

Thanks.

Posted
$csv = Import-Csv "\\svr002\p.howarth$\CTF Gold Form\ParentEmails2017.csv"

 

 

Import-Module ActiveDirectory

 

write-host "Looping through CSV"

$csv | ForEach {

$DisplayName = trimit($_.givenName + "." + $_.sn)

 

$testcount = (Get-ADUser -filter {name -eq $AcName}).count

if ($testcount -lt 1)

{

write-host "Creating user:" $AcName " - " $DisplayName

 

#Do creation and setting stuff

 

}

else

{

#Skip anything to do with this user

}

}

That's a cut down version of mine.

 

Basically, if the user doesn't exist, create them and set ActiveSync, OWA Policy etc. Otherwise skip them completely.

 

Peter

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...