May 17 2013

Powershell WMI query for virtual machine



----------------------------------------------------------------------------
I use a maximum of one Google Ad per post to help offset some of my blog hosting costs.

----------------------------------------------------------------------------

There have been many times when I need to query a machine to see if it is virtual or physical. This quick Powershell WMI query will do the trick:

 

$Result = $null
$bios = gwmi Win32_BIOS -computername computername | Select-Object "version","serialnumber"
$compsys = gwmi Win32_ComputerSystem -computername $DC.Name | Select-Object "model","manufacturer"
if($bios.Version -match "VRTUAL") {$DCVM = "Virtual - Hyper-V"}
elseif($bios.Version -match "A M I") {$DCVM = "Virtual - Virtual PC"}
elseif($bios.Version -like "*Xen*") {$DCVM = "Virtual - Xen"}
elseif($bios.SerialNumber -like "*VMware*") {$DCVM = "Virtual - VMWare"}
elseif($compsys.manufacturer -like "*Microsoft*") {$DCVM = "Virtual - Hyper-V"}
elseif($compsys.manufacturer -like "*VMWare*") {$DCVM = "Virtual - VMWare"}
elseif($compsys.model -like "*Virtual*") {$DCVM = "Virtual"}
else {$DCVM = "Physical"}
write-host $Result




----------------------------------------------------------------------------
I use a maximum of one Google Ad per post to help offset some of my blog hosting costs.

----------------------------------------------------------------------------

January 19 2012

Free online training for System Center 2012 including SCCM

I’ve come across a couple of good free online training websites to update your skills for the System Center 2012 releases, which includes SCCM 2012.

The first is the Microsoft Virtual Academy – http://www.microsoftvirtualacademy.com/ . In their own words – “Improve your IT skill set and help advance your career with a free, easy to access training portal. Learn at your own pace, focusing on Microsoft technologies, gain points and get recognition”. One of the track you can do is “Overview and Infrastructure Changes in SCCM 2012” which has 6 modules covering a lot of the functionality that SCCM 2012 provides. The direct link for this is – http://www.microsoftvirtualacademy.com/tracks/overview-and-infrastructure-changes-in-sccm-2012

The second resource is the Microsoft TechNet Virtual Labs: System Center located at http://technet.microsoft.com/en-us/systemcenter/bb539977. There are 5 SCCM 2012 virtual labs available at the moment. In their own words “TechNet Virtual Labs enable you to quickly evaluate and test Microsoft’s newest products and technologies through a series of guided, hands-on labs that you can complete in 90 minutes or less. There is no complex setup or installation required, and you can use TechNet Virtual Labs online immediately, free”. Personally, I think these are great because you get to use the Microsoft virtual machines to do whatever you want, even if its not the lab material – so it save you time as you don’t need to run up your own test lab.

On a side note there is also the hydration kit available for SCCM 2012 RC 1 – see http://www.deploymentresearch.com/Blog/tabid/62/EntryId/48/The-Hydration-Kit-for-ConfigMgr-2012-RC1-is-available-for-download.aspx

 
 

June 1 2011

SCCM report – count physical vs virtual servers

This report displays the number of servers in the environment and gives a breakdown and percentage view of physical vs virtual:


Declare @Total as int
Declare @Physical as int
Declare @Virtual as int
set @Virtual =
(Select distinct count (*)
From
v_R_System full Join
v_GS_COMPUTER_SYSTEM On v_GS_COMPUTER_SYSTEM.ResourceID =
v_R_System.ResourceID
where v_R_System.Operating_System_Name_and0 LIKE '%server%'
and v_R_System.Client0 = 1
and (v_GS_COMPUTER_SYSTEM.Manufacturer0 = 'Microsoft Corporation' or v_GS_COMPUTER_SYSTEM.Manufacturer0 = 'VMware, Inc.'))
set @Total =
(Select distinct count (*)
From
v_R_System full Join
v_GS_COMPUTER_SYSTEM On v_GS_COMPUTER_SYSTEM.ResourceID = v_R_System.ResourceID
where v_R_System.Operating_System_Name_and0 LIKE '%server%'
and v_R_System.Client0 = 1 )
set @Physical = (select @Total - @Virtual)
Select @Physical as 'Physical servers',
@Virtual as 'Virtual servers',
@Total as 'Total servers',
(select (@Virtual * 100) / @Total) as 'Percentage (%) that are virtual'