Temporarily enable and disable PowerShell 2.0 on modern Windows systems for legacy installer compatibility (for example, SQL Server 2014 Express setup), without leaving PowerShell 2.0 permanently enabled. This will hopefully get us over the compatibility issues introduced with deprecating a core dependency of some older installers that Microsoft (and others) provide.
This repository provides a guided, interactive workflow that:
- Validates prerequisites and required payload files.
- Builds a local C# helper executable at runtime (source provided).
- Enables PowerShell 2.0 components (GAC + registry) for legacy installers that have PowerShell 2.0 dependencies.
- Disables/removes those components after installation is complete.
The terminal window is designed to stay open while you install the legacy software, and then you can disable PowerShell 2.0 before closing the terminal window. Operations and their success or failure is reported in the terminal window.
If you close the terminal window before disabling PowerShell 2.0 per step 4, you can run the .bat again to disable it.
Usage:
- Download repository files.
- Run
TogglePS2.batas administrator. - Follow on-screen prompts to enable and disable PowerShell 2.0 features in Windows.
- Recommended: Disable PowerShell 2.0 features once you've finished installing the legacy application for security.
Core helper:
TogglePS2.cs(compiled to%ProgramData%\TogglePS2\TogglePS2.exeat runtime, no manual build required)TogglePS2.cscan be inspected with a text or code editor for auditing purposes before deployment.
Payload source:
ps2DLC/(binary and resource DLL payload + legacy scripts)
PowerShell 2.0 was removed from current Windows versions, but some older software installers still expect it. This project enables a controlled, temporary reintroduction and clean removal process to reduce long-term security exposure.
Run TogglePS2.bat as Administrator
|
+--> Require admin rights
+--> Locate .NET 4.x C# compiler (csc.exe)
+--> Validate ps2DLC payload files
+--> Verify .NET Framework 3.5 is installed
+--> Compile TogglePS2.cs -> %ProgramData%\TogglePS2\TogglePS2.exe
|
+--> Prompt: Enable PS2 now? [Y/n]
|
+--> If Yes: helper mode = enable
|
+--> Install DLLs into GAC (x86 + amd64 when applicable)
+--> Install localized resource DLLs for installed/current UI culture + en-US fallback
+--> Write PowerShell registry keys (32/64-bit views as needed)
+--> Repair ACLs if registry access is denied
+--> Verify PS2 registry state
|
+--> Prompt: Disable PS2 later? [Y/n]
|
+--> If Yes: helper mode = disable
|
+--> Delete PowerShell registry keys
+--> Remove DLLs from GAC
+--> Verify removal
The helper installs/removes .dll payloads from:
ps2DLC/Binaries/x86ps2DLC/Binaries/amd64(64-bit OS)ps2DLC/ResourceBinaries/<arch>/<culture>for:- installed UI culture
- current UI culture
en-US
Registry root managed by this project:
HKLM\SOFTWARE\Microsoft\PowerShell\1
Includes key paths such as:
...\PowerShellEngine...\ShellIds\Microsoft.PowerShell...\ShellIds\ScriptedDiagnostics
On 64-bit systems, both native and WOW64 registry views are handled where appropriate.
- Windows (run with elevated Administrator privileges).
- .NET Framework 4.x compiler available at one of:
%SystemRoot%\Microsoft.NET\Framework64\v4.0.30319\csc.exe%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\csc.exe
- .NET Framework 3.5 installed and enabled.
- Repository layout preserved (do not move payload folders unless you also update the scripts).
- Open an elevated Command Prompt or PowerShell window.
- Run
TogglePS2.batfrom the repository root. - Press
Ywhen prompted to enable PowerShell 2.0. - Perform your legacy installer task (example: SQL Server 2014 Express install).
- Return to the prompt and press
Yto disable PowerShell 2.0.
If you press N at the first enable prompt, the prompt will ask whether you want to run a disable remediation step immediately. This helps recover systems where PowerShell 2.0 may already be enabled from a prior interrupted session (or you accidentally close the terminal before disabling PowerShell 2.0).
The compiled helper supports these modes:
enable <ps2DLC folder>disable <ps2DLC folder>install <ps2DLC folder>(GAC only)uninstall <ps2DLC folder>(GAC only)writeRegistry <ps2DLC folder>deleteRegistry <ps2DLC folder>
Example (after batch has compiled helper):
%ProgramData%\TogglePS2\TogglePS2.exe enable "C:\path\to\repo\ps2DLC"Runtime logs are written to:
%ProgramData%\TogglePS2\TogglePS2.log%ProgramData%\TogglePS2\CompileHelper.log%ProgramData%\TogglePS2\EnablePs2.log%ProgramData%\TogglePS2\DisablePs2.log%ProgramData%\TogglePS2\Verify.log
If the batch fails, check these logs first.
Run from an elevated terminal.
Install/repair .NET Framework 4.x Developer/Targeting components so csc.exe is available.
Enable .NET Framework 3.5 Windows feature before enabling PowerShell 2.0 compatibility.
Ensure folder structure remains intact under ps2DLC/Binaries and ps2DLC/ResourceBinaries.
The helper attempts ACL repair automatically, but elevation and local security policy may still block writes/deletes. Review the log files and run in a fully elevated session.
If you skip enable (N), the script will offer a second prompt to run disable as remediation.
- Press
Yto force cleanup/removal of PowerShell 2.0 state. - Press
Nto exit without making changes.
PowerShell 2.0 is legacy software and should not remain enabled longer than required.
Recommended practice:
- Enable immediately before the legacy installer step that requires it.
- Disable immediately after installation completes.
- Keep logs for change/audit tracking if used in managed environments.
TogglePS2.bat: interactive orchestration script.TogglePS2.cs: helper implementation for GAC + registry + verification.ps2DLC/: payload binaries/resources and legacy PowerShell artifacts.ps2DLC/loadGAC.ps1: older/manual approach retained for reference.ps2DLC/regkeysNew/*.reg: registry templates (legacy/reference artifacts).
- This project is based on original Microsoft PowerShell code. (PS2DLC)
- All contents of sub-folder
ps2DLCare Microsoft original files supplied at: Microsoft - You can use those files from Microsoft or from the repo here as long as the file structure matches.