EmmettBrown
Contributor
Contributor

VBS and Guest OS PowerCLI Query

Jump to solution

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!

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
5 Replies
LucD
Leadership
Leadership

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
EmmettBrown
Contributor
Contributor

Thank you, that worked great!

0 Kudos
EmmettBrown
Contributor
Contributor

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

Answered my own question:

Format-Table Name

0 Kudos
LucD
Leadership
Leadership

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
EmmettBrown
Contributor
Contributor

Thank you!

0 Kudos