Unable to load Exchange Server powershell library ?

Folks,

Can anyone please share the trick in how to run the Exchange Server 2010 powershell in PowerGUI powershell IDE ?

Because in my WIndows 8.1 the Powershell version is as follows:

Windows PowerShell
Copyright (C) 2014 Microsoft Corporation. All rights reserved.

PS H:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      4.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.34209
BuildVersion                   6.3.9600.17400
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.2

Open in new window


and this is the error that I'm receiving in the Console Window:
Add-PSSnapin : Cannot load Windows PowerShell snap-in 
Microsoft.Exchange.Management.PowerShell.E2010 because of the following error: The 
type initializer for 'Microsoft.Exchange.Data.Directory.Globals' threw an exception.
At line:1 char:258
+ ... t -eq 0 } | %{ Add-PSSnapin $_ }
+                    ~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (Microsoft.Excha...owerShell.E2010:String) [Add-PSSnapin], PSSnapInException
    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand

Open in new window


Any kind of help and assistance would be greatly appreciated.

Thanks
LVL 9
Senior IT System EngineerIT ProfessionalAsked:
Who is Participating?
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
In that case you need to use explicit credentials, like with:
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://outlook.domain.com/PowerShell/ -Authentication Negotiate -Credential (get-credential)
Import-PSSession $Session

Get-ExchangeDiagnosticInfo

Open in new window

This will ask each time for user and password. You can also add a fixed user with (get-credential MyUserName), so only the password is prompted for.
0
 
SreRajCommented:
Hi,

Looks like direct loading of Ex2010 EMS is not supported with 4.0. You may have to establish a remote session to server. Following article has more information on establishing remote session.

https://technet.microsoft.com/en-us/library/dd297932(v=exchg.141).aspx

Following is the discussion on TechNet regarding this.

https://social.technet.microsoft.com/Forums/exchange/en-US/d45f0808-b5fb-469d-8a39-60d1d160c1a0/exchange-2010-pssnapin-exception
0
 
Senior IT System EngineerIT ProfessionalAuthor Commented:
ok, so how do I execute the PowerShell that I got it opened in my PowerGUI IDE on my laptop.
0
WEBINAR: 10 Easy Ways to Lose a Password

Join us on June 27th at 8 am PDT to learn about the methods that hackers use to lift real, working credentials from even the most security-savvy employees. We'll cover the importance of multi-factor authentication and how these solutions can better protect your business!

 
SreRajCommented:
If you have a PowerShell Script which loads Exchange 2010 PowerShell Snap-in in between, you will have to modify the script so that it establishes a remote PS Session with an Exchange Server and then proceeds with the remaining commands.

This limitation only applies Exchange 2010 PS Snap-in. Other PowerShell commands and scripts will work as it is.
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
As said above, https://technet.microsoft.com/en-us/library/dd297932(v=exchg.141).aspx describes it well:
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<FQDN of Exchange 2010 server>/PowerShell/ -Authentication Kerberos
Import-PSSession $Session

Open in new window

If you can use your current credentials, that is from inside your domain.
Be aware that you are executing anything remote, so you should make sure to filter as much data as possible pre displaying. Object serialization for Remoting consumes a lot of resources.
0
 
Senior IT System EngineerIT ProfessionalAuthor Commented:
OK which resources here that is consumed ?

My laptop or the exchange servers ?
Once the script finished it should then released the memory right.
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
All of network, server and client...  But yes, resources are released when finished.
0
 
Senior IT System EngineerIT ProfessionalAuthor Commented:
Ok, so if I want to use the PowerGUI IDE or the builtin Windows powershell ISE, I need to put the two lines below for every command that I want to execute ?

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<FQDN of Exchange 2010 server>/PowerShell/ -Authentication Kerberos
Import-PSSession $Session

Open in new window


is that correct ?

While the disadvantage of running the command with the first two lines above is that the IDE doesn't do Intellisense or autocomplete.
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Correct.
0
 
Senior IT System EngineerIT ProfessionalAuthor Commented:
ok, one last question to clarify.

I've got 4x Exchange Server VMs running as follows:
All of the Exchange Servers is on 2010 SP3:

HT/CAS: Windows NLB
PRODHTCAS01-VM
PRODHTCAS02-VM

Mailbox: No DAG just stand alone servers.
PRODMBX01-VM
PRODMBX02-VM

so which Exchange server address should I put into the URI http://<FQDN of Exchange 2010 server>/PowerShell ?
should I use the NLB Cas Array name ?
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
I assume you'll need to provide the CAS array name.
0
 
Senior IT System EngineerIT ProfessionalAuthor Commented:
somehow it is still doesn't work:

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://outlook.domain.com/PowerShell/ -Authentication Kerberos
Import-PSSession $Session

Get-ExchangeDiagnosticInfo

Open in new window


This is the error:
New-PSSession : [outlook.domain.com] Connecting to remote server outlook.domain.com failed with the following error message : WinRM cannot process the request. The following
error occurred while using Kerberos authentication: The computer outlook.domain.com is unknown to Kerberos. Verify that the computer exists on the network, that the name
provided is spelled correctly, and that the Kerberos configuration for accessing the computer is correct. The most common Kerberos configuration issue is that an SPN with the
format HTTP/outlook.domain.com is not configured for the target. If Kerberos is not required, specify the Negotiate authentication mechanism and resubmit the operation. For
more information, see the about_Remote_Troubleshooting Help topic.

At C:\Users\Admin\AppData\Local\Temp\fdf89f0b-89ed-4ae2-9443-f0532857151e.ps1:2 char:12
+ $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri ht ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
    + FullyQualifiedErrorId : NetworkPathNotFound,PSSessionOpenFailed
Import-PSSession : Cannot validate argument on parameter 'Session'. The argument is null. Provide a valid value for the argument, and then try running the command again.
At C:\Users\Admin\AppData\Local\Temp\fdf89f0b-89ed-4ae2-9443-f0532857151e.ps1:3 char:18
+ Import-PSSession $Session
+                  ~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Import-PSSession], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.ImportPSSessionCommand

The URL outlook.domain.com is the one that I use in the WNLB on the HT/CAS server and also on the Outlook connection.
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
outlook.domain.com is member of your domain? If not, you will have to use a different authentication than Kerberos.
0
 
Senior IT System EngineerIT ProfessionalAuthor Commented:
Well, it is a virtual name for the Windows NLB cluster Virtual IP. For load balancing.
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Does that answer my question?
0
 
Senior IT System EngineerIT ProfessionalAuthor Commented:
There is no computer with the name outlook in the domain.com AD console.
0
 
Senior IT System EngineerIT ProfessionalAuthor Commented:
Thanks !
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.