Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Exchange 2010 Powershell CMDLET

Posted on 2013-11-05
7
Medium Priority
?
579 Views
Last Modified: 2013-11-05
We have an OU with about 40 user but about 35 are non mail enabled (no mailbox or mail contact) accounts. We want to give those 35 users a mailbox now. Is there a quick PS cmdlet that can do this is bulk for all users in that OU. Also the 5 or so users that have mailboxes, shouldn't be affected. Thanks in advance.
0
Comment
Question by:timgreen7077
  • 4
  • 3
7 Comments
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 39625974
Prertty easy for this. Use the folliowing powershell command below.

Construct your CSV like below...

sAMAccountName               Database
jsmith                                    server1\databasename
sthomas                                server1\databasename
etc....

$UserList = Import-Csv "c:\yourCSVfile.csv"
foreach ($Mailbox in $UserList) {
$Mailbox.sAMAccountName
$Mailbox.Database
Enable-Mailbox -Identity $Mailbox.sAMAccountName -Database $Mailbox.Database

Open in new window


This will create mailboxes for all AD users that are in the CSV file that do not already have a mailbox assocaited with it.

Will.
0
 

Author Comment

by:timgreen7077
ID: 39626001
Spec01:
you have an open bracket '{' where does it close, and also, how do I save this so that I can run it.
0
 
LVL 53

Accepted Solution

by:
Will Szymkowski earned 2000 total points
ID: 39626008
Opps! put a "}" on line 6, See below...

$UserList = Import-Csv "c:\yourCSVfile.csv"
foreach ($Mailbox in $UserList) {
$Mailbox.sAMAccountName
$Mailbox.Database
Enable-Mailbox -Identity $Mailbox.sAMAccountName -Database $Mailbox.Database 
}

Open in new window


- Open notepad and then save it in there
- Re-name the file from txt to .ps1.
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 

Author Comment

by:timgreen7077
ID: 39626030
unfortunately I don't know much about powershell. I have  done all that you asked. please instruct on how to run this, or suggest an EMC cmdlet. thanks for your help
0
 

Author Comment

by:timgreen7077
ID: 39626037
this is the error I receive:
The term 'Enable-Mailbox' is not recognized as the name of
the spelling of the name, or if a path was included, verif
At C:\create.ps1:5 char:15
+ Enable-Mailbox <<<<  -Identity $Mailbox.sAMAccountName -
    + CategoryInfo          : ObjectNotFound: (Enable-Mail
    + FullyQualifiedErrorId : CommandNotFoundException
0
 
LVL 53

Assisted Solution

by:Will Szymkowski
Will Szymkowski earned 2000 total points
ID: 39626051
All you need to do is Open the EMS (Exchange Management Shell) navigate to the path where you saved the .ps1 file. from there do the following

If you save the .ps1 file to your local C drive then it will look like below... path is C:\> and \scriptname.ps1 is how to launch it.
Example...
c:\> \scriptname.sp1

If you are launching this from Powershell itself you need to add the snap-in for Exchange. This means Exchange tools also needs to be installed on the machine you are running it from.

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin

If you are not familiar with getting the powershell snap-in to work like shown above just run the script in the Exchange Management Shell.

Will.
0
 

Author Comment

by:timgreen7077
ID: 39626054
Ok, I got it to work. I did this is the EMC and removed the server name/Database and just put the DB only and it worked. Thanks for all your help
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Want to know how to use Exchange Server Eseutil command? Go through this article as it gives you the know-how.
There can be many situations demanding the conversion of Outlook OST files to PST format and as such, there is no shortage of automated tools to perform this conversion. However, what makes Stellar OST to PST converter stand above the rest? Let us e…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question