Function: PowerShell Command Add-PSSnapin

by Simon Sparks · 23 September 2026

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 Add-PSSnapin

Function: commandAddPSSnapin

public commandAddPSSnapin(objPowerShellHost: PowerShellHost, strSessionId: string): PowerShellRemotePSObject {
    let objPowerShellCommand: PowerShellCommand = this.buildPowerShellCommand("Add-PSSnapin", "");

    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.

You may also like