1 2 3 4 5 Previous Next 72 Replies Latest reply on Oct 21, 2015 6:50 AM by LucD Go to original post
      • 30. Re: orphaned vmdk files script
        godbucket Enthusiast

        I'm not sure, I'm not a scripting guy per se, but I dont think so. I just ran the script that you posted in the beginning of this thread:

        http://communities.vmware.com/servlet/JiveServlet/download/1527048-37989/VMDK-orphaned.ps1

         

        Again, it returns the list of all my hosts and datastores, very slowly, but doesnt display whether I have any orphaned vmdk's or not. And I know for fact that I do because I placed some out there as a test.

         

        What am I doing wrong? Thanks again for your help!!!

        • 31. Re: orphaned vmdk files script
          LucD Guru
          User ModeratorsvExpertCommunity Warriors

          That script doesn't display the $report array either.

          Can you try the script I attached in my previous reply, it has an extra line at the end.

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          • 32. Re: orphaned vmdk files script
            godbucket Enthusiast

            Oh... duh! I am so sorry, I didnt even see that you had attached that. I wasnt looking.

             

            Ok! Wow! Now it runs! Thanks!!!!

             

            However now I see the need to export to a spreadsheet, because it logs tons of servername-ctk.vmdk files, which I know are change-block-tracking files.

             

            So again, please excuse my idiocy, but is there a way to exclude CBT files and export everything into an Excel format?

             

            Man, seriously, thanks again

            • 33. Re: orphaned vmdk files script
              LucD Guru
              Community WarriorsUser ModeratorsvExpert

              Just replace that last line

              $report

              into

              $report | Export-Csv "C:\orphans.csv" -NoTypeInformation -UseCulture
              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
              • 34. Re: orphaned vmdk files script
                godbucket Enthusiast

                Ah, now I understand. I guess I was looking at the script wrong; like I said, I'm not much of a scripting guy.

                 

                Thanks so much!!! This worked great!!! I appreciate all the help!

                • 35. Re: orphaned vmdk files script
                  RenerS Lurker

                  Hey LucD. Did you ever find a resolution to this? I am getting the same error

                   

                  ####

                  Get-View : Cannot validate argument on parameter 'VIObject'. The argument is null or empty. Supply an argument that is not null or empty and

                  then try the command again.

                  At C:\apps\VMWare\Scripts\PowerShell\VMDK-orphaned-2.ps1:15 char:23

                  +     $dsBrowser = Get-View <<<<  $ds.Browser

                      + CategoryInfo          : InvalidData: (:) [Get-View], ParameterBindingValidationException

                      + FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView

                  #######

                  Line 15 = $dsBrowser = Get-View $ds.Browser

                   

                  I too am connecting to vCenter from PowerGUI and from PowerCLI

                   

                  PowerCLI Version

                  ----------------

                     VMware vSphere PowerCLI 5.0 build 435427

                  ---------------

                  Snapin Versions

                  ---------------

                     VMWare AutoDeploy PowerCLI 5.0 build 575

                     VMWare ImageBuilder PowerCLI 5.0 build 575

                     VMware License PowerCLI 5.0 build 395016

                     VMWare vSphere PowerCLI 5.0 build 435427

                   

                  When I run Get-Datastore | %{Get-View $_.Id} | Select Name,Browser

                   

                  I get valid responses back. Sample output..

                   

                  Name                                                                   Browser                                                            

                  ----                                                                   -------                                                             

                  LD9001-01                                                              HostDatastoreBrowser-datastoreBrowser-datastore-3229               

                  LD9001-01                                                              HostDatastoreBrowser-datastoreBrowser-datastore-3229               

                  LD9000-01                                                              HostDatastoreBrowser-datastoreBrowser-datastore-2777               

                   

                  I am running the VMDK-orphaned-2.ps1 script you provided later in this thread (nov 4, 2011).

                   

                  Any thoughts? I have 200 + hosts with over 500+ datastores accross 3 vCenter servers. It has proven impossible to keep up with orphans manually and I can’t seem to get a script running to find them.

                   

                  Thanks a million in advance for your response.

                  • 36. Re: orphaned vmdk files script
                    RvdNieuwendijk Virtuoso
                    vExpertUser Moderators

                    I used Luc's VMDK-orphaned-2.ps1 script to create a new vCheck plugin. But while running the script in our environment, I noticed that it reports Changed Block Tracking *-ctk.vmdk files as orphaned files. So I modified the script to not report the *-ctk.vmdk files, by changing the line:

                     

                    if ($fileResult.Path)


                    into:

                     

                    if ($fileResult.Path -and $fileResult.Path -notlike "*-ctk.vmdk")

                     

                    Hopefully this is also useful for someone else.

                     

                    For more information about Changed Block Tracking see:

                    Changed Block Tracking (CBT) on virtual machines.

                     

                    Message was edited by: RvdNieuwendijk

                    • 37. Re: orphaned vmdk files script
                      godbucket Enthusiast

                      Beautiful. Works great! THANKS! Thanks to you and Luc. I appreciate you guys big time.

                      • 38. Re: orphaned vmdk files script
                        drivera01 Hot Shot

                        how about if we want to only report  out of inventory vms on particular clusters only?

                        • 39. Re: orphaned vmdk files script
                          LucD Guru
                          User ModeratorsCommunity WarriorsvExpert

                          The original script from Raiders of the Lost VMX allows clusters on the entityName parameter and with the WhatIf switch it will only list the VMX files of unregistered VMs it finds.

                          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                          • 40. Re: orphaned vmdk files script
                            drivera01 Hot Shot

                            Hi LucD,

                             

                            Since this is commented out, I would assume that it defaults to FALSE and therefore registers what it finds out of inventory?

                             

                             

                            So since I only want to REPORT any VMDKs and VMs out of inventory and take no other action than reporting. I assume I need to uncomment out this line particular:

                             

                            114# Register-VMX -entityName "MyDatacenter" -whatif:$true



                            Am I missing anything else to acheive what I want to do. Since I plan to only check specific clusters, I will update the entity parameter appropriately..


                            thanks!!

                            • 41. Re: orphaned vmdk files script
                              LucD Guru
                              User ModeratorsvExpertCommunity Warriors

                              That line 114 is a sample call of the function.

                              But your assumption is correct, remove the comment symbol and specify a cluster on the entityName parameter.

                              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                              • 42. Re: orphaned vmdk files script
                                drivera01 Hot Shot

                                Hi LucD,

                                 

                                OK got it,

                                 

                                one question... I ran it and it found items I expected, except for one VM out of inventory. The VM it did not find, there actually is a VM by the same displayname in inventory right now. Did the VM with the same displayname that is in inventory confusing the script?

                                 

                                I plan to remove/delete the out of inventory VM, but this is a real case that appears to happen in my environment.. people leave stuff lying around.

                                • 43. Re: orphaned vmdk files script
                                  LucD Guru
                                  vExpertCommunity WarriorsUser Moderators

                                  Yes, the script is not intelligent enough to find doubles, of which one is registered.

                                   

                                  But that is a good idea !

                                  Something to put on my (long) list of functions I need to write if I find the time

                                  Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                                  • 44. Re: orphaned vmdk files script
                                    drivera01 Hot Shot

                                    So the other scenario that is  seen alot is there may be a sole vmdk in a folder that is out of inventory for a particular VM.  The original VM was svmotioned so it left this vmdk in its original location in a folder on the original datastore.

                                     

                                    As time goes on this type of cruft is left around and forgot about because someone just REMOVED it from the VM and did not DELETE it.

                                     

                                    Do you have any suggestions on how to find these orphan VMDKs just laying around?

                                     

                                    thanks!!