Categories: PowerCLI

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

Rajesh Radhakrishnan

Share
Published by
Rajesh Radhakrishnan

Recent Posts

NAKIVO Backup & Replication v10.8 Released With New Features

Nakivo has released its new Backup and Replication solution Nakivo v10.8, which includes support for…

2 years ago

Oracle Cloud VMware Solution and Features

Oracle Cloud VMware Solution (OCVS) provides a customer-managed, native VMware-based cloud environment hosted in Oracle…

2 years ago

Vinchin Backup and Recovery Review

Vinchin is a professional provider of data protection solutions for enterprises. It provides a series…

2 years ago

VMware Cloud Disaster Recovery (VCDR) Solution Deployment And Configuration Part 2

In my previous blog post, I have explained about VMware Cloud Disaster Recovery (VCDR) Onboarding and…

2 years ago

How to Deploy vRNI Cloud With VMC on AWS

vRealize Network Insight helps you build an optimized, highly available, and secure network infrastructure across…

2 years ago

This SysAdmin Day, WIN with Hornetsecurity!

Can you believe it's here again? SysAdmin Day is back, and with it comes endless gratitude…

2 years ago