Friday, May 8, 2015

#67 : Get Windows Operating System Name and Version

Sometimes, we need to know the Operating system name and version for troubleshooting and sometimes we need to run specific code for specific version. With Powershell, this is very simple.

$OS_VERSION=$(Get-WmiObject -Class Win32_OperatingSystem).Version
$OS_NAME=$(Get-WmiObject -class Win32_OperatingSystem).Caption

echo "Version : $OS_VERSION"
echo "Version : $OS_NAME"


Hope, this was simple and useful for your scripts.
Enjoy scripting!!

No comments:

Post a Comment

#112: How to handle xml document in Powershell?

 In PowerShell, you can handle XML data using various cmdlets and methods provided by the .NET Framework. Here's a basic guide on how to...