Jump to content
Welcome to our new Citrix community!
  • 0

REST Api call to delete Machine / Machine accounts


Kunal N

Question

When I make a rest API call to delete a Machine from Citrix, the Machine gets deleted however the Machine Account doesn't and the state changes to tainted. These machines are pure AzureAD joined and I am able to delete the accounts using powershell SDK.

 

But since I wish to automate the process, I need to understand how to delete the account with the machine:

 

Eg:

$del=@{
    deleteVm="true"
    deleteAccount="Delete"
}
Invoke-RestMethod "https://api-us.cloud.com/cvad/manage/Machines/****" -Method delete -Headers $headers -ContentType "application/json" -UserAgent "Mozilla/5.0" -Body ($del | ConvertTo-Json -Depth 10)

 

Link to comment

3 answers to this question

Recommended Posts

  • 0

Hi, Kunal. 
If you want to delete the account, please try this:

Invoke-RestMethod "https://api-us.cloud.com/cvad/manage/Machines/****?deleteVm=true&deleteAccount=None" -Method delete -Headers $headers -ContentType "application/json" -UserAgent "Mozilla/5.0" 

Link to comment
  • 0
13 hours ago, Ji Gao said:

Hi, Kunal. 
If you want to delete the account, please try this:

Invoke-RestMethod "https://api-us.cloud.com/cvad/manage/Machines/****?deleteVm=true&deleteAccount=None" -Method delete -Headers $headers -ContentType "application/json" -UserAgent "Mozilla/5.0" 

Just for my information, I do get the below error message in powershell, however it still does what I need it to do:

Invoke-RestMethod : body {font-family:Arial; margin-left:40px; }img  { border:0 none; }#content { margin-left: auto; margin-right: auto }#message h2 { font-size: 20px; font-weight: normal; color: #000000; margin: 34px 0px 0px 0px }#message p  { font-size: 13px; color: #000000; margin: 7px 0px 0px0px}#errorref { font-size: 11px; color: #737373; 
margin-top: 41px }Service unavailableOur services aren't available right nowWe're working to restore all services as soon as possible. Please check back soon.0FOExYgAAAAAgHJ6NKCVuSoLGLGRgHajKQ082QUEzMTUwODEwMDIzADVmZTNlMTRiLTkxOTQtNDFhYS1iYjE1LTQzODAzZjVlZDBlMQ==
At line:1 char:1
+ Invoke-RestMethod "https://api-us.cloud.com/cvad/manage/Machines/CE-I ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Link to comment

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...