Evan Barre
Evan Barre

Reputation: 85

Copy ad user list to exchange

I have an ou with approximately 100 users in it. Our Exchange server has just been stood up, and we need to copy the AD user accounts to the exchange mailboxes. In essence, create a mailbox and email address for every ad user by copying their login.

I know this can be done through powershell. The command I have so far is:

Import-Module $OUusers = Get-aduser -LDAPFilter '(name=*)' -SearchBase {OU=myou,DC=MYDC,DC=COM} foreach($username in $OUusers) { Enable-Mailbox - identity $username.samaccountname }

But it errors out and says "missing argument" and points to the comma after my OU. What am I doing wrong? Server 2012R2, exch 2016.

Upvotes: 0

Views: 62

Answers (1)

Mathias R. Jessen
Mathias R. Jessen

Reputation: 174485

Qualify the SearchBase OU DN with quotes, rather than with {}:

$OUusers = Get-aduser -LDAPFilter '(name=*)' -SearchBase 'OU=myou,DC=MYDC,DC=COM'

Upvotes: 1

Related Questions