locked
ASP.Net connection to Remote Powershell (Exchange 2010 CAS Server) RRS feed

  • Question

  • User-851819717 posted

    Hi,  I'm trying to setup a open a powershell connection to a Exchange 2010 Client Access Server. The snag is that my connections are being denied and I see the follwoing error message "Fatal error : Connecting to remote server failed with the following error message : The WS-Management service cannot process the request. The resource URI (http://schema.microsoft.com/powershell/microsoft.powershell) was not found in the WS-Management catalog. The catalog contains the metadata that describes resources, or logical endpoints. For more information, see the about_Remote_Troubleshooting Help topic., please find a complete error at ErrorLog file"

    The Server I have installed IIS on, has the Exchange Management Tools installed, and I have no problems connection to remote sessions via PS, as I am an Org Admin etc...

    any ideas why?

    Dim q As String = physicalFolder.ToString
    Dim r As String = TextBox1.Text
    script = "D:\PSTMailboxReports\MailboxPSTCheck.ps1" & Space(1) & "-id r" & Space(1) & "-txtpath q"
    conntectTo = "casserver.fqdn"
    user = "domain\username"
    password = "*******"
    Const SHELL_URI As String = "http://schema.microsoft.com/powershell/microsoft.powershell"
    Dim serverURI As New Uri("http://" & conntectTo & ":5985/wsman")
    Dim securepass As New SecureString
    Dim c As Char
    For Each c In password
    securepass.AppendChar(c)
    Next
    Dim remotecred As New PSCredential(user, securepass)
    Dim connectionInfo As New WSManConnectionInfo(serverURI, SHELL_URI, remotecred)
    connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Kerberos
    connectionInfo.ProxyAuthentication = AuthenticationMechanism.Negotiate
    Dim myRunSpace As Runspace = RunspaceFactory.CreateRunspace(connectionInfo)
    Dim psresult As New System.Collections.ObjectModel.Collection(Of PSObject)
    myRunSpace.Open()
    Dim psh As PowerShell = PowerShell.Create()
    psh.Runspace = myRunSpace
    psh.AddScript(script)
    psresult = psh.Invoke
    psh.Dispose()
    myRunSpace.Close()



    Sunday, May 4, 2014 11:57 AM

Answers