cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Joshua
Engaged Sweeper III
I followed the documentation and am able to pull all of the data from our Chrome Admin Console into Lansweeper. The problem I'm finding is there's no IP address so the IP Location is undefined. I get it, the integrated scanning is just pulling data from the Admin Console and there's no IP address field in there so tough.

Is there no way to locally scan the devices by direct IP? They ping and Lansweeper tries to get some basic data on them but fails so no record gets generated for the IP address I'm scanning. Can I add some sort of local back door account to them and treat them like a Linux machine using that account in Lansweeper for access?

For now, I'm probably just going to write a script that triggers an hour after the Chrome Admin pull that scans DHCP for the MAC addresses and then adds the IP Address field to the database. Just wondering if there's a better way that other people are using.
1 REPLY 1
Joshua
Engaged Sweeper III
Okay this is my nightly PowerShell script that will use DHCP so these devices will be assigned an Asset Location. Still interested in how other people are tackling this problem as there might be a better way.


# Variables you must set
$DHCPServer = "TYPEYOURDHCPSERVERNAMEHERE"
$LANSW = "TYPEYOURLANSWEEPERSQLSERVERINFOHERE"

# Get every lease in DHCP (Takes about 5 minutes to run for me, everything else is pretty quick)
$DHCPLeases = @()
$DHCPScopes = Get-DhcpServerv4Scope -ComputerName $DHCPSERVER
foreach ($Scope in $DHCPScopes.ScopeId){
$DHCPLeases += Get-DhcpServerv4Lease -ComputerName $DHCPSERVER -AllLeases -ScopeId $Scope
}

# Gets the Ethernet MAC address of every ChromeOS Device pulled from the admin console by the nightly midnight scan
$query = "select chrome.EthernetMacAddress from tblassets ass left join tblChromeOs chrome on ass.assetid = chrome.assetid where assettype = 84"
$lanswmacs = invoke-sqlcmd -serverinstance $LANSW -database lansweeperdb -ConnectionTimeout 30 -QueryTimeout 300 -query $query

# Convert MACS to match DHCP
$MACS = $lanswmacs.EthernetMacAddress -replace ':', '-'

# Get IP Address for each ChromeOS MAC found in DHCP
$MACStoImport = @()
foreach ($MAC in $MACS){
if ($MAC -in $DHCPLeases.ClientID){
$obj = new-object psobject
$obj | add-member noteproperty MAC ($MAC -replace '-', ':')
$obj | add-member noteproperty IP ($DHCPLeases | ? {$_.clientid -match $MAC}).IPAddress.IPAddressToString
$MACStoImport += $obj
}
}

# Import the Data into Lansweeper
foreach ($item in $MACStoImport){

# Update the IPAddress field
$query = "
UPDATE tblassets
SET IPAddress = '$($item.IP)'
FROM tblassets
LEFT JOIN tblChromeOs on tblassets.assetid = tblChromeOs.assetid
WHERE tblChromeOs.EthernetMacAddress like '$($item.Mac)'
"
invoke-sqlcmd -serverinstance $LANSW -database lansweeperdb -ConnectionTimeout 30 -QueryTimeout 300 -query $query

# Update the IPNumeric field
[long]$IPNum = ($item.IP.Split('.') | ForEach-Object {$_.PadLeft(3,'0')}) -join ''

$query = "
UPDATE tblassets
SET IPNumeric = $IPNum
FROM tblassets
LEFT JOIN tblChromeOs on tblassets.assetid = tblChromeOs.assetid
WHERE tblChromeOs.EthernetMacAddress like '$($item.Mac)'
"
invoke-sqlcmd -serverinstance $LANSW -database lansweeperdb -ConnectionTimeout 30 -QueryTimeout 300 -query $query

# Update the LocationID field
$ipsearch = $item.IP.Substring(0, $item.IP.lastIndexOf('.')) + '.%'
$query = "select LocationID from tsysIPLocations where realstart like '$ipsearch'"
$LocID = (invoke-sqlcmd -serverinstance $LANSW -database lansweeperdb -ConnectionTimeout 30 -QueryTimeout 300 -query $query).LocationID

$query = "
UPDATE tblassets
SET LocationID = $LocID
FROM tblassets
LEFT JOIN tblChromeOs on tblassets.assetid = tblChromeOs.assetid
WHERE tblChromeOs.EthernetMacAddress like '$($item.Mac)'
"
invoke-sqlcmd -serverinstance $LANSW -database lansweeperdb -ConnectionTimeout 30 -QueryTimeout 300 -query $query
}