Getting Feedback from PowerShell Invoke Command RRS feed

  • Question

  • Hi

    I'm using PS2.0 and am running a command on a remote machine. This seems to be running fine, but I can't seem to manage to get any feedback from the command I Invoke.

    How can I get the output of the command? (what is displayed on the screen if I run the command)

    How can I get a List of Errors if any have been raised.


    My Code looks like this....



    myErrors As System.Collections.IList



    Dim ConnectionInfo As WSManConnectionInfo = New WSManConnectionInfo(New Uri(_URI), "", Credentials)



    Dim _Runspace As Runspace = RunspaceFactory.CreateRunspace(ConnectionInfo)


    Dim _PowerShell As PowerShell = PowerShell.Create()


    Dim _command As PSCommand = New PSCommand()


    _command.AddParameter("Identity", <UserDN>)

    _PowerShell.Commands = _command


    _PowerShell.Runspace = _Runspace


    ConnectionInfo.AuthenticationMechanism = AuthenticationMechanism.Kerberos

    Dim _URI As String = String.Format("http://{0}/powershell?serializationLevel=Full", <ServerName>)
    Wednesday, April 13, 2011 2:59 PM

All replies

  • If starting the invoke-command on powershell you are able to asign the result to a new object.

    The call looks like

    $result = invoke-command -computer $computer -scriptblick {<your script to start on remote machine>}



    regards Thomas Paetzold visit my blog on:
    Wednesday, April 13, 2011 5:32 PM
  • Hi Daniel,

    Is your question answered? If so please mark it accordingly. Thanks in advance.


    regards Thomas Paetzold visit my blog on:
    Tuesday, June 14, 2011 7:28 PM