Automatically delete device in WDM

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #6834
    phillary
    Member
    • Total Post: 4
    • Newbie

    Hi

    In WDM 4.8.5, does anybody know if it’s possible to automatically delete devices that haven’t checked in for a specific amount of time, rather than doing it manually?

    Thanks

    Phil

    #21016
    ConfGen
    Keymaster
    • Total Post: 11485
    • Jedi Master
    • ★★★★★★★

    There is no automatic function doing this for you.
    But you can use some SQL queries and call these from inside SQL on a regular base.
    You can create your own stored procedure like that one:


    IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[sp_DeleteInactiveDevices]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
    DROP PROCEDURE [dbo].sp_DeleteInactiveDevices
    GO

    CREATE PROCEDURE [dbo].sp_DeleteInactiveDevices
    @InactiveDays int
    AS
    BEGIN
    DECLARE @ClientID int
    DECLARE @DeviceList CURSOR

    SET @DeviceList =CURSOR FOR
    SELECT ClientID
    FROM [RapportDB].[dbo].[Client]
    WHERE DATEDIFF(day, CheckIn, getdate()) >= @InactiveDays
    AND AgentVersion <> '5.0.0.15'
    AND AgentVersion <> '5.0.0.17'

    OPEN @DeviceList
    FETCH NEXT FROM @DeviceList INTO @ClientID
    WHILE (@@FETCH_STATUS = 0)
    BEGIN
    EXEC sp_DeleteClient @ClientID
    FETCH NEXT FROM @DeviceList INTO @ClientID
    END
    CLOSE @DeviceList
    DEALLOCATE @DeviceList
    END
    GO

    CG

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.