Automation Library¶
InvocationResult¶
Description¶
Container, that holds the Powershell Execution result and a single returned object.
Generic Parameters¶
- T
Properties¶
Name | Data Type | Static | Readonly | Description |
---|---|---|---|---|
Successful | bool | No | No | If true, then the Powershell was successfully ran and the result was transformed to its expected type (T). |
Result | T | No | No | Object, returned by the Powershell Script and transformed into its expected type (T). |
InvocationResults¶
Description¶
Container, that holds the Powershell Execution result and a list of the returned objects.
Generic Parameters¶
- T
Properties¶
Name | Data Type | Static | Readonly | Description |
---|---|---|---|---|
Successful | bool | No | No | If true, then the Powershell was successfully ran and the results where transformed to the expected type (T). |
Result | Collection | No | No | Multiple objects, returned by the Powershell Script and transformed into their expected type (T). |
Powershell¶
Description¶
Provides Methods to run a Powershell Script (added as a file into your Application) and retrieve its result(s).
Generic Parameters¶
- T
Methods¶
GetResult(string)¶
Description
Runs an uploaded Powershell Script, without input parameters and returns an InvocationResult in the requested format. Use for those Scripts that return one single object.
Return Type : AutomationLib.InvocationResult
Static : No
Namespace : AutomationLib.Powershell
Parameters
Name | Data Type | Description |
---|---|---|
scriptName | string | The Powershell Script to be executed. |
Syntax
string scriptFile = CommonLib.Utilities.GetServerPhysicalPath("~/Resources/MyComputerInfo.ps1");
AutomationLib.Powershell[Domain.ComputerInfo] adapter;
AutomationLib.InvocationResult[Domain.ComputerInfo] result;
result = adapter.GetResult(scriptFile);
if(result.Successful){
Model.MyComputer = result.Result;
ShowMessage("Fetched Information for " + Model.MyComputer.Name); //or result.Result.Name
}
GetResult(string, Dictionary[string, Object])¶
Description
Runs an uploaded Powershell Script, with parameters, and returns an InvocationResult in the requested format. Use for those Scripts that return one single object.
Return Type : AutomationLib.InvocationResult
Static : No
Namespace : AutomationLib.Powershell
Parameters
Name | Data Type | Description |
---|---|---|
scriptName | string | The Powershell Script to be executed. |
scriptArguments | Dictionary | Key-Value dictionary, representing the Powershell script's parameters and their values. |
Syntax
string scriptFile = CommonLib.Utilities.GetServerPhysicalPath("~/Resources/HardDriveInfo.ps1");
AutomationLib.Powershell[Domain.HardDriveInfo] adapter;
AutomationLib.InvocationResult[Domain.HardDriveInfo] result;
Dictionary[string, Object] args;
args.Add("drive", "C");
args.Add("detailed", true);
result = adapter.GetResult(scriptFile, args);
if(result.Successful){
Model.HardDrive = result.Result;
ShowMessage("Free size of Hard Drive "+Model.HardDrive.Name+":\ = " + Model.HardDrive.FreeSizeInGB); // or result.Result.Name & result.Result.FreeSizeInGB
}
GetResults(string)¶
Description
Runs an uploaded Powershell Script, without input parameters and returns an InvocationResult in the requested format. Use for those Scripts that return a collection of similar objects.
Return Type : AutomationLib.InvocationResults
Static : No
Namespace : AutomationLib.Powershell
Parameters
Name | Data Type | Description |
---|---|---|
scriptName | string | The Powershell Script to be executed. |
Syntax
string scriptFile = CommonLib.Utilities.GetServerPhysicalPath("~/Resources/Get-VMs.ps1");
AutomationLib.Powershell[Domain.VM] adapter;
AutomationLib.InvocationResults[Domain.VM] result;
result = adapter.GetResults(scriptFile);
if(result.Successful){
foreach Domain.VM vm in result.Result {
DebugLib.Logger.WriteInfoLine("Virtual Machine "+ vm.Name +" is currently "+ vm.State +".");
}
}
GetResults(string, Dictionary[string, Object])¶
Description
Runs an uploaded Powershell Script, without with parameters and returns an InvocationResult in the requested format. Use for those Scripts that return a collection of similar objects.
Return Type : AutomationLib.InvocationResults
Static : No
Namespace : AutomationLib.Powershell
Parameters
Name | Data Type | Description |
---|---|---|
scriptName | string | The Powershell Script to be executed. |
scriptArguments | Dictionary | Key-Value dictionary, representing the Powershell script's parameters and their values. |
Syntax
string scriptFile = CommonLib.Utilities.GetServerPhysicalPath("~/Resources/Get-VMs.ps1");
AutomationLib.Powershell[Domain.VM] adapter;
AutomationLib.InvocationResults[Domain.VM] result;
Dictionary[string, Object] args;
args.Add("VLANID", 15);
args.Add("detailed", false);
result = adapter.GetResults(scriptFile, args);
if(result.Successful){
foreach Domain.VM vm in result.Result {
DebugLib.Logger.WriteInfoLine("Virtual Machine "+ vm.Name +" is currently "+ vm.State +".");
}
}