What's the update?
Join Vembu Microsoft Ignite 2018 BOOTH #545 September 24–28, 2018 | Orlando, Florida. Register Now and Get a chance to win a Amazon Fire TV Cube       |        All inclusive BC/DR plan with Vembu BDR Suite 4.0 , Register now for the Webinar and understand What’s under the hood with V 4.0       |       

Script to List VM and associated folder and Datastore name

Script to List VM and associated folder and Datastore name

This script is very useful to identify where the VMs are located on the VMware Infra.

Save the below script as .PS1 extension  and Run fron vSphere Power CLI ,  Out Put will be saved on  the Location where we mention  , here it is D:\share\vmname.csv

Connect vCenter

Connect-VIServer (MyvCenter) -User (My Username)-Password (My Password)

Script

Get-VM |

Select Name,

@{N=”Datastore”;E={[string]::Join(‘,’,(Get-Datastore -Id $_.DatastoreIdList | Select -ExpandProperty Name))}},

@{N=”Folder”;E={$_.Folder.Name}} | export-csv D:\share\vmname.csv