Note: This is an unsupported method
The work-around is as follows
1. Create a collection on your reporting NS as follows:
SELECT c.Guid
FROM [vComputerResource] c
INNER JOIN
(SELECT [ResourceGuid], max([ModifiedDate]) as LatestInventoryDate FROM dbo.ResourceUpdateSummary GROUP BY [ResourceGuid]) as dt
ON c.Guid = dt.ResourceGuid
INNER JOIN vResourceEx rx ON rx.Guid = c.Guid
WHERE rx.IsManaged = 1
AND rx.IsLocal = 0
AND dt.LatestInventoryDate < dateadd ( dd , -60 , getdate() )
In this example, the collection will be populated with machines that have not forwarded any inventory for 60 days. You can configure the bottom line, as needed, with whatever purge settings you require. One thing to note here of course is to make sure that the time interval specified for the above collection is not less than or equal to the frequency of the Inventory Forwarding rule schedule.
2. Copy and paste the following into notepad and then save it as DeleteCollectionMembers.cs:
///Copy this contents into notepad and save the file as DeleteCollectionMembers.cs
using System;
using System.Collections;
using System.IO;
using System.Xml;
using System.Data;
using System.Data.SqlTypes;
using System.Data.SqlClient;using Altiris.NS;
using Altiris.NS.StandardItems;
using Altiris.NS.ItemManagement;
using Altiris.NS.Security;
using Altiris.NS.ContextManagement;
using Altiris.NS.StandardItems.Collection;namespace NScript.Test
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class Class1
{
public Class1()
{
//
// TODO: Add constructor logic here
//
}/// <summary>
/// The main entry point for the application.
/// </summary
[STAThread]
static void Main(string[] args)
{SecurityContextManager.SetContextData();
Guid collectionGuid;try
{
collectionGuid = new Guid(args[0]);
}
catch
{
Console.WriteLine("Need to specify collection guid");
return;
}ResourceCollection collection = (ResourceCollection) Item.GetItem(collectionGuid);
if (collection == null)
{
Console.WriteLine("Collection guid {0.EN_US} not found", collectionGuid.ToString());
return;
}collection.UpdateMembership (true);
using (DatabaseContext context = DatabaseContext.GetContext())
{
string sql = string.Format(@"select ResourceGuid from CollectionMembership where CollectionGuid = '{0.EN_US}'", collectionGuid);
ArrayList list = new ArrayList();
int i = 0;using (SqlDataReader reader = (SqlDataReader) context.CreateCommand(sql).ExecuteReader())
{
while (reader.Read())
{
list.Add(reader.GetGuid(0));
}
}Console.WriteLine("{0.EN_US} computer(s) to be deleted", list.Count);
if (list.Count == 0)
return;foreach (Guid guid in list)
{
Item.DeleteItem(guid);
if (++i % 20 == 0)
{
Console.WriteLine("{0.EN_US} done..",i);
}
}Console.WriteLine("Deletion of {0.EN_US} computer(s) complete.",i);
}
}
}
}
3. Now use the .cs utility created above to delete all of the computers that are present in the created collection. Run the above utility on a daily basis on your reporting NS (you may want to schedule this) using the following command line:
nscript DeleteCollectionMembers.cs <Guid>
where <Guid> is the guid of the collection that you created above.
Applies To
Notification Server 6.0 Service Pack 3 (all hotfixes and previous versions).