Skip to content

Latest commit

 

History

History

Version-scriptblock-host-problem

Version and scriptblock host problem

When PowerShell.exe is called from PowerShell then it is possible to specify the parameter Command as a script block. But if the parameter Version is also specified then in some hosts this combination fails with a confusing error:

The term '-Version' is not recognized as the name of a cmdlet, function, script file, or operable program.

For example, this command works in any host

    PowerShell {...}

This command works in ConsoleHost but fails in ISE, DefaultHost, and some others including PowerShell jobs

    PowerShell -Version 2 {...}

Scripts


v6-beta.7+ notes

-Version is not supposed to be used for invoking commands.