Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Creating Mailboxes and Setting AD Properties in Powershell

$
0
0

We're on a hybrid email environment.

I've managed to create a Powershell script to create bulk mailboxes (see script below). But I needed to add an additional proxy email address to it but the script that I've made is not allowing me to. Instead I've created another script that adds the additional email addresses (proxy addresses). Also, to make my job easier, I'm trying to find a way to automatically tick the following properties in active directory within the script.

  • Check - Account is disabled
  • Check - Password never expires

The end effect, is it possible to combine all these into 1 script to automate all these tasks? Thanks once again for your help and I look forward to your reply.

Script to Bulk Add Mailboxes

$users = Import-CSV "C:\Users\torrest\Documents\I.T. Repository\Powershell\Scripts\CSV\SharedMailboxList.csv" 
$users| foreach {
$Password = convertto-securestring $_.password -asplaintext -force
New-RemoteMailbox -Name $_.Name -PrimarySMTPAddress $_.PrimarySMTPAddress -OnPremisesOrganizationalUnit

$_.OnPremisesOrganizationalUnit -UserPrincipalName $_.UserPrincipalName -Alias $_.Alias -DisplayName $_.DisplayName -

RemoteRoutingAddress $_.RemoteRoutingAddress -Password $Password –ResetPasswordOnNextLogon:$false
}

Script to Add Proxy Addresses

$list = import-csv "C:\Users\torrest\Documents\I.T. Repository\Powershell\Scripts\CSV\ProxyEmailAddressAddition.csv"
foreach ($a in $list)
{
$targetuser = $a.Mailbox
$targetaddr = $a.NewEmailAddress

get-aduser -filter {mail -like $targetuser} | set-aduser -add @{proxyaddresses=$targetaddr}
}






Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>