First off, kudos for a great script go to MorDrakka. Even though it does show snapshots as well as orphaned, which requires some manual sorting to verify what is what, it's still very helpful.
I need to add the size of the found file to this script, but have been unsucessful so far. Can anyone assist?
Thanks.
There are several ways this can be achieved. Here's one:
To this section of the .ps1 script:
...
$file.Name = $fileResult.Path
$strFilename = $file.Name
...
Add this line:
$strLength = $fileResult.Length
To this section of the .ps1 script:
...
$strOutput = $strDatastoreName + " Orphaned VMDK Found: " + $strFilename
$strOutput | Out-File $Outputfile -width 150 -Append
...
Change the above 2 lines to:
$strOutput = $strDatastoreName + " Orphaned VMDK Found: " + $strFilename + " " + $strLength
$strOutput | Out-File $Outputfile -width 150 -Append
Give that a try...
You may want to add some extra logic to be able to get a better output like X MB or Y GB?
Marco -
No joy on the additions. It returns a blank space for $strLength. Here's what my script looks like aftr making your corrections. Any ideas?
$file = "" | select Name, FullPath
$file.Name = $fileResult.Path
$strFilename = $file.Name
$strLength = $fileResult.Length
IF ($strFilename)
{
IF ($strFilename.Contains(".vmdk"))
{
IF (!$strFilename.Contains("-flat.vmdk"))
{
IF (!$strFilename.Contains("delta.vmdk"))
{
$strCheckfile = ""$file.Name""
IF ($arrUsedDisks -Like $strCheckfile){}
ELSE
{
$strOutput = $strDatastoreName + "," +$strFilename ","$strLength
$strOutput | Out-File $Outputfile -width 150 -Append
Where is that script again? I can't find it anymore...
Marco
After this line in the original version:
$file.Name = $fileResult.Path
Add this:
$fileResult|get-member
I'd like to see the output from that part...
If you can't I'll try to fire up a VI connection tomorrow...
Marco
I'm so sorry... I'm just coming back to this forum now. Did you still need help?
Hello.
Thank you for you script. Its a greatfull tool to find orphaned vmdks.
I'm using it in ESX 3.0 with good results, but it doesn't work in 3.5.
It reports the following error:
"Referencia a objeto no establecida como instancia de un objeto"
translated my be like this
"Reference to an object not stablished as an object instance."
in the line:
$arrUsedDisks = Get-VM | Get-HardDisk | %{$_.filename}
Could you help me?
If you need any other information do not hesitate in contacting me.
Thank you in advance,
kind regards, joni.
Did you find a resolution to this. I would love to run this on my VI 2.5 ESX 3.5 servers?
See my version of the script in
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference