{"id":734,"date":"2016-08-18T06:55:36","date_gmt":"2016-08-18T05:55:36","guid":{"rendered":"http:\/\/virtualworlduk.co.uk\/?p=734"},"modified":"2016-08-18T06:55:36","modified_gmt":"2016-08-18T05:55:36","slug":"powercli-list-of-tagged-vms-datastore-and-host","status":"publish","type":"post","link":"https:\/\/www.virtualworlduk.co.uk\/wordp\/powercli-list-of-tagged-vms-datastore-and-host\/","title":{"rendered":"PowerCli &#8211; List of Tagged VMs, Datastore and Host"},"content":{"rendered":"<p>Here is a relatively simple PowerCli one liner that will list the virtual machines based on a VM Tag assigned to them, along with the Datastore(s) that the VM is on and the Host that the VM is currently on.<\/p>\n<p>The example below assumes that there is a tag with &#8216;Test\/Dev&#8217; in it assigned to the VMs (but this can be changed to whatever you wish), the other item to change would be the exportfolderlocation.<\/p>\n<pre>$test = get-vm -tag *<span style=\"color: #ff0000;\"><em>Test\/Dev<\/em><\/span>* | Select Name, @{N=\"Datastore\";E={[string]::Join(',',(Get-Datastore -Id $_.DatastoreIdList | Select -ExpandProperty Name))}},@{N=\"Folder\";E={$_.Folder.Name}},VMHost | Export-Csv <span style=\"color: #ff0000;\"><em>exportfolderlocation<\/em><\/span>\\Test.csv -NoTypeInformation -UseCulture<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here is a relatively simple PowerCli one liner that will list the virtual machines based on a VM Tag assigned to them, along with the Datastore(s) that the VM is on and the Host that the VM is currently on. The example below assumes that there is a tag with &#8216;Test\/Dev&#8217; in it assigned to the VMs (but this can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":735,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[9],"tags":[],"class_list":["post-734","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vmware"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/posts\/734","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/comments?post=734"}],"version-history":[{"count":0,"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/posts\/734\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/media?parent=734"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/categories?post=734"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/tags?post=734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}