Altiris Software Dev Kit (ASDK)

 View Only

Removing Items Remotely and in Bulk 

Oct 09, 2015 05:18 PM

Methods of Deleting

Whilst items can be directly deleted from the SMP console I want to show you a couple of alternative methods which you might not necessarily know about which allows you to remove items in bulk and remotely.

  • Item Management Service ASDK (Remotely)
  • ItemToDelete Table (In Bulk)

Item Management Service ASDK (Remotely)

The ASDK services are a great a way of interacting with your notification server and allow technicians to remotely maintain their assets and other SMP entities. There are various services available but for this article we are going to concentrate on the ItemManagement service and the DeleteItem endpoint.

By default the service is located at the following URL.

http://<NSServer>/Altiris/ASDK.NS/ItemManagementService.asmx

Consuming the Item Management Service via Powershell

There are many ways to consume a webservice but the easiest and often overlooked way is with Powershell. The below script is an example of how to consume the service and invoke the delete item method.

##
## A COLLECTION OF ITEM GUIDS
##
param(
    [parameter(Mandatory=$true)]
    [string[]]$items
)

##
## SERVICE WSDL - UPDATE TO REFLECT YOUR NS
##
$service = "http://<NSServer>/Altiris/ASDK.NS/ItemManagementService.asmx?WSDL"

##
## PROMPT THE USER FOR CREDENTIALS
##
$cred | Out-Null
if($cred -eq $null)
{
    $cred = Get-Credential
}

##
## CREATE A PROXY & SECURE
##
$proxy = New-WebServiceProxy -uri $service -namespace WebServiceProxy -Credential $cred

##
## DELETE EACH ITEM
##
Foreach($item in $items)
{
    $proxy.DeleteItem($item)
}

Executing the Script

  1. Save the above script to your computer as DeleteItems.ps1
  2. Edit the $service variable tor reflect your NS server address
  3. Run Powershell and navigate to your script directory
  4. Run the following command - ./DeleteItems.ps1
  5. You will be prompted to enter one or more item GUIDs
  6. Enter one of more item GUIDs
  7. You will be prompted to enter your credentials to authenticate the requests
  8. Enter your authentication details (remember to include the domain if required)

ItemToDelete Table (In Bulk)

This table allows you to schedule the deletion of Items within the SMP by simply inserting the item GUID and a date you which the item to be deleted. This can be extremely useful if you need to delete a lot of items and if you required the deletion to take place out of hours.

There is a scheduled task on the NS Server (Windows Task Scheduler) that runs every 15 minutes named NS.Quarter-Hour which will delete any items whose delete date has past the scheduled task time.

Adding Data to the ItemToDelete

The following SQL script will insert items into this this table to be deleted at the next scheduled run.

INSERT INTO [dbo].[ItemToDelete]
           ([Guid]
           ,[DeleteDate])
     VALUES
           ('DEA62DE0-A698-485D-8799-0004F3A41F68', --REPLACE WITH YOUR ITEM GUID
           GETDATE())

Forcing the Schedule to Run

You can force this task to run ASAP by running the task directly from the Windows Task Scheduler on the SMP server.

  1. Access the SMP server
  2. Click the Start button.
  3. Select Control Panel.
  4. Click System and Maintenance.
  5. Click Administrative Tools.
  6. Double-click Task Scheduler.
  7. Under Task Scheduler Library look for NS.Quarter-Hour
  8. Right click on this task and choose Run#

 

Christopher McEwen
Developer

Protirus

 

Statistics
0 Favorited
9 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Related Entries and Links

No Related Resource entered.