Jump to content
Dew

Retire a computer programmatically?

Recommended Posts

I'm searching for a way to retire a computer in Automate as part of a larger script we run when a computer is removed from our environment. I assumed I would be able to effect something through the Automate API, but try as I might I couldn't find anything in the documentation that would allow me to do so.

I need to be able to retire offline computers, as in most cases when we are retiring a computer in our environment the computer is already in a state where the drive has been pulled and will never contact the network again; however, I do not want to do this through a Monitor that checks for last contact time, as we also have computers that may be offline in remote locations for extended periods of time.

From my understanding a computer can be retired by calling sp_DeleteComputer('%computerid%','message'), but our Automate server is hosted remotely and I do not know of any way I could do so.

Is what I'm trying to do even possible? Ideas would be appreciated.

Share this post


Link to post
Share on other sites

Hi, thank you for responding.

I had noticed I could use a SQL Execute function from within a script in Automate, I guess where I'm falling short is I'm unsure how I could trigger an Automate script to run against a specific computer from an external source such as a PowerShell script.

I did see that you can post to cwa/api/v1/Computers/{computerId}/CommandExecute in the API but I was unable to determine any way that I could run an Automate script against an offline computer using commands. Am I barking up the wrong tree entirely?

Edit: I somehow overlooked ScheduledScript_PostComputerScheduledScript, now my only issue is figuring out how to format the POST so as to not receive a nondescript unhandled exception, but that is unrelated to the original question.

Edited by Dew

Share this post


Link to post
Share on other sites

@Dew 

Hi Dew,

I am looking for an automated process to retire scripts very similar to what you have setup.

I would like to retire devices not seen online for last 90 days for specific service plans(I have EDF for this) and also ensure the process inputs the reason into automate of why it was retired for auditing purposes.

Is there anyway you can search your script for me to have access to it?

Share this post


Link to post
Share on other sites
On 12/11/2019 at 7:11 PM, Dew said:

Hi, thank you for responding.

I had noticed I could use a SQL Execute function from within a script in Automate, I guess where I'm falling short is I'm unsure how I could trigger an Automate script to run against a specific computer from an external source such as a PowerShell script.

I did see that you can post to cwa/api/v1/Computers/{computerId}/CommandExecute in the API but I was unable to determine any way that I could run an Automate script against an offline computer using commands. Am I barking up the wrong tree entirely?

Edit: I somehow overlooked ScheduledScript_PostComputerScheduledScript, now my only issue is figuring out how to format the POST so as to not receive a nondescript unhandled exception, but that is unrelated to the original question.

@Dew

Hi Dew,

 

Did you every get ScheduledScripts POST working? If so could you post a sample of your POST body?
 

I too and getting the "Encounterd unhandled exception" message. I've reviewed the docs at https://developer.connectwise.com/Products/Automate/REST/Computers but still getting hung up.

Any help would be greatly appreciated.

 

Thanks

Brian

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...