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 Command Connect-VIServer
Function: commandConnectVIServer
public commandConnectVIServer(objPowerShellHost: PowerShellHost, strSessionId: string, strServer: string, strProtocol: string, strUsername: string, strPassword: string, intPort: number = 443, objCredential: PowerShellRemotePSObject, blnVerbose: boolean, blnDebug: boolean, strErrorAction: string, strErrorVariable: string, strOutVariable: string, strOutBuffer: string): PowerShellRemotePSObject {
let objPowerShellCommand: PowerShellCommand = this.buildPowerShellCommand("Connect-VIServer");
objPowerShellCommand.addParameter('Server', strServer);
objPowerShellCommand.addParameter('Port', intPort);
objPowerShellCommand.addParameter('Protocol', strProtocol);
objPowerShellCommand.addParameter('User', strUsername);
objPowerShellCommand.addParameter('Password', strPassword);
objPowerShellCommand.addParameter('Credential', objCredential);
objPowerShellCommand.addParameter('Session', strSessionId);
if (blnVerbose && blnVerbose == true) {
objPowerShellCommand.addParameter('Verbose', '')
}
if (blnDebug && blnDebug == true) {
objPowerShellCommand.addParameter('Debug', '')
}
if (strErrorAction) {
objPowerShellCommand.addParameter('ErrorAction', strErrorAction)
}
if (strErrorVariable) {
objPowerShellCommand.addParameter('ErrorVariable', strErrorVariable)
}
if (strOutVariable) {
objPowerShellCommand.addParameter('OutVariable', strOutVariable)
}
if (strOutBuffer) {
objPowerShellCommand.addParameter('OutBuffer', strOutBuffer)
}
let objPowerShellSession: PowerShellSession = objPowerShellHost.getSession(strSessionId);
objPowerShellSession.addCommand(objPowerShellCommand);
let blnInPipeline: boolean = objPowerShellHost.inPipeline(strSessionId);
if (blnInPipeline === false) {
let objPowerShellRemotePSObject: PowerShellRemotePSObject = this.invokeCommand(objPowerShellHost, strSessionId);
return objPowerShellRemotePSObject;
}
else if (blnInPipeline === true) {
return null;
}
}Discover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.
