Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

Remove from a task ..

Created: 07 Aug 2014 • Updated: 14 Aug 2014 | 8 comments
This issue has been solved. See solution.

Inside DS 7.5 there is a task available called "Add to Filter". By attaching this to a Server side script I can add machines to a specific filter based on a computer list provided by the SQL query.

What I am looking for is the exact opposite of what it offered, I want to remove a machine from a specific filter when the query results come back a "Remove from Filter". Is this even possible ? I've not been successful in pulling any information using Chevron to see the guts behind the "Add to Filter" task.

Any help anyone ?

Operating Systems:

Comments 8 CommentsJump to latest comment

andykn101's picture

Look at the ASDK, that contains components and scripts to do many things programmatically in Symantec including removal from filters.

So I have a DS 6.9 Job that will remove a machine from all Filters in a particular folder or sub folders as part of a re-image so we can deploy that computer to a new user without all the software the previous user used to have.
 

Authorised Symantec Consultant (ASC) with Endpoint Management Limited, an Authorised Symantec Delivery Provider based in the UK.

Connect Etiquette: Please "Mark as Solution" posts that fix your problem.

Thomas Baird's picture

Raw SQL...?  Script tasks are the "Fill in the blank" tasks IMO...

Thomas Baird
Enthusiast for making things better!

 

andykn101's picture

I thouhgt we weren't spposed to do direct SQL manipulation for things like Filter membership....
 

Authorised Symantec Consultant (ASC) with Endpoint Management Limited, an Authorised Symantec Delivery Provider based in the UK.

Connect Etiquette: Please "Mark as Solution" posts that fix your problem.

cnorm75's picture

FIll in the blank, provide my own filter GUID, makes no difference. The issue is that the task to add machines to filters was provided in CMDB 7.5 and its counterpart is not readily available. There are several other tasks that have been provided that have the addition or removal of the job trying to be completed.

Andy, if you dont mind sharing, your job that removes a machine from a specific filter I can duplicate it to do what I need. I have found in the ASDK a way to add.inclusions, no luck so far on the removal.

Automating the uninstallation of packages after a specified time and removing the user from the specific filter that maintains compliance on said software staying installed is my ultimate goal. I just need to have the user removed from the filter when the automated removal jobs executes.

Thanks for your replys !

andykn101's picture

I don't do vbscript myself, I cobbled this together frokm other posts on Connect:

'Remove PC from filters
'vbscript
On Error Resume Next
'---------------------------------------
' Setup management objects
'---------------------------------------
set collectionManagementA = CreateObject("Altiris.ASDK.NS.CollectionManagement")
set itemManagementA = CreateObject("Altiris.ASDK.NS.ItemManagement")
set resourceManagementA = CreateObject("Altiris.ASDK.NS.ResourceManagement")

'Using the web service
    itemManagementA.TargetServer = "YourNSFQDN.local"
    itemManagementA.Authenticate()
    collectionManagementA.TargetServer = "YourNSFQDN.local"
    collectionManagementA.Authenticate()
    resourceManagementA.TargetServer = "YourNSFQDN.local"
    resourceManagementA.Authenticate()

machineName = "%COMPNAME%"
machineDomain = "NetBIOSDOmain"
computerGuid = resourceManagementA.GetComputerByNameAndDomain(machineName, machineDomain)
'---------------------------------------
' Setup other variables
'---------------------------------------
'This is the GUID for the top level folder - 1. Managed Software Delivery Filters
Const FILTERFOLDER = "{0ec5e832-85ab-47f5-b74d-b67d86214e6b}" ' FolderGUID to start searching under
'---------------------------------------
' Remove Inclusions
'---------------------------------------
Function recurseCheck(GUID)
  for each NSItemDetails in itemManagementA.GetItemsInFolder(GUID)
  ' You don't need to change the line below - I think it just skips the removal for foldser items
    If NSItemDetails.TypeName = "PresentationFolder" Then
      recurseCheck(NSItemDetails.Guid)
    Else
        Call collectionManagementA.RemoveInclusions(NSItemDetails.Guid, computerGuid)
    Call collectionManagementA.UpdateCollections(NSItemDetails.Guid)
    End If
  next
End Function

recurseCheck(FILTERFOLDER)

set collectionManagementA = Nothing
set itemManagementA = Nothing
set resourceManagementA = Nothing
set NSItemDetails.Guid = Nothing

WScript.Quit

I run this using Deployment Server 6.9, which replaces the %COMPNAME% token with the actual compter name when it runs.

Const FILTERFOLDER is the GUID of the Folder that contains all the filters you want to remove the PC from. It will check filters in subfolders.

It's a bit of a brute force script as it tries to remove the PC from every Filter it fineds, not just the ones it finds the PC GUID in.

The ASDK logs all it's activity in seperate log files D:\Program Files\Altiris\Altiris ASDK\Logs which can be read by the Logviewer utility.

Authorised Symantec Consultant (ASC) with Endpoint Management Limited, an Authorised Symantec Delivery Provider based in the UK.

Connect Etiquette: Please "Mark as Solution" posts that fix your problem.

cnorm75's picture

Our Quick delivery Tasks setup for help desk to deploy software also place the machine in the resepctived managed deployment job as a specific inclusion.

I think I have way now to remove from the filter based on the same logic and ran from a server task output file.

I'll post it up if it works today.

cnorm75's picture

Whammo !! We have a winner folks.

So in DS 7.5 we start with a Job, in that job is a server task to run the required query against the database, followup with a Task server script (in Powershell) that runs the following script against the computer list output of the server task:

# Initialize input
$filter="%!FilterGUID!%"
$Computers="%!RESOURCEGUIDLIST!%"
# A computer list encloses guids in single quotes which will fail
$computers=$computers -replace "'",""
# Use ASDK to remove items from filter
$altirisfilter=New-WebServiceProxy -uri http://YOURNSSERVER/Altiris/ASDK.NS/CollectionManagementService.asmx -class AltirisItem -namespace WebServiceProxy -usedefaultcredential
$altirisfilter.removeinclusions($filter,$computers)

Finally the last task is a client script that is run against the machine list from the server task output to uninstall the software product.

I hope this will help someone else looking to remove machines from specific filters.

Thanks to David to helping with the last piece to prevent me pulling out what hair I have left.

SOLUTION