|

Script to get OS version

Share

I am surprised by the number of organizations still managing their many devices without a system management tool. It may not be the most efficient way, but over the years they have developed processes and procedures to manually (or semi-manually) keep up the environment running.

With the introduction of Windows 10 these manual processes have been put to the test in order to keep up with the new Windows as A Service cadence. This is especially true or organization that have opted to stay with Windows 10 Pro.

One question I have been asked often is if there is an easy way to gather the systems’s Windows 10 version and edition from the environment.

I think one of the simplest ways is using the Windows Management Interface Command ( wmic ) which is a command prompt tool available in most / all Windows OS platforms, that returns information about the system you are running it on. wmic has been around for many years, and is well know to savy system administrators. There is a lot you can do with it.

The command-line

The following command-line:

wmic os get Caption, Version, BuildNumber, OSArchitecture,CSname

produces the following output to the console (screen):

BuildNumber  Caption                          CSName   OSArchitecture  Version

17134        Microsoft Windows 10 Enterprise  XY6V356  64-bit          10.0.17134

Finally the following command-line creates a CSV file with the information above stated and write to a file with >> drive:\filename.csv .

wmic os get Caption, Version, BuildNumber, OSArchitecture,CSname /format:csv >> c:\infofile.csv

It will look something like this:

Node,BuildNumber,Caption,CSName,OSArchitecture,Version
 DELL-E6330-01,18362,Microsoft Windows 10 Pro,DELL-E6330-01,64-bit,10.0.18362

You can change the file name to a shared drive and it will create an inventory of all of your devices.

Node,BuildNumber,Caption,CSName,OSArchitecture,Version
Y6V356 ,17134,Microsoft Windows 10 Enterprise,Y6V356,64-bit,10.0.17134
Node,BuildNumber,Caption,CSName,OSArchitecture,Version
DELL-E6330-01,18362,Microsoft Windows 10 Pro,DELL-E6330-01,64-bit,10.0.18362 

After you have ran it across your devices, you can import that file into excel and delete duplicates, format as needed, analyze and then take action as needed.

Other ideas:

How to get a list of installed software on the device:

wmic product get name,version

Want to get a list of all users to a csv file or table?

wmic  useraccount list full /format:csv
wmic  useraccount list full /format:table

As you can see, there are many options and info available with the wmic command-line utility. Below are some resources you can read more about this powerful utility:

Similar Posts