How to get the Windows OS release using powershell?

Viewed 478

I can view my windows os type using the following command

PS C:\> (Get-WmiObject Win32_OperatingSystem).caption

Microsoft Windows Server 2008 R2 Enterprise

Is there a way to get only the OS release like 2008 R2 value using powershell? Thanks!

1 Answers

I would try this: (Get-WmiObject Win32_OperatingSystem).caption.split()[4..5]

Related