Video Screencast Help
Give us your opinion and win with Symantec! Please help us by taking this survey and tell us about your satisfaction level using Symantec Connect. One lucky winner will receive 500 Connect points!* Take the survey.

Remove Computers from NS Database and DS Database with DS Job

Created: 03 Apr 2009 • Updated: 03 Apr 2009 | 3 comments
Language Translations
MtBiker's picture
+13 13 Votes
Login to vote

When multiple people are reimaging and retiring computers it can become difficult to determine which machines should still remain in your database. I have determined that I only want active machines on our network to be in Altiris NS and DS so I have created a job to remove the computers from both databases once they are returned to stock.

This has helped us greatly in keeping our inactive inventory from our active inventory. The main downside to this method is you are also deleting all history to that machine.

This is how its done:

First, you will need to install the Microsoft SQL Server 2005 Command Line Query Utility on your DS server. You can get the SQL 2005 version here:

Here is the Microsoft documentation on how to use the SQLCMD tool:

Once you have the query utility installed, create a DS job that will run from the DS server and not the client itself. To remove the record from the NS database, add a run script in your DS job with this command>

"C:\Program Files\Microsoft SQL Server\90\Tools\binn\SQLCMD.EXE" -U SQLUSER -P SQLPASSWORD -S SQLSERVER\SQLINSTANCE -d NSDATABASE -Q"DECLARE @guid uniqueidentifier; select @guid = Guid from vComputer where Name = '%COMPNAME%'; EXEC spResourceDelete @guid"

To remove the computer record from the DS server create another DS job to run from the DS server and not the client and add a run script with this command

"C:\Program Files\Microsoft SQL Server\90\Tools\binn\SQLCMD.EXE" -U SQLUSER -P SQLPASSWORD -S SQLSERVER\SQLINSTANCE -d DSDATABASE -Q "delete computer where name = '%COMPNAME%'"

This should allow you to remove records from both databases. Good Luck!

Comments 3 CommentsJump to latest comment

MHope's picture

Hello. Doesn't this method leave items into the  dbo.nics  table and prevent the users in the future from entering the same machines (or new machines with the unfortunate same mac address) back again, because the mac addresses of the old computers are still listed in dbo.nics table?



Login to vote