VMware Cloud Community
mcsaki
Contributor
Contributor
Jump to solution

Orphaned VM's, getting the folder Size from path, VMX

Hi everyone,

I am running the latest script in this thread: (I think ver 4): Find unregistered virtual machines

I want to run some metrics on the servers the script runs on. Essentially I want to add the resources these orphaned VM's take up in a csv file. The script needs to note down the size of the folder where the VMX is found. I'm not sure how to do that with this script.

Any help is appreciated!

Thanks,

Mike

32 Replies
mcsaki
Contributor
Contributor
Jump to solution

They are VMFS, as for the Itemtype I'm not too sure. The script says File under that category. PSISContainer is False

0 Kudos
LucD
Leadership
Leadership
Jump to solution

I'm at my wits end I'm afraid.

With the script you attached earlier, the script works perfectly for me.

I would need to do e debugging sessions to analyse where the issue is located.

But since I can't seem to replicate the issue you are having, that will be difficult


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

0 Kudos
mcsaki
Contributor
Contributor
Jump to solution

Can you send the script you are using? Maybe I'm still adding something wrong. I'll try to see if I can find anything.

Thanks a lot for your help regardless!

0 Kudos
mcsaki
Contributor
Contributor
Jump to solution

Hi LucD,

I am getting a different error now:

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That seems to indicate that one of the datastores can not be found?!?

The script tries to obtain the datastore from the path to the VMX file.

For example, for "[DS1] TestVM/TestVM.vmx", the datastorename would be DS1.

Are there any VMX files in the resulting CSV, that have a datastore in the path that can not be retrieved with Get-Datastore?


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

0 Kudos
mcsaki
Contributor
Contributor
Jump to solution

I can't check all vmx files, however they are in the proper datastore. I'm able to retrieve all the datastores and trace the vmx files using the path. It's accurate. 

0 Kudos
LucD
Leadership
Leadership
Jump to solution

I added some debugging lines in the 2nd part of the script (attached).

What does this show (i don't need all the output, just some representative loops through the 2nd part of the script).


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

0 Kudos
mcsaki
Contributor
Contributor
Jump to solution

It seems to be working! I added a pause since it was going through very fast and then started displaying the report, but here is the output:

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That seems to indicate that your copy of the script had an issue.
You can remove the Write-Host lines from the 2nd part of the script, and export the $newReport array to a CSV file.

Then it should be working.


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

0 Kudos
mcsaki
Contributor
Contributor
Jump to solution

Hi LucD,

I tried running the script again and it seems to be on/off.

It does not work if i try to export it to a file. I added the Write-Host back in and here's what I got:

0 Kudos
LucD
Leadership
Leadership
Jump to solution

I think I know what the problem is, your VM files are 2 levels deep, instead of the regular 1 level.

These are apparently all VMs created with LabManager.

Is that correct?


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

LucD
Leadership
Leadership
Jump to solution

Ok, try running with this updated version.


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

mcsaki
Contributor
Contributor
Jump to solution

It worked! I'm going to try and get the folder values in GB.

Thanks  so much LucD!

0 Kudos