VMware Cloud Community
EmmettBrown
Contributor
Contributor
Jump to solution

VBS and Guest OS PowerCLI Query

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!

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
5 Replies
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
EmmettBrown
Contributor
Contributor
Jump to solution

Thank you, that worked great!

Reply
0 Kudos
EmmettBrown
Contributor
Contributor
Jump to solution

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

Answered my own question:

Format-Table Name

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
EmmettBrown
Contributor
Contributor
Jump to solution

Thank you!

Reply
0 Kudos