Function: Get The Current Code Page of a PowerShell Host

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 Get The Current Code Page of a PowerShell Host

Function: getCurrentCodePage

public getCurrentCodePage(objPowerShellHost: PowerShellHost): string {

    let objPowerShellHostConfig: PowerShellHostConfig = objPowerShellHost.getHostConfig();

    let objPowerShellConfigurationParameters: PowerShellConfigurationParameters = objPowerShellHostConfig.configurationParameters;

    let objPowerShellShellCodePage: PowerShellShellCodePage = objPowerShellConfigurationParameters.shellCodePage;

    // e.g. // "IBM437","UTF8"

    if (objPowerShellConfigurationParameters && objPowerShellShellCodePage) {
        // @ts-ignore
        return objPowerShellShellCodePage.name;
    } else {
        return "";
    }
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like