Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Load modules/snapins permanently

Status
Not open for further replies.

disturbedone

Vendor
Sep 28, 2006
781
AU
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?
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top