Previous Topic: Connect-XO - Connect PowerShell to a Control ServiceNext Topic: Disconnect-XO - Disconnect from a Running Control Service


Connect PowerShell to a Control Service using a Script

You can avoid the need to manually enter your credentials into the PSCredentials dialog by encrypting your password and running it as an object.

To encrypt your password and run it as an object

Enter the following commands, using your password where indicated, and run it once:

read-host -assecurestring | convertfrom-securestring | out-file C:\ securestring.txt <password>
$pass = cat C:\securestring.txt | convertto-securestring
$mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist <domain\user_name>, $pass
Connect -XO [-Host] <String> $mycred [[-Protocol][<String>]] [[-Port] [<String>]]

The outcome is the same as if you used a standard connection:

Connecting...
<IP Address> connected! 

For more information, refer to the PowerShell documentation or search the internet.