News, tips, advice, support for Windows, Office, PCs & more. Tech help. No bull. We're community supported by donations from our Plus Members, and proud of it
Home icon Home icon Home icon Email icon RSS icon
  • Error persists from 1903 w/Win32_Processor class in PowerShell

    Posted on RetiredGeek Comment on the AskWoody Lounge

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

    This topic contains 0 replies, has 1 voice, and was last updated by  RetiredGeek 1 month, 2 weeks ago.

    • Author
      Posts
    • #2018286 Reply

      RetiredGeek
      AskWoody MVP

      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

    Please follow the -Lounge Rules- no personal attacks, no swearing, and politics/religion are relegated to the Rants forum.

    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 Advanced BBCodes, they will be stripped before saving.