Automation

 View Only
  • 1.  VBS and Guest OS PowerCLI Query

    Posted Jun 17, 2022 04:22 PM

    Hello!

    I am trying to write a PowerCLI query to determine which VMs have VBS disabled and are also running the guest OS "Microsoft Windows Server 2016 or later (64-bit)".

    I thought maybe something like this might work, but it's not returning anything:

    Get-VM | sort | where { $vm.ExtensionData.config.flags.VbsEnabled -eq "False" -and $vm.ExtensionData.Guest.GuestFullName -eq "Microsoft Windows Server 2016 or later (64-bit)" } | Format-Table -AutoSize

    Was I way off? I found another post here that details turning on VBS for a specific VM and it works great. That post also contains a command to check for a specific VM: (Get-VM myVM).extensiondata.config.flags.VbsEnabled but I am having such difficulty coming up with what seems like it should be a simple query.

    Any help is greatly appreciated!



  • 2.  RE: VBS and Guest OS PowerCLI Query
    Best Answer

    Posted Jun 17, 2022 04:35 PM

    Can you try like this?

    Get-VM | 
    where { $_.ExtensionData.config.flags.VbsEnabled -eq $false -and $_.ExtensionData.Guest.GuestFullName -eq "Microsoft Windows Server 2016 or later (64-bit)" } | 
    Sort-Object -Property Name |
    Format-Table -AutoSize


  • 3.  RE: VBS and Guest OS PowerCLI Query

    Posted Jun 17, 2022 04:42 PM

    Thank you, that worked great!



  • 4.  RE: VBS and Guest OS PowerCLI Query

    Posted Jun 17, 2022 05:42 PM

    Is there a way to format the output so it only contains the VM name?

    Answered my own question:

    Format-Table Name



  • 5.  RE: VBS and Guest OS PowerCLI Query

    Posted Jun 17, 2022 05:46 PM

    Sure,like this

    Get-VM | 
    where { $_.ExtensionData.config.flags.VbsEnabled -eq $false -and $_.ExtensionData.Guest.GuestFullName -eq "Microsoft Windows Server 2016 or later (64-bit)" } | 
    Sort-Object -Property Name |
    Select Name |
    Format-Table -AutoSize


  • 6.  RE: VBS and Guest OS PowerCLI Query

    Posted Jun 17, 2022 06:30 PM

    Thank you!