VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Issue getting orphaned data

Hi,

I am trying to get the orphaned VMX and VMDK from below scripts. script2 has more details but output shows blank. script1 has fewer information, but I am able to get the output.

please help.

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try replacing this line

if($key -notmatch $excludeFilter){

with

if($excludeFilter -eq '' -or ($excludeFilter -ne '' -and $key -notmatch $excludeFilter)){


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

View solution in original post

Reply
0 Kudos
8 Replies
LucD
Leadership
Leadership
Jump to solution

Is script2 producing an empty .xlsx file?
Can you add the -Verbose switch on script2?


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

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Yes LucD,

script2 generates empty .xlsx file.

I am not sure, how to add -verbose to the script2, please help

Is it as below

Get-Datastore | Get-VmwOrphan | Export-Excel $reportlocation -AutoFilter -AutoSize -WorksheetName Orphaned_VMDKs -Verbose

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

LucD,

If I use Get-Datastore | Get-VmwOrphan | Export-Excel $reportlocation -AutoFilter -AutoSize -WorksheetName Orphaned_VMDKs -Verbose

I am getting the output as

pastedImage_0.png

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I mean

Get-Datastore | Get-VmwOrphan -Verbose | Export-Excel $reportlocation -AutoFilter -AutoSize -WorksheetName Orphaned_VMDKs


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

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

LucD,

Please find the verbose log from script2 is attached.

I have recently removed a VM by name demotest1 from inventory and deleted all the files expect demotest1.vmdk

but when a report, still i am not able to get the zombie disk of demotest1

When I run the script1 with versbose, it identifies the zombie disk of demotest1

verbose output of script1

PS D:\Mine\Work Related\myreports4.0\Orphaned_VMDK> .\script1.ps1

VERBOSE: 06-01-2020 14:41:52 Get-View Finished execution

VERBOSE: 06-01-2020 14:41:54 Get-VM Finished execution

VERBOSE: 06-01-2020 14:41:55 Get-Template Finished execution

VERBOSE: 06-01-2020 14:41:56 Get-View Finished execution

VERBOSE: 06-01-2020 14:42:05 Get-VM Finished execution

VERBOSE: 06-01-2020 14:42:07 Get-Template Finished execution

VERBOSE: 06-01-2020 14:42:08 Get-View Finished execution

VERBOSE: 06-01-2020 14:42:15 Get-VM Finished execution

VERBOSE: 06-01-2020 14:42:16 Get-Template Finished execution

VERBOSE: 06-01-2020 14:42:18 Get-View Finished execution

VERBOSE: 06-01-2020 14:42:22 Get-VM Finished execution

VERBOSE: 06-01-2020 14:42:22 Get-Template Finished execution

VERBOSE: 06-01-2020 14:42:24 Get-View Finished execution

and verbose output in script1 xlsx file

pastedImage_0.png

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try replacing this line

if($key -notmatch $excludeFilter){

with

if($excludeFilter -eq '' -or ($excludeFilter -ne '' -and $key -notmatch $excludeFilter)){


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

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

perfect LucD. That worked perfectly Smiley Happy

Thank you very much.

Reply
0 Kudos
FSchleyhahn
Contributor
Contributor
Jump to solution

I am new to Powershell scripting, so I apologize if my question sounds too elementary for this forum.  I am attempting to locate orphan files in my VMware Environment and am trying to use this script.  However, how do I connect to my virtual center server and login?  Do I have to replace any of the text within this script for my environment.  For example, do I have to run this for each datastore and is there a place within the script that I have to type in the datastore name?  Again, I'm sorry for the silly questions.  Any assistance you can provide will be appreciated.  Thank you.

Reply
0 Kudos