Service Graph Connector for Intune - retiring devices
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 07:55 AM
Hi,
We recently migrated from SCCM to SG-Intune for discovering our client devices (Laptops and Mobile devices).
So far everything looks to be ok but we are having some issues with devices being retired when they are still available in Intune.
There does not seem to be a state change when a device is decomissioned so the device just stops coming in. We made a post-import script that retires the device when it is nog imported for 2 days in a row but that does not always seem to work like we expect.
Also, when it is retired and the device rediscovered there is no trigger to set the state back to installed because the state is set bij the post import script and not by the actual import, so it updates the record but it remains retired.
Has anyone thought of a more elegant solution to this issue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2024 01:26 PM
Hi have the same requirement. How does your post script look like?
I cant see any attribute in Intune that would be a good candidate to trigger retirement state..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2024 11:14 PM
I'm happy to share but take below script as a guideline, not as a solution. It might not fit your needs.
// reactivate retired Cloud PC's
var gr = new GlideRecord('cmdb_ci_computer');
gr.addEncodedQuery('sys_updated_on>javascript:gs.endOfYesterday()^model_id.nameLIKECloud PC Enterprise^discovery_source=SG-Intune^ORdiscovery_source=Manual Entry^install_status=7^ORDERBYDESCsys_created_on'); // all active cloud PC's updated before yesterday.
gr.query();
gr.setValue('install_status','1'); // Installed
gr.updateMultiple();
// Retire Cloud PC's that are not found.
var grCCC = new GlideRecord('cmdb_ci_computer');
grCCC.addEncodedQuery('sys_updated_on<javascript:gs.beginningOfYesterday()^model_id.nameLIKECloud PC Enterprise^discovery_source=SG-Intune^ORdiscovery_source=Manual Entry^u_active=true^ORDERBYDESCsys_created_on'); // all active cloud PC's updated before yesterday.
grCCC.query();
// double-check against import table to make sure the computer is really not being imported
var grIIC = new GlideRecord('sn_intune_integrat_computer');
while (grCCC.next()){
var compName = grCCC.getDisplayValue();
grIIC.addEncodedQuery('sys_created_on<javascript:gs.beginningOfYesterday()');
grIIC.addQuery('u_devicename', compName);
grIIC.query();
// retire and unassign old CIs
if (grIIC.getRowCount() == 0){
grCCC.setValue('install_status','7'); // Retired
grCCC.setValue('assigned_to','NULL'); // Empty Assigned_to field
grCCC.update();
}};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2024 07:43 AM
Thank you! This got me going in the correct direction!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2025 07:02 AM