As a part of the ongoing blog series “Performing Management tasks using Cimcmdlets” we are sharing PowerShell snippets for a few Computer Management tasks.

In this post we will be going over the PS snippets for Operating System Management. The corresponding Visual Basic samples are at: http://msdn.microsoft.com/en-us/library/aa394596(v=vs.85).aspx

1. Determine if a service pack has been installed on a computer:

PS:> # Get Instance of Win32_OperatingSystem

PS:> # Look for ServicePackMajorVersion and ServicePackMinorVersion properties

PS:> Get-CimInstance –ClassName Win32_OperatingSystem –Namespace root/cimv2 | Select ServicePackMajorVersion, ServicePackMinorVersion

2. Determine when the operating system was installed on a computer:

PS:> # Get Instance of Win32_OperatingSystem

PS:> # Look for InstallDate property

PS:> Get-CimInstance –ClassName Win32_OperatingSystem –Namespace root/cimv2 | Select  InstallDate

3. Determine which version of the Windows operating system is installed on a computer:

PS:> # Get Instance of Win32_OperatingSystem

PS:> # Look for Caption and Version properties

PS:> $os = Get-CimInstance –ClassName Win32_OperatingSystem –Namespace root/cimv2 | Select Caption, Version

4. Determine which folder is the Windows folder (%Windir%) on a computer:

PS:> # Get Instance of Win32_OperatingSystem

PS:> # Look for WindowsDirectory property

PS:> $os = Get-CimInstance –ClassName Win32_OperatingSystem –Namespace root/cimv2 | Select WindowsDirectory

5. Determine what hotfixes have been installed on a computer:

PS:> # Get Instance of Win32_ QuickFixEngineering

PS:> # Look for HotFixID property

PS:> Get-CimInstance –ClassName Win32_QuickFixEngineering –Namespace root/cimv2 | Select HotFixID

 

We will be covering other computer management scenarios in our future posts. If you have any questions please feel free to send them to us.

Important links:

              Processes

              Computer Hardware

 

Thanks

Vaibhav Chugh [MSFT]

Standards Based Management