VMware Cloud Community
AGFlora
Enthusiast
Enthusiast
Jump to solution

Get the path of a virtual machine

Hi

Need help retrieving the full path of a virtual machine. I've tried examples but could not get it to work.

Any help would be greatly appreciated.

Attached is the code that I need to add the path to.

Thanks

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try it with the attached script.


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

View solution in original post

0 Kudos
11 Replies
LucD
Leadership
Leadership
Jump to solution

That property would be in

$vm.config.files.vmPathName


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

0 Kudos
AGFlora
Enthusiast
Enthusiast
Jump to solution

Hi LucD

That did work as far as the path from the SAN...Thanks. I should of made myself more clear but what I need is the path from the hosts & Clusters or just the DataCenter.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Have a look at .

Is that the "path" you want to see ?


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

0 Kudos
AGFlora
Enthusiast
Enthusiast
Jump to solution

Yes...

Name Path
VM1 datacenter1\folder1\VM1
VM2 datacenter1\folder2\VM2
VM3 datacenter2\folder2\VM3

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try it with the attached script.


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

0 Kudos
adamy
Enthusiast
Enthusiast
Jump to solution

The above examples will all work.

The easiest way is to right click on a VM and choose "Edit Settings" and highlight the Hard disk(one at a time) and look in the upper right of the Window. The full path and the LUN is there.

There are definitly many ways to do this.

0 Kudos
AGFlora
Enthusiast
Enthusiast
Jump to solution

" The easiest way is to right click on a VM and choose "Edit Settings" and highlight the Hard disk(one at a time) and look in the upper right of the Window. The full path and the LUN is there."

This is true if I wanted to just view the path of one vm at a time but I need to view the path(Datacenter\Folder\VM1) of hundreds of vm's in a report.

Thanks for your input.

0 Kudos
adamy
Enthusiast
Enthusiast
Jump to solution

My apologies. After I hit send I realized this was in the VMware vSphereTM PowerCLI community.

Feeling a little stupid here.

0 Kudos
AGFlora
Enthusiast
Enthusiast
Jump to solution

No problem. At least you took the time to try and help. :smileyblush:

Cheers!

0 Kudos
AGFlora
Enthusiast
Enthusiast
Jump to solution

Works great Thanks!.

I've just ordered Hal's book. Have you read it?

Message was edited by: AGFlora

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Yes, I read Hal's book (in fact I was one of the reviewers Smiley Wink )

It will be a great resource when you're going the PowerShell automation way.

Enjoy reading it.


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

0 Kudos