PowerCLI

 View Only
  • 1.  How to determine the Windows version (STD-ENT-etc)

    Posted Sep 02, 2015 09:16 AM

    Hi all,

    I have been tasked to gather info about all our Windows machines running in vSphere. Basically the most important thing is to find out the version of Windows we are running, e.g., Windows Server 2008 R2 Enterprise.

    I have attempted several times to run a script to scan host/vcentre to retrieve the info; however the furthest I can get is to get the info from vmtools which does not retrieve the actual version of windows running. I have seen this community thread, but still does not tell me whether Standard or Enterprise is running.

    What is the way of querying the guestOS to retrieve the version?

    PS: I am fine running a powershell script to query AD to get the Windows version; however we have quite a few Windows VMs which are not joined to any domain, hence my limitations scanning AD via powershell and the need to query vCentre.

    Help is much appreciated

    rb51



  • 2.  RE: How to determine the Windows version (STD-ENT-etc)

    Posted Sep 02, 2015 12:15 PM

    Hello,

    Pitty it is, Vmware not gathering that 100% :smileywink:. Because for them it makes no differences.

    so best would be to gather this inside OS going other through the AD with Powershell.

    (gwmi win32_operatingsystem).caption

    That gives me back for example : Microsoft Windows Server 2012 Datacenter

    Best regards

    Max



  • 3.  RE: How to determine the Windows version (STD-ENT-etc)

    Posted Sep 02, 2015 12:59 PM

    Like MadMax01 suggests, run that powershell command via powercli.

    I assume you got a list of vms with windows systems:

    $WindowsVMS = get-view -viewtype virtualmachine -property 'name','guest.guestFamily' -filter @{'guest.GuestFamily'='windowsGuest'}

    Then you invoke script on them . Assuming that in those boxes vmware tools are running of course.

    Build a windows credential set before:

    $credential = get-credential

    foreach ($vm in $WindowsVMS){

    $vm | select name, @{n='Edition';e={(Invoke-VMScript -GuestCredential $credential -ScriptType 'powershell' -ScriptText '(gwmi win32_operatingsystem).caption' -VM $vm.name).ScriptOutput} }

    }

    At the end you willl get nice report like

    Name                                                                  Edition

    ----                                                                  -------

    myVM                                                     Microsoft Windows Server 2008 R2 Enterprise ...

    Assuming that those credentials will match every vm it should be all ok. If not you have to try to run multiple times this script with different versions, and try implementing ifs on fault then use different set of credential.



  • 4.  RE: How to determine the Windows version (STD-ENT-etc)

    Posted Sep 04, 2015 03:13 PM

    thank you both,

    I will try the suggestion and check the outcome.

    thanks again for taking the time to reply to my post.

    rb51