running remote commands

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Francis Francis 3 weeks, 4 days ago.

  • Author
    Posts
  • #74012
    Profile photo of Francis
    Francis
    Participant

    Just completed the MVA Powershell class (topic 9) about loading remote powershell commands to your workstation/tablet, etc. Can very easily get ActiveDirectory management to function even with a prefix, but unable to load powershell for Exchange. I know this is a pssnapin so I have to use the add-pssnapin. When I query the Exchange server with "invoke-command -computername exchange2010 {get-pssnapin -registered}" the snapins are returned. If I try to load the snapins like I did with a module (invoke-command -computername exchange2010 {add-pssnapin microsoft.exchange.management.powershell.e2010}) the command seems to run but I do not have any of the Exchange powershell commands. What am I missing?

  • #74018
    Profile photo of Stephen Valdinger
    Stephen Valdinger
    Participant

    You are going to want to use a Session for this

    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http://exchange.fqdn/powershell" -Authentication Kerberos
    
    Import-PSSession -Session $Session

    When you are done, you can do this to clean up the session connection:

    Get-PSSession | Remove-PSSession
    • #74137
      Profile photo of Francis
      Francis
      Participant

      Ahh.....Was creating a powershell session with the server but not in this way. I was creating the session with the server and trying to use load-pssnapin. Thank for pointing out the correct way.

You must be logged in to reply to this topic.