Discovery pattern ext to populate custom 'most recent logged on user'

Richard Nelson1
Tera Contributor

Hi all,  I'm looking for help on a discovery pattern extension that will take the current logged on user and populate a custom field called 'Most recent logged in user' on the Computer CI record. 

 

The rationale for doing this is that the 'Assigned to' field on the CI and corresponding Asset record gets overwritten when discovery runs and finds the current logged in user.  Sometimes the current user is not the assigned owner of the device.   

 

The approach I have taken is to copy steps 2.58 and 2.59 from the Windows OS desktops pattern into a new extension.  I then changed the target field on 2.59 to point to a new custom field 'u_most_recent_user' which has the same type and properties as the original 'assigned to' field.   

 

I can see from the CI history that it is trying to update the field but it still appears blank.  I'm also curious about how the Transform table function updates the existing 'Assigned to' which is a reference field with 'domain/username' but then shows as populated with a 'Name'. 

 

Any thoughts to point me in the right direction would be appreciated. 

 

Thanks in advance 

5 REPLIES 5

Potter69
Tera Contributor

@Richard Nelson1 wrote: Portal4me.com

Hi all,  I'm looking for help on a discovery pattern extension that will take the current logged on user and populate a custom field called 'Most recent logged in user' on the Computer CI record. 

 

The rationale for doing this is that the 'Assigned to' field on the CI and corresponding Asset record gets overwritten when discovery runs and finds the current logged in user.  Sometimes the current user is not the assigned owner of the device.   

 

The approach I have taken is to copy steps 2.58 and 2.59 from the Windows OS desktops pattern into a new extension.  I then changed the target field on 2.59 to point to a new custom field 'u_most_recent_user' which has the same type and properties as the original 'assigned to' field.   

 

I can see from the CI history that it is trying to update the field but it still appears blank.  I'm also curious about how the Transform table function updates the existing 'Assigned to' which is a reference field with 'domain/username' but then shows as populated with a 'Name'. 

 

Any thoughts to point me in the right direction would be appreciated. 

 

Thanks in advance 


Create collections in Configuration Manager to more easily manage groups of users and devices.

mhunter
Tera Contributor

one thing that i have found is if you are using win32_comuputer system>username, if no one is logged into the device, then it will return blank. im trying to find a way to go get to the last logged in user as well, but i dont think this would be the correct wmi variable.

Manuel Stimac
Mega Sage

Hi @Richard Nelson1,

in the Pattern Designer, could you debug it and click on test to verify the value of the variable is valid?

 

If this answer helps you please mark it as Helpful/Solution.
Thanks & Regards - Manuel 

 


If my answer helped you, please mark it as Helpful/Solution.
Thanks & many Regards - Manuel 

Hi, slight delay in responding due to the holiday season.  I have debugged the entry and var values appear to be populated as per the screen shot.  However nothing gets updated into the Assigned_to field.

 

I have also noticed that in our Prod and Test environments the assigned_to field is updated by a client side script called 'Populate CI Manufacturer'.  Which I find odd given it does not mention the user name or any related values.