I have looked in multiple locations, however aren't finding what I need. Many scripts will only report on clusters, or will also register the found VMDK files, which is what I don't want.
I would love (as I'm sure others would) to have a report in a .csv format that will scan my ESX 3.5 update 4 servers in my VC 2.5 update 4, and report any .VMDK files that aren't registered in VC.
We have iSCSI, storage as well as local storage being used on each server.
I have searched high and low for something, yet I can't seem to find anything that works.
thanks in advance.
I'm running the script against some of my ESX servers. It processed fine for a number of servers, but it's hanging (not crashing, not failing - just continuing to process w/o any CPU activity) at the following line for a long time - probably 10 minutes at least.
$searchResult = $dsBrowser.SearchDatastoreSubFolders($rootPath, $searchSpec)
The ESX servers are all on the same network and I'm running the script on the VirtualCenter Server.
Is it normal for "SearchDatastoreSubFolders" method to take such a long time? I did browse the datastores through Infrastructure Client and browsing some of the datastores on the same ESX servers took a VERY long time too. Any idea what could be causing it to be so slow?
Thanks,
Chris
Never mind.
After the datastore browser finished searching for files I found that there were a couple thousand old log files in several of the folders in the datastore. I'm guessing this is why it's slow, but it would be nice if I could speed up the search.
Great Script!
Thanks,
Chris
I just wanted to chime in as well and say that this is an amazingly helpful script! It has helped me clear out much space on my datastores. I tore it down and wrote about a half dozen scripts based on it to report on several different types of file-related issues. (Log bloat, random .iso's, etc)
LucD thanks for pointing out those fixes! I recently upgraded to vSphere and was worried about stuff like that breaking.
I've tried to run this with teh updated code for vSphere, but I keep getting this error:
Exception calling "SearchDatastoreSubFolders" with "2" argument(s): "Datastore '[SAN001 (LUN 804)]' is not accessible."
At :line:38 char:55
++ $searchResult = $dsBrowser.SearchDatastoreSubFolders <<<< ($rootPath, $searchSpec)+
This isnt the first lun it hits. I've tried excluding that LUN thinking there was an issue.. but it will just hang up on the next LUN. I checked that I can browse them just fine.
I'm also try to get more info about vmware.vim.viconvert but no luck. Any idea how to convert this script in vb.net using vmware.vim dll as I can't find any resource available? It seems vimapi_40 class from vmware.vim is different from vim25api class for vSphere 4.
Is there a solution now for the "Not initialized: boolean fileOwner" Problem ?
I have excact the same Problem a s mentioned above, even when i set the $searchSpec.Details.FileOwner =$true explicit.
I'm using PowerCLI 4.0 build 162509 on a VSphere environment.
Greetings
Yes, see Yasen's reply in
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks a lot Lucd for this great and very useful script, and Yasen for the work around for vSphere 4 fileOwner bug.
I'm new to powercli and vsphere scripting and I have one question, How can I suppress the ctk.vmdk files from the results, since they aren't actually orphaned vmdks but "change tracking" vmdk files?
Or even better, is it possible to just show the ctk.vmdk file if it is associated with a vmdk file which in turn is orphaned? In the mean time I will keep looking into this and will post any findings I might have...
Thanks in advance,
Kind regards from Brazil,
Paulo
You could try changing the test
if (-not ($arrUsedDisks -contains ($folder.FolderPath + $fileResult.Path))){
into
if (-not ($arrUsedDisks -contains ($folder.FolderPath + $fileResult.Path) -and $fileResult.Path -notmatch "ctk.vmdk ")){
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It worked!
Just had to change the parenthesis to
if (-not ($arrUsedDisks -contains ($folder.FolderPath + $fileResult.Path)) -and $fileResult.Path -notmatch "ctk.vmdk"){
Thanks a lot!
PS. An observation: Yasen workaround also suppressed flat.vmdk from the results (which appeared when the "details" property were left out) maybe there is a way of using "VMware.Vim.VIConvert" as a way of tying ctk with its respective vmdk and that way if there is an orphaned ctk file it would show up on the results. Not that it matters since CTK files ain't that big, but I thought it was worth mentioning.
Hi Luc,
In my environment there is a known problem that a couple of datastore had VMFS crash and none of the esx box could read the contents of datastore. I'm running this script Get-orphaned-vmdk and when this script tries to retrive the contents of the corrupted datastore in the line $dsBrowser.SearchDatastoreSubFolders($rootPath, $searchSpec) the script breaks and halts. Could you please help to skip the datastore where it can't get the contents and continue with remaining datastores?