IP*Works! SSH V9 - Online Help
IP*Works! SSH V9
Questions / Feedback?

Execute Method

Execute a command on the remote PowerShell Server.

Syntax

psclient.execute(command, [callback])

Callback

The 'callback' parameter specifies a function which will be called when the operation completes (or an error is encountered). If the 'callback' parameter is not specified, then the method will block and will not return until the operation completes (or an error is encountered).

The callback for this method is defined as:

function(err){ }

'err' is the error that occurred. If there was no error, then 'err' is 'null'.

'err' has 2 properties which hold detailed information:

err.code
err.message

Remarks

The Command parameter contains the text of the command to execute. If the connection to the server hasn't been explicitly made before with the SSHLogon method, then the class will establish a new connection, execute the command and immediately close it. If a connection has been previously established, it will still be open when the command is done.

If the command returned any errors, an exception will be raised with the error information returned by the server.

Example: Executing a command and iterating over the results

Psclient1.Execute "ls C:\"

For i = 0 To Psclient1.PSObjectCount - 1
    Psclient1.PSObjectIndex = i
    For j = 0 To Psclient1.PSObjectPropertyCount - 1
        If Psclient1.PSObjectPropertyName(j) = "Name" Then
            Text1.Text = Text1.Text & Psclient1.PSObjectPropertyValue(j) & vbCrLf
        End If
    Next
Next

 
 
Copyright (c) 2017 /n software inc. - All rights reserved.
Build 9.0.6240.0