PowerShell determines the operating system version command

Source: Internet
Author: User

PowerShell Missionary original article. Allowed to be reproduced in 2015-12-15, but must retain the name and provenance, otherwise be held liable


A preface

Judging the operating system version, is an old topic, bat, VBS, there are examples, this is not an important issue, I feel not worth writing posts.
But pinch, with the win version of the increase, PowerShell version fragmentation more and more serious, so "use PowerShell to determine the operating system version"
It's getting more and more important. In other words, you must determine the operating system version before using a slightly biased PowerShell command. Or, strongly
We recommend that you use the latest version of the win server, the win client to play PowerShell.


Advantages and disadvantages of the two methods

Cmd+ver Method:
There seems to be no server or client.


WMI Method:
Recommended


SystemInfo Method:
There is a difference between the command of the Chinese system and the English system.

Three jade flowers on the command


Judging Win7
(Cmd/c ver) [1]-like "*6.1*"
Or
(Systeminfo/fo CSV | convertfrom-csv). ' Os name '-like ' *7* "
PowerShell Missionary original article. Allowed to be reproduced in 2015-12-15, but must retain the name and provenance, otherwise be held liable
English system by:
(Systeminfo/fo CSV | convertfrom-csv). ' Os name '-like ' *7* '
or using the WMI method:
(Get-wmiobject-class Win32_OperatingSystem). Caption-like "*7*"


Judging win8,win8.1
(Cmd/c ver) [1]-like "*6.3*"
Or
(Systeminfo/fo CSV | convertfrom-csv). ' Os name '-like ' *8* "
English system by:
(Systeminfo/fo CSV | convertfrom-csv). ' Os name '-like ' *8* '
or using the WMI method:
(Get-wmiobject-class Win32_OperatingSystem). Caption-like "*8*"


Judging Win10
(Cmd/c ver) [1]-like "*10.*"
Or
(Systeminfo/fo CSV | convertfrom-csv). ' Os name '-like ' *10* "
English system by:
(Systeminfo/fo CSV | convertfrom-csv). ' Os name '-like ' *10* '
or using the WMI method:
(Get-wmiobject-class Win32_OperatingSystem). Caption-like "*10*"


Judging win2012 R2
(Cmd/c ver) [1]-like "*6.3*"
Or
(Systeminfo/fo CSV | convertfrom-csv). ' Os name '-like ' *2012 r2* "
English system by:
(Systeminfo/fo CSV | convertfrom-csv). ' Os name '-like ' *2012 r2* "
or using the WMI method:
(Get-wmiobject-class Win32_OperatingSystem). Caption-like "*2012 r2*"

PowerShell determines the operating system version command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.