Connecting To Exchange 2010 Using Remote Powershell…

Share & Comment

Remote Powershell (Windows Powershell v2) allows you to connect to an Exchange 2010 organization from a client without having the 2010 management tools installed. You should install Windows Management Framework, which includes Powershell V2 and Windows Remote Management on the client. Download it here. Make sure that you select the correct version (x86 or X64) depending on the client you use.

The clients should be either Vista SP1+ or Windows 2008 SP1+ (x86 or x64). Uninstall any previous versions of Management Framework, if you have it. Instructions are here.

In order to connect to an Exchange 2010 organization from a client with windows management framework installed and no 2010 management tools, we need to follow certain steps.

  • Store the login details of an account that has permissions to remote in. By default, the account that was used to install Exchange 2010 will have the permissions already.
  • If you want another user to be able to initiate a remote powershell session, run Set-User –identity username –RemotePowershellEnabled $True
  • Store the session details in a variable
  • Import the session defined. It will take a while.
  • Run exchange cmdlets / administer the 2010 environment.
  • Once you have finished your work, remove the session.

Let’s get to business. Once the framework is installed, launch Windows Powershell V2

Run $user = Get-Credential to store the login account details. A login box gets prompted, fill in the details and click OK. The account details are now in the variable “user”.

S1

Run $session = New-PSSession -Configurationname Microsoft.Exchange –ConnectionUri http://hew-dc/powershell -Credential $user

S2

This stores the session details including the account used for remoting.

Run Import-PSSession $session to import the server-side powershell session to the client side one.

S3

It takes some time to import the exchange cmdlets. Once it is completed, you can use all exchange cmdlets in your Windows Powershell session.

S4

Run Remove-PSSession $session once you have completed your work.

S5

That’s it for now!

Share & Comment
Subscribe for Updates
Never miss a blog post again

15 thoughts on “Connecting To Exchange 2010 Using Remote Powershell…

  1. cute

    Hi Rajith Jose Enchiparambil,

    when i executed the following command

    "[PS] C:Windowssystem32>$session = New-PSSession -Configurationname http://schemas.microsoft.com/powershell/Microsoft.Exchange -ConnectionUri http://localhost/powershell?serializationLevel=Full -Credential $user"
    i confronted with the following error

    [localhost] Connecting to remote server failed with the following error message : The WinRM client cannot process the r
    equest. The WinRM client tried to use Negotiate authentication mechanism, but the destination computer (localhost:80) r
    eturned an 'access denied' error. Change the configuration to allow Negotiate authentication mechanism to be used or sp
    ecify one of the authentication mechanisms supported by the server. To use Kerberos, specify the local computer name as
    the remote destination. Also verify that the client computer and the destination computer are joined to a domain. To u
    se Basic, specify the local computer name as the remote destination, specify Basic authentication and provide user name
    and password. Possible authentication mechanisms reported by server: For more information, see the about_Remote_Troubl
    eshooting Help topic.
    + CategoryInfo : OpenError: (System.Manageme….RemoteRunspace:RemoteRunspace) [], PSRemotingTransportExc
    eption
    + FullyQualifiedErrorId : PSSessionOpenFailed

    any help regarding this issue would be appreciated

    thanks in advance

    Reply
  2. cute

    Hi Rajith

    Thanks for your reply .yes $user have admin rights.
    Rajith my problem has been resolved by changing this "localhost" to my FQDN in New-PSSession command.

    ————-
    Best regards,
    Cute Devil

    Reply
  3. tuandmk47

    Hi,
    I execute C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -noexit -command “. ‘C:Program FilesMicrosoftExchange ServerV14binRemoteExchange.ps1′; Connect-ExchangeServer -auto” command from javaprogram but fail ‘emoteExchange.ps1” is not recognized as an internal or external command.
    Can you help me?

    Source java

    String[] command = new String[4];

    command[0] = “cmd”;

    command[1] = “C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -noexit -command ”. ‘C:Program FilesMicrosoftExchange ServerV14binRemoteExchange.ps1′; Connect-ExchangeServer -auto”";

    command[2] = “$Temp = ConvertTo-SecureString 123456 -asPlainText –Force”;
    command[3] = “New-Mailbox -Name tuandm -UserPrincipalName tuandm@metfone.com.kh -OrganizationalUnit metfone.com.kh/metfone/Users -Database metfone -Password $Temp | Set-Mailbox -IssueWarningQuota 136314889 -ProhibitSendReceiveQuota 157286400 -UseDatabaseQuotaDefaults $false”;
    Process p = Runtime.getRuntime().exec(command );
    p.getOutputStream().close();

    Reply
  4. Pingback: Connect To Lync Server Using Remote PowerShell | HOW EXCHANGE WORKS

  5. Xtrait

    The following command doesn’t work on my system & network. The first few until
    Run $session.. command works fine.
    BUT the…
    Import-PSSession $session – Doesnt work; Gives the following output in RED.
    ===
    Import-Module : There were errors in loading the format data file:
    Microsoft.PowerShell, , C:\Users\bartender\AppData\Local\Temp\tmp_a60c23a2-372b-4f7e-b49b-372b07fb2421_kxwmt4fr.jo1\tmp
    _a60c23a2-372b-4f7e-b49b-372b07fb2421_kxwmt4fr.jo1.format.ps1xml : File skipped because of the following validation exc
    eption: File C:\Users\bartender\AppData\Local\Temp\tmp_a60c23a2-372b-4f7e-b49b-372b07fb2421_kxwmt4fr.jo1\tmp_a60c23a2-3
    72b-4f7e-b49b-372b07fb2421_kxwmt4fr.jo1.format.ps1xml cannot be loaded because the execution of scripts is disabled on
    this system. Please see “get-help about_signing” for more details..
    Microsoft.PowerShell, , C:\Users\bartender\AppData\Local\Temp\tmp_5315cd91-f04f-429a-a2e6-ce04770076ce_ky1b04bf.i0o\tmp
    _5315cd91-f04f-429a-a2e6-ce04770076ce_ky1b04bf.i0o.format.ps1xml : File skipped because of the following validation exc
    eption: File C:\Users\bartender\AppData\Local\Temp\tmp_5315cd91-f04f-429a-a2e6-ce04770076ce_ky1b04bf.i0o\tmp_5315cd91-f
    04f-429a-a2e6-ce04770076ce_ky1b04bf.i0o.format.ps1xml cannot be loaded because the execution of scripts is disabled on
    this system. Please see “get-help about_signing” for more details..
    At line:3 char:30
    + Import-Module <<<< -Name $name -Alias * -Function * -Prefix $prefix -DisableNameChecking:$disableNam
    eChecking -PassThru -ArgumentList @($session)
    + CategoryInfo : InvalidOperation: (:) [Import-Module], RuntimeException
    + FullyQualifiedErrorId : FormatXmlUpateException,Microsoft.PowerShell.Commands.ImportModuleCommand
    ===

    Reply
      1. Andre

        Even considering that the last activity on this topic was almost one year ago, just for the record, it seems that Xtrait issue can be solved using the following command:

        Set-ExecutionPolicy RemoteSigned

        Reply
  6. Bijo

    Tried to connect with an exchange server in another forest with Authentication kerberos returned with error 1311. Error message:”Connecting to remote server failed with the following error message : WinRM cannot process the request. The following error occured while using Kerberos authentication: There are currently no logon servers available to service the logon request.”
    Have you received this type of error

    Reply
    1. Rajith Jose Enchiparambil

      Hi Bijo,

      WinRM issues are common, run winrm /quickconfig in an elevated command prompt, followed by an iisreset.

      Reply
  7. Pingback: Exchange 2010 Prerequisites « prgmr.io

  8. Pingback: Exchange 2010 Prerequisites « prgmr.io

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>