7 Replies Latest reply on Jan 6, 2020 3:23 AM by ganapa2000

    Issue getting orphaned data

    ganapa2000 Hot Shot

      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.

        • 1. Re: Issue getting orphaned data
          LucD Guru
          User ModeratorsvExpertCommunity Warriors

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

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          • 2. Re: Issue getting orphaned data
            ganapa2000 Hot Shot

            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

            • 3. Re: Issue getting orphaned data
              ganapa2000 Hot Shot

              LucD,

               

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

               

              I am getting the output as

               

              • 4. Re: Issue getting orphaned data
                LucD Guru
                Community WarriorsUser ModeratorsvExpert

                I mean

                 

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

                 

                Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                • 5. Re: Issue getting orphaned data
                  ganapa2000 Hot Shot

                  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

                  • 6. Re: Issue getting orphaned data
                    LucD Guru
                    vExpertCommunity WarriorsUser Moderators

                    Try replacing this line

                     

                    if($key -notmatch $excludeFilter){

                     

                    with

                     

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

                     

                    Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                    • 7. Re: Issue getting orphaned data
                      ganapa2000 Hot Shot

                      perfect LucD. That worked perfectly

                       

                      Thank you very much.