VMware Cloud Community
Guv
Enthusiast
Enthusiast
Jump to solution

Datastore and VM's

Can I get a script which allows me to get a list of VM's on a specfic datastore. I think you use the get-datastore command, but I dont how you would get the list of VM's

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You use the pipeline

Get-Datastore -Name datastorename | Get-VM

____________

Blog: LucD notes

Twitter: lucd22


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

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

You use the pipeline

Get-Datastore -Name datastorename | Get-VM

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
Guv
Enthusiast
Enthusiast
Jump to solution

Can i combine this script or change it, which will give me all my datastores and their VM;s, so basically I can see for all my VM's what datastores they are on. Is there foreach command I have to use

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Something like this you mean ?

foreach($ds in Get-Datastore){
	foreach($vm in ($ds | Get-VM)){
		$vm | Select @{N="VMname";E={$_.Name}},
			@{N="DSName";E={$ds.Name}}
	}
}

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos