When attempting to delete hosting infrastructure (either a Connection or Resources) from Citrix Studio, the following message appears:
"Resources "Local storage" cannot be deleted because they are being used by the following Machine Catalogs and/or background actions:..."
To avoid overloading the hypervisor, Machine Creation Services (MCS) delays the deletion of unused disks from a Catalog in some scenarios. To complete this deletion process, MCS requires the Resources that were used to create the Catalog are not deleted until all the unused disks are deleted.
The preceding message appears if attempting to delete the Resources used to create the Catalog (or the Connection that owns the Resources) when MCS is yet to delete the unused disk.
To resolve this issue, complete the following steps:
Note: Ensure that all Catalogs still use the Resources that are deleted using the Catalogs node in Studio.
To obtain a precise estimate of when the disks will be deleted, run the following PowerShell commands on any Controller in the Site:
Add-PsSnapin Citrix.Host.Admin.V2
Add-PsSnapin Citrix.MachineCreation.Admin.V2
Cd XDHyp:\HostingUnits
Get-ChildItem
Running the preceding commands returns a list of Resources (called “HostingUnits” in the SDK), and will look similar to the following:
From this step, note HostingUnitUid of the Resources that you are trying to delete (highlighted in the preceding screenshot) and then run the following command, substituting HostingUnitUid from your environment:
Get-ProvTask | Where-Object { $_.ImagesToDelete | Where-Object { $_.HostingUnit -eq "a3284d3e-848c-4f98-ad74-61457b990a7f" } }
Running the preceding command gives a list of tasks that still need to complete before the Resources can be deleted, and will look similar to the following:
From the preceding screenshot, it is noticed that the last attempt which was made to delete the disks is in the LastUpdateTime field, and the next attempt that will be made is in the RetryInterval field (specified in hours:minutes: seconds). In this case, the next attempt is made at 10/10/2013 2:48:82 PM.
To remove this task execute command Remove-ProvTask-TaskID <EnterTaskID>
If no tasks are listed then all tasks have already been completed. Attempt to remove storage with the following commands:
Storage :
Remove-HypHostingUnitStorage -LiteralPath XDHyp:\HostingUnits\MyHostingUnit -StoragePath 'XDHyp:\HostingUnits\MyHostingUnits\newStorage.storage'
PersonalvDiskStorage:
Get-ChildItem XDHyp:\HostingUnits\MyHostingUnit\*.storage | Remove-HypHostingUnitStorage -LiteralPath XDHyp:\HostingUnits\MyHostingUnit -StorageType PersonalvDiskStorage
TemporaryStorage:
Get-ChildItem XDHyp:\HostingUnits\MyHostingUnit\*.storage | Remove-HypHostingUnitStorage -LiteralPath XDHyp:\HostingUnits\MyHostingUnit -StorageType TemporaryStorage
Hosting Resource Name
Remove-Item -path XDHyp:\HostingUnits\MyHostingUnit