Remote Powershell errors

Welcome Forums General PowerShell Q&A Remote Powershell errors

This topic contains 2 replies, has 2 voices, and was last updated by

5 years, 4 months ago.

  • Author
  • #10011

    Points: 1
    Rank: Member

    I'm working on a remote powershell script. I can get the powershell to work with a basic Get-Host, but when I try add the Exchange Snapin I get errors.

    Invoke-Command -ConnectionUri http://RemoteServer:5985/wsman -ScriptBlock { Get-Host} -credential domain\login

    The above works correctly

    When I attempt this code:
    Invoke-Command -ConnectionUri http://RemoteServer:5985/wsman -ScriptBlock {C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -noexit -command ". 'C:\Program Files\Microsoft\Exchange Server\bin\Exchange.ps1'" Get-Host} -credential domain\login

    This is the errors I'm getting from the above script.
    Exception setting "ViewEntireForest": "An Active Directory error 0x80072030 occ
    + CategoryInfo : NotSpecified: (Exception setti... 0x80072030 occ:String) [], RemoteExcep
    + FullyQualifiedErrorId : NativeCommandError

    urred while searching for domain controllers in domain There is no such object on the server.


    At C:\Program Files\Microsoft\Exchange Server\bin\Exchange.ps1:19 char:32

    + $global:AdminSessionADSettings. <<<< ViewEntireForest = $false + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyAssignmentException Any ideas on what I can do to get this script working?

  • #10012

    Points: 0
    Rank: Member

    You will get errors doing it this way
    Remoting against Exchange is an odd beast – it doesn't work in the same way as normal PowerShell remoting

    You need to create a session against the Exchange endpoint. This gives you a restricted & constrained endpoint eg can't use filters 'cos use of literals is not allowed.

    You need to import the session – then you can work with the Exchange cmdlets as if they were local

  • #10097

    Points: 1
    Rank: Member

    The remote server has Exchange Server 2007 not 2010. Not sure if that is part of my issue.

The topic ‘Remote Powershell errors’ is closed to new replies.