Skip to content

PowerShellConnection Class ​

Definition ​

Wrapper for using the System.Management.Automation.PowerShell object and management of a RunSpace

  • Namespace: JASE.Automation
  • Assembly: JASE.Automation.dll

Constructors ​

NameDescription
PowerShellConnection()Create Connection
PowerShellConnection(string computer)Create Connection to a specific remote computer
PowerShellConnection(string computer, PSCredential credentials)Create Connection to a specific remote computer with Credentials
PowerShellConnection(string computer, string username, string password)Create Connection to a specific remote computer with UserName and Password

Properties ​

NameDescription
Path
Session

Methods ​

NameDescription
void AddModule(string module)
ScriptBlock ConvertStringToScriptBlock(string script)Converts a string to a PowerShell ScriptBlock object
bool CopyFiles(string source, string destination, string session = null)Use PowerShell to copy files between source and destination locations
PSCredential CreateCredentials(string username, string password)Create PowerShell credentials using usernname and password
bool CreateDirectory(string path)Create a Directory using PowerShell
void Dispose()Dispose() calls Dispose(true) and GC.SuppressFinalize
PSResult Execute(string command, IEnumerable<PSParameter> parameters = null)Execute a command within the PowerShell session
object GetVariable(string name)Get the current value of a variable within PowerShell session
ReadOnlyCollection<PSResult> History()History of Command execution and results
bool RemoveVariable(string name)Remove a variable from the PowerShell session
string SetPath(string path)
bool SetVariable(string name, object value)Set the value of a variable in the PowerShell session
bool TestPath(string path)