VMware

This Question is Answered

2 "helpful" answers available (6 pts)
2 Replies Last post: Nov 4, 2009 8:56 AM by jxstale  

Get-View -ViewType VM list only VM's in a Datastore posted: Nov 4, 2009 8:37 AM

Click to view jxstale's profile Lurker 2 posts since
May 15, 2008

All, I seem to be stumped on something that should be easy. I imagine it stems from a lack of understanding of Get-View.

I am trying to modify the vCheck v3 script from virtu-al. In it he uses the line below to get the views of the VM's. I only want the views of the VM's in a specific datastore. I have been able to modify the rest of the code, but I'm stuck here.

$FullVM = Get-View -ViewType VirtualMachine | Where {-not $_.Config.Template}

I've tried: $FullVM = Get-Datacenter <DATACENTER> | Get-View -ViewType VirtualMachine | Where {-not $_.Config.Template} without luck. Error follows:

Get-View : The input object cannot be bound to any parameters for the command either because the command does not take
pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
At line:1 char:25
+ $FullVM = $DC | Get-View <<<< -ViewType VirtualMachine | Where {-not $_.Config.Template}
+ CategoryInfo : InvalidArgument: (Server Management Denver:PSObject) Get-View, ParameterBindingExcepti
on
+ FullyQualifiedErrorId : InputObjectNotBound,VMware.VimAutomation.Commands.DotNetInterop.GetVIView

Any help would be appreciated, Josh

Click to view LucD's profile Champion 2,431 posts since
Oct 31, 2005
Try this
Get-View -Viewtype VirtualMachine -Searchroot (Get-Datacenter <dcname> | Get-View).MoRef

VMware Developer

SDKs, APIs, Videos, Learn and much more in the Developer community.

Learn More

Developer Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

VMware vSphere

Come witness the next giant leap in virtualization.

Register Today

Communities