Hey all,
I am looking for a script to to help me clean up datastores from left over files. After vmotion sometimes the datastore leaves behind folders with only files with the exts, .hlog .nvram -aux.xml and .vmxf files. I would like to see if it is possible to make a script to help round up and delete these.
Thanks in advance,
Andy
To look at orphaned VMDK files you can have a look at my Orphaned files and folders – Spring cleaning post.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I did review that earlier, but the problem is I am not getting orphaned vmdk files but orphaned files like I said in the original post.
Working on an update of my function that does all files.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Awesome, any timeline on that sorta change? Week, month, 6 month?
Thanks dude!
How about now :smileygrin:
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Wow you are awesome. I got the function up and running and got it working, but does it have a delete switch I can use to delete the files it found?
No, I consciously decided not to include a Delete switch.
There will be another function coming that you can use to create and delete files.
The idea is that the output of Get-VmwOrphan is piped to the to-be function
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
OHHHH You tease me with a perfect clean up method :smileygrin: well any idea how long it will be until the next function is up and going? :smileygrin:
Just curious if there was any update on this?
Thanks dude!
Nearly there :smileyblush:
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
*sits eating popcorn staring with anticipation*
Thank you I am so grateful for this!!
Rofl :smileylaugh:
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hey dude any news on this? I am just out of popcorn and need to know if it is a go or I should make some more.
No Halloween candy left then?
Seriously, the function is there, but as you may have noticed from some recent tweets of mine, I discovered some files for which I don't know if they can be removed safely or not.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sorry I don't use twitter much at all. I looked around your site and not seeing the function so it is still in the production with the potential threat of removing unsafe files?
No problem.
It is taking quite long,
I'll make some changes to bypass the issue for now, and post that here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
In the attached file you'll find two functions, a revised Get-VmwOrphan and the new Remove-VmwFile.
When you try out the Remove-VmwFile function I strongly suggest to first always add the WhatIf switch, that way you are sure the correct files are removed.
Like this
Get-Datastore -Name MyDS | Get-VmwOrphan | Remove-VmwFile -WhatIf
You can also do this in two steps..
Like this for example
Get-Datastore -Name MyDS | Get-VmwOrphan | Export-Csv -Path report-orphan.csv -NoTypeInformation -UseCulture
Import-Csv -Path report-orphan.csv -UseCulture | Remove-VmwFile -WhatIf
You can also combine both with the Tee-Object cmdlet.
Get-Datastore -Name MyDS | Get-VmwOrphan | Tee-Object -Variable buffer | Remove-VmwFile -WhatIf
$buffer | Export-Csv -Path report-orphan.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This is looking excellent! I just wanted to make sure I understand correctly as this is a touchy script. If I run this line:
Get-Datastore -Name MyDS | Get-VmwOrphan | Remove-VmwFile -WhatIf
Nothing will get deleted, because of the whatif tag. If I remove that tag, all will get deleted. And if I run your first example it should look like 2 lines, first use this line:
Get-Datastore -Name MyDS | Get-VmwOrphan | Export-Csv -Path report-orphan.csv -NoTypeInformation -UseCulture
Then if the output looks acceptable, then run this command:
Import-Csv -Path report-orphan.csv -UseCulture | Remove-VmwFile -WhatIf
Again a huge thanks!!
Both your assumptions are correct.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference