Execute Method
Execute a command on the remote PowerShell Server.
Syntax
procedure Execute(Command: String);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 component 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