disturbedone
Vendor
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?
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?