Hi, i need a powershell script – look for registry or wmi and see the last policy request time / date interval to confirm machine successfully updated in a day or 2 days

Question

Hi, i need a powershell script – look for registry or wmi and see the last policy request time / date interval to confirm machine successfully updated in a day or 2 days

 

“how to find out the lasft policy request time stamp in local machine using powershell if the client is inactive”

Answers ( 2 )

    1
    2020-05-12T15:39:54+05:30

    Hi,

    Please use below SQL query to get all report.

    ——————————————————————
    Declare @CollectionID Varchar(8)
    Set @CollectionID = ‘SMS00001’
    select
    Vrs.Name0 as ‘Computer Name’,
    Vrs.User_Name0 as ‘User Name’,
    case when Vrs.client0 = 1 then ‘Installed’
    else ‘NotInstalled’ end as ‘ClientAgentStatus’,
    summ.ClientStateDescription,
    case when summ.ClientActiveStatus = 0 then ‘Inactive’
    when summ.ClientActiveStatus = 1 then ‘Active’
    end as ‘ClientActiveStatus’,
    summ.LastActiveTime,
    case when summ.IsActiveDDR = 0 then ‘Inactive’
    when summ.IsActiveDDR = 1 then ‘Active’
    end as ‘IsActiveDDR’,
    case when summ.IsActiveHW = 0 then ‘Inactive’
    when summ.IsActiveHW = 1 then ‘Active’
    end as ‘IsActiveHW’,
    case when summ.IsActiveSW = 0 then ‘Inactive’
    when summ.IsActiveSW = 1 then ‘Active’
    end as ‘IsActiveSW’,
    case when summ.ISActivePolicyRequest = 0 then ‘Inactive’
    when summ.ISActivePolicyRequest = 1 then ‘Active’
    end as ‘ISActivePolicyRequest’,
    case when summ.IsActiveStatusMessages = 0 then ‘Inactive’
    when summ.IsActiveStatusMessages = 1 then ‘Active’
    end as ‘IsActiveStatusMessages’,
    summ.LastOnline,
    summ.LastDDR,
    summ.LastHW,
    summ.LastSW,
    summ.LastPolicyRequest,
    summ.LastStatusMessage,
    summ.LastHealthEvaluation,
    DATEDIFF ( DAY ,summ.LastPolicyRequest,getdate() ) ‘Last Communicated Day’,
    case when LastHealthEvaluationResult = 1 then ‘Not Yet Evaluated’
    when LastHealthEvaluationResult = 2 then ‘Not Applicable’
    when LastHealthEvaluationResult = 3 then ‘Evaluation Failed’
    when LastHealthEvaluationResult = 4 then ‘Evaluated Remediated Failed’
    when LastHealthEvaluationResult = 5 then ‘Not Evaluated Dependency Failed’
    when LastHealthEvaluationResult = 6 then ‘Evaluated Remediated Succeeded’
    when LastHealthEvaluationResult = 7 then ‘Evaluation Succeeded’
    end as ‘Last Health Evaluation Result’,
    case when LastEvaluationHealthy = 1 then ‘Pass’
    when LastEvaluationHealthy = 2 then ‘Fail’
    when LastEvaluationHealthy = 3 then ‘Unknown’
    end as ‘Last Evaluation Healthy’,
    case when summ.ClientRemediationSuccess = 1 then ‘Pass’
    when summ.ClientRemediationSuccess = 2 then ‘Fail’
    else ”
    end as ‘ClientRemediationSuccess’,
    summ.ExpectedNextPolicyRequest
    from V_R_System Vrs
    Left join v_CH_ClientSummary summ on Vrs.ResourceID = summ.ResourceID
    Where Vrs.ResourceID in (select ResourceID from v_FullCollectionMembership fcm where fcm.CollectionID = @CollectionID)
    order by Vrs.Name0
    ———————————————————————————

    Thanks
    Karthikeyan

    Best answer
    3
    2020-05-11T07:37:22+05:30

    Hello Sandeep, you can create a collection using LastLogonTimeStamp and can use collection to identify the computers that are inactive on the network for last 2 days.

    select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,
    SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,
    SMS_R_SYSTEM.Client from SMS_R_System
    where DATEDIFF(dd,SMS_R_System.LastLogonTimestamp,GetDate()) > 2

    + By Eswar – http://eskonr.com/2018/08/sccm-collection-for-active-inactive-computers-using-last-logon-timestamp-and-troubleshooting/

    Note – Test this before implementing to production

Leave an answer

Sorry, you do not have permission to answer to this question .