Using PowerShell to find your operating system (OS) and service pack (SP) level

Using PowerShell to find your operating system (OS) and service pack (SP) level

Using PowerShell to find your OS and SP levels

You can use PowerShell to quickly display your server’s OS and SP levels. The following example shows how you how you can use the Get-WmiObject cmdlet to retrieve you server’s name, operating system, x86 architecture type and major service pack level.

# Get Operating System Info
$sServer = "myserver"
$sOS =Get-WmiObject -class Win32_OperatingSystem -computername $sServer

foreach($sProperty in $sOS)
{
   write-host $sProperty.Description
   write-host $sProperty.Caption
   write-host $sProperty.OSArchitecture
   write-host $sProperty.ServicePackMajorVersion
}

 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish