I need to audit my storage environment as it is filling up on 2 vcenters.
Phase 1
First I looked at the current VMs that are running and where their files are located.
get-vm | fl name, Host, DatastoreIdList, PowerState
This shows me most of what I am looking for, but I see that some of these VM are connected to multiple DataStores(DS) even though there is only one listed under the VM configuration. So I have some info and I am not sure what DS is correct or why its listing multiples?
Phase 2
Then some the luns have VMs that removed from inventory that are no longer needed. These VM are consuming valuable resources and I would like to retain the VMDK and configs to a backup location.
Is there a way to see/export a complete list of folders on each DS sorted by the least recently accessed?
Many Thanks!
Aaron
1) Could it be that some of the VMs have harddisks that are located on other datastores then where the VM's folder is located.
You can check with
Get-VM | Get-Harddisk |
Select @{N='VM';E={$_.Parent.Name}},Name,FileName
2) You can check for orphaned files with the script in Orphaned files and folders – Spring cleaning
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
1) Could it be that some of the VMs have harddisks that are located on other datastores then where the VM's folder is located.
You can check with
Get-VM | Get-Harddisk |
Select @{N='VM';E={$_.Parent.Name}},Name,FileName
2) You can check for orphaned files with the script in Orphaned files and folders – Spring cleaning
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you for the quick response and btw i have been reading on your blog for some time. So thank you for keeping that updated! So just to be sure as I do not want to remove anything yet but all I would need to do to collect the info and not delete would be to remove this?
param
(
[
parameter
(
Mandatory
=
$true
,
ValueFromPipeline
=
$true
)]
[PSObject[]]
$Datastore
,
[switch]
$Delete
)
Thank you!
If you do not add the Delete switch on the call, the function will only list the orphaned files.
See the Sample Runs further down the post
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Is there a way to alter your housekeeping script to move the files to a "Cleanup" folder on the datastore, instead of deleting them?
That is a good idea!
It's not in the current version of the script, but it shouldn't be too hard to add that functionality.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference