Jump to content
Welcome to our new Citrix community!
  • Citrix Studio: Unable to Delete Hosting Resources–There is Currently an Active Background Action


    cugcblogs

    marcohofmannrnd.png by Marco Hofmann, CTA

    Today in Citrix Studio, I discovered a dead Hosting connection that I had set up years ago for some MCS tests. When I tried to simply delete the connection, I received the following message:

    hofmann062518-01.png.ccf99c4a049d169c2bce204930829591.png

    The error message leads to the following (helpful!) KB article: CTX138318

    After following the different steps outlined in the article...

    asnp citrix*Cd XDHyp:\HostingUnitsGet-ChildItemGet-ProvTask | Where-Object { $_.ImagesToDelete | Where-Object { $_.HostingUnit -eq "f4dcd282-3d9b-478a-9107-2cafe6f6f124" } }

    ... I ended up with something like this:

    TaskId                 : db2ed90d-9f5f-43c9-8ee0-01dfde159544Active                 : FalseHost                   : XA-WMS2016-01DateStarted            : 28.05.2018 22:47:27Metadata               : {}CurrentOperation       : TaskProgress           : 100LastUpdateTime         : 28.05.2018 22:47:37ActiveElapsedTime      : 9DateFinished           : 28.05.2018 22:47:37TerminatingError       : FaultedType                   : DisusedImageCleanUpStatus                 : FinishedImagesToDelete         : {HostingUnitUid 'f4dcd282-3d9b-478a-9107-2cafe6f6f124', Image 'DiskId Version=2,LsiLogicScsi,1000,group-v47771,[v3700_p01_18] MCS-2012R2-baseDisk-datastore-47764/12 Feb 2017 19-53-35.4705Z.vmdk,resgroup-8,Vmfs : StorageId                          datastore-47764', Last Processed '5/28/2018 6:59:24 PM', HostingUnitUid 'f4dcd282-3d9b-478a-9107-2cafe6f6f124', Image 'DiskId Version=2,LsiLogicScsi,1000,group-v47771,[v3700_p01_14]                          MCS-2012R2-baseDisk-datastore-47360/MCS-2012R2-baseDisk-datastore-47360.vmdk,resgroup-8,Vmfs : StorageId datastore-47360', Last Processed '5/28/2018 7:02:31 PM'}HeartbeatInterval      : 01:00:00RetryInterval          : 06:00:00WorkflowStatus         : TerminatedTaskExpectedCompletion : TaskId                 : 10f7b103-0675-42c8-9a97-0c20016af145Active                 : FalseHost                   : XA-WMS2016-02DateStarted            : 14.04.2018 21:10:39Metadata               : {}CurrentOperation       : TaskProgress           : 100LastUpdateTime         : 17.06.2018 02:59:26ActiveElapsedTime      : 5464104DateFinished           : 17.06.2018 02:59:26TerminatingError       : FaultedType                   : DisusedImageCleanUpStatus                 : FinishedImagesToDelete         : {HostingUnitUid 'f4dcd282-3d9b-478a-9107-2cafe6f6f124', Image 'DiskId Version=2,LsiLogicScsi,1000,group-v47771,[v3700_p01_18] MCS-2012R2-baseDisk-datastore-47764/12 Feb 2017 19-53-35.4705Z.vmdk,resgroup-8,Vmfs : StorageId                          datastore-47764', Last Processed '6/16/2018 11:01:05 PM', HostingUnitUid 'f4dcd282-3d9b-478a-9107-2cafe6f6f124', Image 'DiskId Version=2,LsiLogicScsi,1000,group-v47771,[v3700_p01_14]                          MCS-2012R2-baseDisk-datastore-47360/MCS-2012R2-baseDisk-datastore-47360.vmdk,resgroup-8,Vmfs : StorageId datastore-47360', Last Processed '6/16/2018 11:04:12 PM'}HeartbeatInterval      : 01:00:00RetryInterval          : 06:00:00WorkflowStatus         : TerminatedTaskExpectedCompletion : TaskId                 : 0d3bbe35-581d-46c8-b85f-23aa9911ed6fActive                 : TrueHost                   : XA-WMS2016-01DateStarted            : 17.06.2018 02:59:10Metadata               : {}CurrentOperation       : RunningTaskProgress           : LastUpdateTime         : 18.06.2018 17:05:10ActiveElapsedTime      : 137155DateFinished           : TerminatingError       : Type                   : DisusedImageCleanUpStatus                 : RunningImagesToDelete         : {HostingUnitUid 'f4dcd282-3d9b-478a-9107-2cafe6f6f124', Image 'DiskId Version=2,LsiLogicScsi,1000,group-v47771,[v3700_p01_18] MCS-2012R2-baseDisk-datastore-47764/12 Feb 2017 19-53-35.4705Z.vmdk,resgroup-8,Vmfs : StorageId                          datastore-47764', Last Processed '6/18/2018 12:02:03 PM', HostingUnitUid 'f4dcd282-3d9b-478a-9107-2cafe6f6f124', Image 'DiskId Version=2,LsiLogicScsi,1000,group-v47771,[v3700_p01_14]                          MCS-2012R2-baseDisk-datastore-47360/MCS-2012R2-baseDisk-datastore-47360.vmdk,resgroup-8,Vmfs : StorageId datastore-47360', Last Processed '6/18/2018 12:05:09 PM'}HeartbeatInterval      : 01:00:00RetryInterval          : 06:00:00WorkflowStatus         : RunningTaskExpectedCompletion : TaskId                 : 210c7daf-ed26-4275-8cab-26dee5f941e7Active                 : FalseHost                   : XA-WMS2016-01DateStarted            : 15.04.2018 11:20:05Metadata               : {}CurrentOperation       : TaskProgress           : 100LastUpdateTime         : 15.04.2018 11:20:35ActiveElapsedTime      : 29DateFinished           : 15.04.2018 11:20:35TerminatingError       : FaultedType                   : DisusedImageCleanUpStatus                 : FinishedImagesToDelete         : {HostingUnitUid 'f4dcd282-3d9b-478a-9107-2cafe6f6f124', Image 'DiskId Version=2,LsiLogicScsi,1000,group-v47771,[v3700_p01_18] MCS-2012R2-baseDisk-datastore-47764/12 Feb 2017 19-53-35.4705Z.vmdk,resgroup-8,Vmfs : StorageId                          datastore-47764', Last Processed '4/15/2018 9:14:32 AM', HostingUnitUid 'f4dcd282-3d9b-478a-9107-2cafe6f6f124', Image 'DiskId Version=2,LsiLogicScsi,1000,group-v47771,[v3700_p01_14]                          MCS-2012R2-baseDisk-datastore-47360/MCS-2012R2-baseDisk-datastore-47360.vmdk,resgroup-8,Vmfs : StorageId datastore-47360', Last Processed '4/15/2018 9:15:05 AM'}HeartbeatInterval      : 01:00:00RetryInterval          : 06:00:00WorkflowStatus         : TerminatedTaskExpectedCompletion : TaskId                 : 458a44a9-214d-4d2e-80d1-400b6c81dd3bActive                 : FalseHost                   : XA-WMS2016-01DateStarted            : 20.05.2018 03:08:58Metadata               : {}CurrentOperation       : TaskProgress           : 100LastUpdateTime         : 20.05.2018 03:09:04ActiveElapsedTime      : 9DateFinished           : 20.05.2018 03:09:04TerminatingError       : FaultedType                   : DisusedImageCleanUpStatus                 : FinishedImagesToDelete         : {HostingUnitUid 'f4dcd282-3d9b-478a-9107-2cafe6f6f124', Image 'DiskId Version=2,LsiLogicScsi,1000,group-v47771,[v3700_p01_18] MCS-2012R2-baseDisk-datastore-47764/12 Feb 2017 19-53-35.4705Z.vmdk,resgroup-8,Vmfs : StorageId                          datastore-47764', Last Processed '5/20/2018 2:55:10 AM', HostingUnitUid 'f4dcd282-3d9b-478a-9107-2cafe6f6f124', Image 'DiskId Version=2,LsiLogicScsi,1000,group-v47771,[v3700_p01_14]                          MCS-2012R2-baseDisk-datastore-47360/MCS-2012R2-baseDisk-datastore-47360.vmdk,resgroup-8,Vmfs : StorageId datastore-47360', Last Processed '5/20/2018 3:01:05 AM'}HeartbeatInterval      : 01:00:00RetryInterval          : 06:00:00WorkflowStatus         : TerminatedTaskExpectedCompletion : 

    The list is normally 5 times this long!

    Which, I should process via:

    Remove-ProvTask -TaskID  

    Which, I didn't want to do manually for each entry. But I remembered the session from Andreas Nick at the TecCon2018, where he showed examples about how to pipe the output of a command to a select grid. I'm not good at PowerShell at all, but I wanted to try it anyway. After two hours of straight web research, I ended up with the following code, which simplified this process a lot!

    asnp citrix*Cd XDHyp:\HostingUnits$Hosting = Get-ChildItem | Out-GridView -PassThru -Title "Select Hosting Connection" | Select-Object -Property HostingUnitUidGet-ProvTask | Where-Object { $_.ImagesToDelete | Where-Object { $_.HostingUnit -eq $Hosting.HostingUnitUid } } |Out-GridView -PassThru -Title "Select Provisioning Tasks for removal" | ForEach-Object { Remove-ProvTask -TaskID $_.TaskId }
    hofmann062518-02.png.b95a664283458dfebf9029dcb350374c.png

    To explain each step in detail:

    Line 1Make PowerShell aware of the Citrix cmdlets.
    Line 2Switch to the Hypervisor Hosting connections of XenDesktop.
    Line 3Write the HostingUnitUid of the affected connection into a variable after a GridView Select.
    Line 4Create a list of all pending tasks and ...
    Line 5Present it in a second GridView Select so you could delete all or selected tasks. The selection is being piped to the Remove command.

    This will look similar to this:

    hofmann062518-03.png.b4497655a3ce1f797dcdb1c664e635a3.pnghofmann062518-04.png?w=1024

    In the Out-GridView, you will first select the affected Hosting connection and in the second window, you will select all ProvTasks you may want to remove. Most of the time this will be all. There are certainly better ways to solve this, but the intent of this post is just to show you with how little work it is to optimize a repetitive task with simple PowerShell tricks.

    Sometimes it can happen, that a ProvTask is "Running" and you can't remove it. For this case, I found a hint at discussions.citrix.com linked at the bottom.

    This worked great for me, but you should test this first!

    Source: https://support.citrix.com/article/CTX138318

    https://discussions.citrix.com/topic/333521-cant-delete-hosting-connection/


    User Feedback

    Recommended Comments

    There are no comments to display.



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...