
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2021 11:53 PM
we need to import about 1000 non computer devices and wanted to assign those devices to individual users with AD.
Is that possible?
Is that possible?
Labels:
- Labels:
-
General Discussion
2 REPLIES 2

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2021 04:50 PM
Once you bulk loaded the assets from the csv into tblAssets, you can create a user relation record between each asset having a Username+Userdomain to its user this way:
Set IDENTITY_INSERT [lansweeperdb].[dbo].[tblAssetUserRelations] ON
GO
DECLARE @offset integer;
set @offset = (Select Max(RelationID) + 1 from [lansweeperdb].[dbo].[tblAssetUserRelations]);
insert into [lansweeperdb].[dbo].[tblAssetUserRelations] (
[RelationID],[Username] ,[Userdomain] ,[AssetID] ,[Type] ,[Comments] ,[Lastchanged] ,[StartDate] ,[EndDate] ,[Ou] ,[AdObjectId] ,[IsLocalUser])
select ROW_NUMBER() OVER(PARTITION BY NULL ORDER BY AssetID) + @offset as RelationID,
a.Username,
a.Userdomain,
a.[AssetID],
12 as Type,
null as Comments,
GETDATE() as Lastchanged,
null as StartDate,
null as EndDate,
null as Ou,
null as AdObjectId,
case a.FQDN
when null then 1
else 0
end as IsLocalUser
FROM [lansweeperdb].[dbo].[tblAssets] a
Where Username > ''
Set IDENTITY_INSERT [lansweeperdb].[dbo].[tblAssetUserRelations] OFF
GO
Set IDENTITY_INSERT [lansweeperdb].[dbo].[tblAssetUserRelations] ON
GO
DECLARE @offset integer;
set @offset = (Select Max(RelationID) + 1 from [lansweeperdb].[dbo].[tblAssetUserRelations]);
insert into [lansweeperdb].[dbo].[tblAssetUserRelations] (
[RelationID],[Username] ,[Userdomain] ,[AssetID] ,[Type] ,[Comments] ,[Lastchanged] ,[StartDate] ,[EndDate] ,[Ou] ,[AdObjectId] ,[IsLocalUser])
select ROW_NUMBER() OVER(PARTITION BY NULL ORDER BY AssetID) + @offset as RelationID,
a.Username,
a.Userdomain,
a.[AssetID],
12 as Type,
null as Comments,
GETDATE() as Lastchanged,
null as StartDate,
null as EndDate,
null as Ou,
null as AdObjectId,
case a.FQDN
when null then 1
else 0
end as IsLocalUser
FROM [lansweeperdb].[dbo].[tblAssets] a
Where Username > ''
Set IDENTITY_INSERT [lansweeperdb].[dbo].[tblAssetUserRelations] OFF
GO

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2021 07:05 PM
ended up using SQL query.
