• Error persists from 1903 w/Win32_Processor class in PowerShell

    Home » Forums » AskWoody support » Windows » Windows 10 » Windows 10 versions – no longer supported » Windows 10 version 1909 – November 2019 Update » Error persists from 1903 w/Win32_Processor class in PowerShell

    Author
    Topic
    #2018286

    Hey Y’all,

    The bug I reported in 1903 with Get-CimInstance -ClassName ‘Win32_Processor’
    returning an incorrect value for the .VirtualizationFirmwareEnabled member persists in 1909.

    I’ve developed some PS code that will work around the problem if you need to test the status of you Virutialization Hardware/Software.

    PowerShell:

    Clear-Host
    $HyperV   = ""
    $HVStatus = ""
    
    $CurOS = Get-CimInstance -ClassName 'Win32_OperatingSystem'
    $WinHome = $CurOS.OperatingSystemSKU -eq 101
    
    $x = Systeminfo  #$x will contain an array of strings!
    
    For ($cntr = 0; $cntr -lt $x.count ; $cntr++) {
    
      If ($x[$cntr].contains('Hyper-V Requirements:')) {
        $HVStart = $cntr
      } # End If
    
    }   # End For
    
    If ($WinHome) {
    
      For ($cntr = $HVStart; $cntr -lt $x.count ; $cntr++) {
    
          If ($x[$cntr].contains(
              'A hypervisor has been detected.')) {
            $HyperV = 'Enabled'
            
          }
    
          If ($x[$cntr].contains(
              'Virtualization Enabled In Firmware: Yes')) {
            $HyperV = 'Enabled'
          }
      
          If ($x[$cntr].contains(
              'Virtualization Enabled In Firmware: No')) {
            $HyperV = 'Disabled'
          }
    
      } #End For
    
      $FeatureName = 'HypervisorPlatform'        
      
    } #End If
    
    Else { #Win 10 Pro or above...
    
      For ($cntr = $HVStart; $cntr -lt $x.count ; $cntr++) {
      
          If ($x[$cntr].contains(
              'A hypervisor has been detected.')) {
            $HyperV = 'Enabled'
          }
          Else { $HyperV = 'Disabled' }
      } #End For
      
      $FeatureName = 'Microsoft-Hyper-V'
    
    } #End Else
    
    $GWOFArgs = @{Online      = $True
                  FeatureName = $FeatureName}
    
    $HVStatus = (Get-WindowsOptionalFeature @GWOFArgs).State
    
    "Hardware Status: $HyperV`nSoftware Status: $HVStatus"
    

    Results:

    Hardware Status: Enabled
    Software Status: Enabled
    

    HTH 😎

    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!
    Computer Specs

    Reply To: Error persists from 1903 w/Win32_Processor class in PowerShell

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: