Determine installed PowerShell version

前端 未结 19 2387
半阙折子戏
半阙折子戏 2020-11-22 09:40

How can I determine what version of PowerShell is installed on a computer, and indeed if it is installed at all?

19条回答
  •  北海茫月
    2020-11-22 10:16

    I have made a small batch script that can determine PowerShell version:

    @echo off
    for /f "tokens=2 delims=:" %%a in ('powershell -Command Get-Host ^| findstr /c:Version') do (echo %%a)
    

    This simply extracts the version of PowerShell using Get-Host and searches the string Version

    When the line with the version is found, it uses the for command to extract the version. In this case we are saying that the delimiter is a colon and search next the first colon, resulting in my case 5.1.18362.752.

提交回复
热议问题