It's quite simple to find the name of the operating system with PowerShell.  The WMI cmdlet GetWmiObject contains a lot of useful information about the environment, there's numerous ways to use the object but here's one method:

 (Get-WmiObject Win32_OperatingSystem).name  

This should work straight away but for me I encounted some "weird" issues which suggested there were some problems with my Windows installation and specifically the WMI repository.  Intially I received the following error: running the above command:

 InvalidOperation: (:) [Get-WmiObject], COMException  

Here's what I did to fix the problem:

 

  • Acertain if there is a problem with WMI (C:\Windows\System32\wbem)
    winmgmt /verifyrepository
  • This this should show you if there are any issues with WMI, this came back and said everything was ok when clearly it wasn't!...
  • I rebuilt the repository in PowerShell
     winmgmt /resetrepository  
     Restart-Service winmgmt -Force  

 


Comments

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading



Calendar

«  May 2012  »
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910
View posts in large calendar

Recent Comments

Banners

Theme Grabber
Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2012 Dan Gibbons .Net Developer