Glad to hear you could fix the issue.
Original Message:
Sent: Nov 11, 2024 08:43 AM
From: dbutch1976
Subject: How to find Orphaned VMDK files with -Delete Option
You are correct. I was a little astonished to find out that the built in read-only account does not have Datastore.Browse privilege assigned, or any other privilege for that matter. After cloning the account, and granting only Datastore.Browse the script is running without error.
Thanks!
Original Message:
Sent: Nov 07, 2024 02:38 PM
From: LucD
Subject: How to find Orphaned VMDK files with -Delete Option
According to the SOAP API reference for the SearchDatastoreSubFolders method, it only requires the Datastore.Browse privilege.
But it could be that calling the method from PS requires additional privileges.
Did you check the vpxd log to see if the error there shows what is missing?
------------------------------
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Original Message:
Sent: Nov 07, 2024 07:09 AM
From: dbutch1976
Subject: How to find Orphaned VMDK files with -Delete Option
Hi LucD,
This script works great when using my admin account, but to be ultra cautious in production I want to do the first runs just for report generation using a read-only account, however when I run it I'm getting the following:
Get-VmwOrphan -Datastore IOMEGA
Exception calling "SearchDatastoreSubFolders" with "2" argument(s): "Permission to perform this operation was denied."
At C:\Users\dbutc\Dropbox\VMware\PowerCLI\orphaned_vmdks\get_orphaned_vmdks.ps1:76 char:9
+ $searchResult = $dsBrowser.SearchDatastoreSubFolders($rootPat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException
Could you explain what it's doing on this line which requires permissions higher than read-only? Hopefully I can just assign the minimum permissions required to run it.
Original Message:
Sent: Mar 04, 2018 09:16 AM
From: LucD
Subject: How to find Orphaned VMDK files with -Delete Option
Try with the attached new version.
You can now do
Get-Datastore -Name DS1 | Get-VmwOrphan -Delete -WhatIf
Once you are sure the correct files will be removed, you can drop the WhatIf switch.
I added an additional parameter ExcludeFolder, which is jandy if you to want speficic folders on the datastore (ISO folder, snapshot folder...)
You can use it like
Get-Datastore -Name DS1 | Get-VmwOrphan -ExcludeFolder 'Folder1','Folder2'
And finally a PS, sometimes you will need to call the function at least twice.
When an orphaned folder contains and orphaned file, the 1st run will remove the file, the 2nd run will remove the folder.