Notification

Icon
Error

Automatic Linking of Assets

Posted: Thursday, July 2, 2020 9:45:46 PM(UTC)
brodiemac-too

brodiemac-too

Member Original PosterPosts: 22
0
Like
We are starting to inventory iPhones that are being imported from Intune. Each phone shows a valid AD user but when you click the link for the user, the device is not listed on the user page. Is there a way to create that asset relation automatically?
brodiemac-too
#1brodiemac-too Member Original PosterPosts: 22  
posted: 7/8/2020 2:06:01 PM(UTC)
I posed this question to support and they tell me it's a feature not yet built into LANSweeper. d'oh!
njordur
#2njordur Member Posts: 17  
posted: 7/10/2020 6:47:01 PM(UTC)
Originally Posted by: brodiemac-too Go to Quoted Post
We are starting to inventory iPhones that are being imported from Intune. Each phone shows a valid AD user but when you click the link for the user, the device is not listed on the user page. Is there a way to create that asset relation automatically?


I'm running this procedure on a sql agent job peridocally to fill this asset relations from intune in. This is only the insert part. Not handling updates.


Code:

create proc [dbo].[InsertIntune_User_Relations] as
  declare @domain as varchar(20)
  set @domain = '<YourDomain>'
  ;with missing_intune_users_cte as (
  select         
        intune.UserDisplayName as Intune_Displayname
        ,intune.UserPrincipalName as Intune_UPN
        ,SUBSTRING(intune.UserPrincipalName,1,CHARINDEX('@',intune.UserPrincipalName)-1) as Intune_Samaccountname
        ,intune.UserId as Intune_Userid
        ,intune.AssetId as Intune_Assetid
        ,intune.EnrolledDateTime as Intune_EnrollDateTime
      ,assr.[Username]
      ,assr.[Userdomain]
      ,assr.[AssetID]
      ,assr.[Type] --Type = 12
      ,assr.[StartDate]  
  from [tblIntuneDevice] intune
  left outer join [tblAssetUserRelations] assr on assr.AssetID = intune.assetid
  where assr.Username is null and intune.UserPrincipalName <> ''
  )
  insert into [tblAssetUserRelations] (Username,Userdomain,AssetID,[Type],[StartDate],Comments)
  select Intune_Samaccountname,@domain,Intune_Assetid,12,Intune_EnrollDateTime,'Imported from Intune' from missing_intune_users_cte
njordur
#3njordur Member Posts: 17  
posted: 7/10/2020 6:50:24 PM(UTC)
I also created a procedure to be run in the same schedule to be able to update the IMEI number from Intune to stick it to tblassetCustom. This was later used to find duplicates assets for example and those who were created manually before intune.

Code:

    create proc [dbo].[UpdateIntuneIMEI_On_Asset] as
    update tblassetcustom 
        set custom2 = intune.imei
    FROM [tblIntuneDevice] intune
    inner join tblassetcustom ass on ass.AssetID = intune.AssetId        
    where intune.imei <> '' and intune.imei not like '*%'
    and ass.Custom2 = ''

Active Discussions

Lansweeper Help Desk Workflow
by  lswanson   Go to last post Go to first unread
Last post: Yesterday at 11:12:21 PM(UTC)
Lansweeper Changing to remote scanning due to COVID
by  FrankSc  
Go to last post Go to first unread
Last post: Yesterday at 9:35:26 PM(UTC)
Lansweeper Not giving hackers the Domain Admin password / account
by  FrankSc   Go to last post Go to first unread
Last post: Yesterday at 9:27:13 PM(UTC)
Lansweeper LsAgent failing - Lansweeper SSL Expired
by  lansweeper25t34  
Go to last post Go to first unread
Last post: Yesterday at 8:33:28 PM(UTC)
Lansweeper Is there a chance to get the firewall off via Lansweeper?
by  EDV_OHZ   Go to last post Go to first unread
Last post: Yesterday at 4:57:26 PM(UTC)
Lansweeper Software List by Computer/Server Name
by  Andy.S   Go to last post Go to first unread
Last post: Yesterday at 8:06:43 AM(UTC)
Lansweeper Merge Asset button
by  KeithBecker  
Go to last post Go to first unread
Last post: 8/5/2020 9:27:54 PM(UTC)