VMware Cloud Community
michaelbrux
Contributor
Contributor
Jump to solution

Excluding Site Recovery Manager Placeholders from Get-VM

I am trying to get details for VM's from both my primary virtual center and my backup site.  The backup site has both VM's and SRM placeholders.  A Get-VM returns both VMs and the placeholders.  I would like to only have the details of the VMs.  I thought this statement would get me what I was looking for, but it doesn't return any results.

Get-VM | where ($_.ExtensionData.Config.ManagedBy.Type -ne "placeholderVm")

any help with how to do this would be appreciated.

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Provided you didn't set a custom extension key for SRM placeholders, you could test for the extensionKey property

Get-VM | where {$_.ExtensionData.Config.ManagedBy.extensionKey -notmatch "com.vmware.vcDr"}

An alternative is to query the DB directly, see Determine VMs in a SRM recovery plan using PowerShell


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

View solution in original post

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

Provided you didn't set a custom extension key for SRM placeholders, you could test for the extensionKey property

Get-VM | where {$_.ExtensionData.Config.ManagedBy.extensionKey -notmatch "com.vmware.vcDr"}

An alternative is to query the DB directly, see Determine VMs in a SRM recovery plan using PowerShell


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

Reply
0 Kudos
michaelbrux
Contributor
Contributor
Jump to solution

@LucD

Both our statements worked when I replaced the ( and ) with { and }  

Silly mistake.  Just needed an extra set of eyes to catch that

Get-VM | where {$_.ExtensionData.Config.ManagedBy.extensionKey -notmatch "com.vmware.vcDr"}


Get-VM | where {$_.ExtensionData.Config.ManagedBy.Type -ne "placeholderVm"}



Thanks for the link for the SRM scripting.  Might need that soon, but for now I am just trying to exclude the placeholders from my list of VMs

LucD
Leadership
Leadership
Jump to solution

Just for others looking at this thread, I corrected the error in my code above


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

Reply
0 Kudos