To use this function add it to the class library file named OrchestratorService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: OrchestratorService.ts
Description: Orchestrator Function to PowerShell Host Invoke Script
Function: invokeScript
let strVirtualServerFQDN = "fqdn.cloudbuildtools.com";
let strPowerShellScript = '';
System.log ("===== Attempting to Ping Virtual Server FQDN = '" + strVirtualServerFQDN + "'");
let objPowerShellInvocationResult = objPowerShellHost.invokeScript(strPowerShellScript);
if (objPowerShellInvocationResult.invocationState == 'Failed')
{
let arrPowerShellInvocationResultErrors = objPowerShellInvocationResult.getErrors();
for ( let iii = 0; iii < arrPowerShellInvocationResultErrors.length; iii++ )
{
let strPowerShellInvocationResultError = arrPowerShellInvocationResultErrors[iii];
System.error ("PowerShell Invocation Error: " + arrPowerShellInvocationResultErrors);
}
}
else
{
let strPowerShellInvocationResultHostOutput = objPowerShellInvocationResult.getHostOutput();
strPowerShellInvocationResultHostOutput = strPowerShellInvocationResultHostOutput.replace(/\n/, "");
System.log("===== " + strPowerShellInvocationResultHostOutput );
objJsonRequest.VirtualServers[i].PingResult = strPowerShellInvocationResultHostOutput;
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
