Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Load modules/snapins permanently

Load modules/snapins permanently

Load modules/snapins permanently

On a W2K3 member server we had a script that created new users in E2K7 (and therefore AD). We upgraded to E2K10 and the script stopped. I built a new W2K8R2 member server, installed E2K10 tools, modified the script slightly and it worked (after a tweak).

The tweak I had to make was to have the lines
Import-Module ActiveDirectory
Add-Pssnapin Microsoft.Exchange.Management.PowerShell.E2010

The first allowed the dsmod command to work to work. The second was to allow the new-mailbox command to work. With these lines it works fine. The thing is these lines weren't required when the script was on W2K3/E2K7.

When I run this script the first time it works fine but the second time it gives me the error
Add-Pssnapin : Cannot add Windows PowerShell snap-in Microsoft.Exchange.Management.PowerShell.E2010 because it is already added.
If I restart the server then this goes away as the snap-in gets unloaded.

The question is, if possible, how can I have the Exchange snap-in (and any others) loaded permanently or have the script add it only if it's not already loaded?

RE: Load modules/snapins permanently

Cancel this. It's designed to use Encrypted RunAs (http://www.wingnutsoftware.com) and it's the ERAS shortcut that loads the Exchange Powershell that enables the .ps1 script file to work.  

RE: Load modules/snapins permanently

Also, you shouldn't be loading the Exchange 2010 snapin. That completely bypasses RBAC security. You should be establishing a remote session instead.

Do you have your Tek-Tips.com Swag? I've got mine!

Stop by the new Tek-Tips group at LinkedIn.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close