cancel
Showing results for 
Search instead for 
Did you mean: 

Delete computer from System Tree using Web API and VBScript

Jump to solution

Hi everybody. We are running EPO 4.6 and I would like to use a VBScript to automate the task of deleting a single computer from the system tree. I have read through the Web API documentation and believe I have found the command I need to run, but I just can't figure out how to actually run the command from within a VBScript. All the examples in the documentation use Python, but I don't know Python.

So, I believe the command I need to run is:

https://MyEPOServer:8443/remote/detectedsystem.delete?names=COMPUTERNAME

But the documentation talks about using WGET to send the command. Does anybody know a way to send the command in native VBScript?

thanks in advance!

Message was edited by: fitzgerac, typo on 9/28/12 3:21:58 PM CDT
1 Solution

Accepted Solutions

Re: Delete computer from System Tree using Web API and VBScript

Jump to solution

Hello Fitzgerac,

You actually need to use the system.delete command, detectedsystems refers to the RSD component. For this script to work you will need to install GNU Wget on every machine that will run this script, you can get the setup files at http://gnuwin32.sourceforge.net/packages/wget.htm. Once installed modify the URL variable to point to your epo server and enter your credentials in the UserName and Password variables. Also make sure the WGET variable points to your installation path. You can delete as many systems as you like so long as they are separated by a comma. The leading white spaces in the Options and URL variables are important for the script to execute properly. Hope this helps!

'####################################

'Script to delete systems from the system tree.

'Written By Darrell Pierson, 2012.

UserName = "foo"

Password = "bar"

WGET = """C:\Program Files (x86)\GnuWin32\bin\wget.exe"""

Options =  " --no-check-certificate --http-user=" & UserName &" --http-password=" & Password

URL = " https://eposerver:8443/remote/system.delete?names="

Names = """MachineName1, MachineName2"""

Set ObjShell = WScript.CreateObject("WScript.Shell")

Result= ObjShell.Run(WGET & Options & URL & Names, 6, True)

If Result = 0 Then

   wscript.echo "The following systems have been deleted: " & Names

Else

   wscript.echo "Unable to delete the following systems: " & Names

End if

Message was edited by: dpierson on 10/15/12 8:40:56 PM CDT
4 Replies

Re: Delete computer from System Tree using Web API and VBScript

Jump to solution

Hello Fitzgerac,

You actually need to use the system.delete command, detectedsystems refers to the RSD component. For this script to work you will need to install GNU Wget on every machine that will run this script, you can get the setup files at http://gnuwin32.sourceforge.net/packages/wget.htm. Once installed modify the URL variable to point to your epo server and enter your credentials in the UserName and Password variables. Also make sure the WGET variable points to your installation path. You can delete as many systems as you like so long as they are separated by a comma. The leading white spaces in the Options and URL variables are important for the script to execute properly. Hope this helps!

'####################################

'Script to delete systems from the system tree.

'Written By Darrell Pierson, 2012.

UserName = "foo"

Password = "bar"

WGET = """C:\Program Files (x86)\GnuWin32\bin\wget.exe"""

Options =  " --no-check-certificate --http-user=" & UserName &" --http-password=" & Password

URL = " https://eposerver:8443/remote/system.delete?names="

Names = """MachineName1, MachineName2"""

Set ObjShell = WScript.CreateObject("WScript.Shell")

Result= ObjShell.Run(WGET & Options & URL & Names, 6, True)

If Result = 0 Then

   wscript.echo "The following systems have been deleted: " & Names

Else

   wscript.echo "Unable to delete the following systems: " & Names

End if

Message was edited by: dpierson on 10/15/12 8:40:56 PM CDT

Re: Delete computer from System Tree using Web API and VBScript

Jump to solution

Thanks dpierson.

What I actually ended up doing was downloading a standalone .exe version of wget from http://users.ugent.be/~bpuype/wget/#download. then I just placed wget.exe in the same folder as my script, and ran the following command in my vbscript:

Set oShell = CreateObject("WScript.Shell")

Set oFSO = CreateObject("Scripting.FileSystemObject")

Dim sPath

sPath=oFSO.GetParentFolderName(WScript.ScriptFullName)

oShell.Run "cmd.exe /c "&sPath&"\wget.exe -q --no-check-certificate --user=admin --password=password "_

    &Chr(34)&"https://EPOSERVER:8443/remote/system.delete?names="&CompName&Chr(34),0,True

hope this helps somebody else out there.

Re: Delete computer from System Tree using Web API and VBScript

Jump to solution

So the password is being sent in clear text? That doesn't seem very secure..

jking
Level 10
Report Inappropriate Content
Message 5 of 5

Re: Delete computer from System Tree using Web API and VBScript

Jump to solution

The password is not being sent in clear text (httpS://...).  Use a limited priviledge account if you're going to embed a password inside a script, or prompt for the password when the script is run.

Jon