I already replied on the other thread, but this is my answer.
Not sure what you trying to do, but the filenames that are returned are just the VMDK files that are not attached to a VM.
Meaning the Get-HardDisk cmdlet will not be able to find them this way.
Same goes for the Remove-HardDisk.
If you want to remove orphaned disk files, you might want to take a look at my Orphaned Files And Folders – Spring Cleaning post.
That function also has the option to remove the orphaned files.Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
Backup software takes snapshot. and then Backup proxy servers attach there client vms vmdk to themselves for backup.
But Incase, of some backup softwares like networker doesn't release these vmdk files post backup is completed to the client machine and this cause Disk Consolidation.
So i want to release those vmdk files from backup proxy server.
as per my research, those files get attached to backup proxy server as "independentnonpersistent"
I see, but then the code you mentioned in the beginning should correct.
Perhaps add a WhatIf switch to the Remove-HardDisk cmdlet to make sure it actually removes what you want to remove.Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz