I need to delete an orphaned automation account

Simon Taylor 20 Reputation points
2025-05-17T19:06:44.91+00:00

I deleted a log analytics workspace before unlinking an automation account. I have exhausted options trying to delete the resource so now I think I need microsoft to delete it in the backend.

PS C:\Windows\system32> Remove-AzAutomationAccount -Name aa-management-prod-uks-001 -Force -ResourceGroupName rg-management-prod-uks-001

Remove-AzAutomationAccount : Object reference not set to an instance of an object.

At line:1 char:1

  • Remove-AzAutomationAccount -Name aa-management-prod-uks-001 -Force -R ...
  • 
        + CategoryInfo          : CloseError: (:) [Remove-AzAutomationAccount], NullReferenceException
    
        + FullyQualifiedErrorId : Microsoft.Azure.Commands.Automation.Cmdlet.RemoveAzureAutomationAccount
    
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,368 questions
{count} votes

Accepted answer
  1. SadiqhAhmed-MSFT 49,331 Reputation points Microsoft Employee Moderator
    2025-05-23T10:48:42.0766667+00:00

    @Simon Taylor

    The issue arose due to the soft delete policy applied to the Log Analytics workspace, which temporarily prevents its deletion to allow for recovery Once this grace period concluded, the associated automation account was successfully deleted, resolving the problem. It's important to note that during the soft delete phase, the workspace and its linked resources remain in a non-functional state, which can impact operations.

    Please let me know if you face any challenge here, I can help you to resolve this issue further

    Provide your valuable Comments.

    User's image

    Please do not forget to "Accept the answer” and “upvote it” wherever the information provided helps you, this can be beneficial to other community members.it would be greatly appreciated and helpful to others.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.