cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JSme58
Engaged Sweeper

Currently no function is available to have lansweeper natively discover the serial numbers or any other information regarding Dell docking stations. My solution is a bit lengthy, but it got the results I needed. 

TL:DR end result is a custom field titled "Docking Station" being filled with the serial number of the docking station plugged in to that computer that day. 

1. You need to have "Dell Command Monitor" installed on dell laptops. It will do forced restart on silent install so the "norestart" is necessary since the data we need will be compiled without reboot.

This is the deployment I set up for that:

<Name>32Dell Command Monitor</Name>
<Description></Description>
<ShutdownOption>0</ShutdownOption>
<ShutdownTime>0</ShutdownTime>
<MaxDuration>900</MaxDuration>
<Rescan>True</Rescan>
<RunMode>2</RunMode>
<Steps>
<Step>
<Nr>1</Nr>
<Name>Install</Name>
<Type>1</Type>
<ReturnCodes>0,1641,3010</ReturnCodes>
<Success>-1</Success>
<Failure>-3</Failure>
<Path>{PackageShare}\</Path>
<Parameters></Parameters>
<MSIParameters>/i /qn /norestart</MSIParameters>
<MSIName></MSIName>
<MSIVersion></MSIVersion>
<Command>msiexec.exe /q /i "{PackageShare}\Installers\Dell\Command_Monitor_x64.msi" /norestart</Command>
<EditMode>True</EditMode>
<Conditions />
</Step>
<Step>
<Nr>2</Nr>
<Name>Registry Script</Name>
<Type>2</Type>
<ReturnCodes>0,1641,3010</ReturnCodes>
<Success>-2</Success>
<Failure>-3</Failure>
<Path></Path>
<Parameters></Parameters>
<MSIParameters></MSIParameters>
<MSIName></MSIName>
<MSIVersion></MSIVersion>
<Command>powershell.exe -executionpolicy unrestricted -file "{PackageShare}\Scripts\DockRegistry.ps1"</Command>
<EditMode>False</EditMode>
<Conditions />
</Step>
</Steps>
<SoftwareVersion>10.3.2.0</SoftwareVersion>
</Package>

2. The powershell script that I have running on the second step calls the new information that is now available through the install of command monitor, and creates a registry key with the relevant data. Computer Name, Current User, Dock Service Tag.

DockRegistry.ps1:

$output = Get-CimInstance -Namespace root\dcim\sysman -ClassName DCIM_Chassis | Where-Object {$_.Name -eq "WD19TB"} | select Tag,Name | ForEach-Object {
$computer = $_.Name
$computerInfo = Get-WmiObject -Class Win32_ComputerSystem
$userInfo = Get-WmiObject -Class Win32_ComputerSystem | Select-Object UserName
[PSCustomObject]@{
'ComputerName' = $computerInfo.Name
'User' = $userInfo.UserName
'Tag' = $_.Tag
}
}
$output | ForEach-Object {
New-Item -Path "HKLM:\Software\ReportValues" | Out-Null
New-ItemProperty -Path "HKLM:\Software\ReportValues" -Name "ComputerName" -Value $_.ComputerName -PropertyType String -Force
New-ItemProperty -Path "HKLM:\Software\ReportValues" -Name "User" -Value $_.User -PropertyType String -Force
New-ItemProperty -Path "HKLM:\Software\ReportValues" -Name "DockST" -Value $_.Tag -PropertyType String -Force
}

3. I then created a registry scan for the "Report Values\DockST" so that I get the service tag of the dock as a value in the lansweeper database.

(The next part is messing with the lansweeper DB which is frowned upon by the devs. So always backup before doing anything even if it's this basic.) 

4. This only works if you have the lansweeper DB on a true SQL instance since you need to run a script against the DB.

This script takes the result from the Registry scan and plugs it in to first Custom field for an asset if it has an entry.

UPDATE dbo.tblAssetCustom
SET dbo.tblAssetCustom.Custom1 = dbo.tblRegistry.value
FROM dbo.tblAssetCustom INNER JOIN dbo.tblRegistry
ON dbo.tblAssetCustom.AssetID = dbo.tblRegistry.AssetID
WHERE tblRegistry.Regkey LIKE '%ReportValues%'

When I confirmed it worked I just changed the display name for the field to "Dock Service Tag".

Now that all of this is put together, and you know where to find everything. One thing that can be done is to attach the powershell script to the event 9002 which is the event for when a thunderbolt device is attached. Then set the db copy job to go off after scans.

1 REPLY 1
Obi_1_Cinobi
Lansweeper Tech Support
Lansweeper Tech Support

Hello there!

That's an impressive workaround, indeed. Before running custom database scripts on your database, we do highly recommend taking a backup first: https://community.lansweeper.com/t5/lansweeper-maintenance/back-up-your-installation/ta-p/64309

New to Lansweeper?

Try Lansweeper For Free

Experience Lansweeper with your own data.
Sign up now for a 14-day free trial.

Try Now