Как найти версию Windows из командной строки PowerShell

Как я могу найти, какую версию Windows я использую?

Я использую PowerShell 2.0 и попробовал:

PS C:\> ver
The term 'ver' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify tha
t the path is correct and try again.
At line:1 char:4
+ ver <<<< 
    + CategoryInfo          : ObjectNotFound: (ver:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Как мне это сделать?

106
задан Peter Mortensen 25 March 2019 в 17:46
поделиться

1 ответ

[решенный]

#copy all the code below:
#save file as .ps1 run and see the magic

 Get-WmiObject -Class Win32_OperatingSystem | ForEach-Object -MemberName Caption
 (Get-CimInstance Win32_OperatingSystem).version


#-------------comment-------------#
#-----finding windows version-----#

$version= (Get-CimInstance Win32_OperatingSystem).version
$length= $version.Length
$index= $version.IndexOf(".")
[int]$windows= $version.Remove($index,$length-2)  
$windows
#-----------end------------------#
#-----------comment-----------------#
0
ответ дан 24 November 2019 в 03:44
поделиться
Другие вопросы по тегам:

Похожие вопросы: