Notification

Icon
Error

12>
TBMPS
#0TBMPS Member Posts: 3  
posted: 1/4/2021 1:47:06 PM(UTC)
I am not looking at my servers. I am looking at my desktops and laptops.
mwrobo09
#1mwrobo09 Member Posts: 56  
posted: 1/13/2021 7:28:28 PM(UTC)
Zaty,

This saved me so much time. I can't thank you enough.

I altered your script slightly to pull the purchase date as well. Uploaded 1600 devices with missing information within a few hours. Would have taken me forever, now I have reliable data for planning.

Thanks again.

Code:

$assets = Invoke-Sqlcmd -ServerInstance server -Database lansweeperdb -Username lansweeperuser -Password 'password' -Query @"
SELECT a.AssetID, a.AssetName, b.Serialnumber, b.SystemSKU
FROM lansweeperdb.dbo.tblAssets a, lansweeperdb.dbo.tblAssetCustom b
WHERE a.AssetID = b.AssetID AND
a.Assettype = -1 AND
b.Warrantydate is NULL AND
b.Manufacturer in ('HP','Hewlett-Packard');
"@
 
foreach ($asset in $assets) {
    $assetId = $asset.AssetID
    $assetName = $asset.AssetName
 
    $warranty = ((Get-HPIncWarrantyEntitlement -SerialNumber $asset.SerialNumber -ProductNumber $asset.SystemSKU).OverallEntitlementEndDate | Measure-Object -Maximum).Maximum
    $StartDate = ((Get-HPIncWarrantyEntitlement -SerialNumber $asset.SerialNumber -ProductNumber $asset.SystemSKU).OverallEntitlementStartDate | Measure-Object -Minimum).Minimum
    Write-Output "$assetID  $assetName  $warranty  $StartDate"
 
    Invoke-Sqlcmd -ServerInstance server -Database lansweeperdb -Username lansweeperuser -Password 'password' -Query @"
    UPDATE dbo.tblAssetCustom
    SET Warrantydate = '$warranty',PurchaseDate = '$StartDate'
    WHERE assetID = $assetId
"@
}


12>

Active Discussions

Lansweeper Freelance for Lansweeper Deploy?
by  Brandon   Go to last post Go to first unread
Last post: Yesterday at 6:32:21 PM(UTC)
Lansweeper Translation settings not saved
by  Peter Andersson  
Go to last post Go to first unread
Last post: Yesterday at 9:27:30 AM(UTC)
Lansweeper Installation issues
by  Richie_Rich   Go to last post Go to first unread
Last post: 5/6/2021 11:29:09 PM(UTC)
Lansweeper Cloud relay data stored time
by  Richie_Rich  
Go to last post Go to first unread
Last post: 5/6/2021 11:14:42 PM(UTC)
Lansweeper Custom attributes from AD
by  dhoward   Go to last post Go to first unread
Last post: 5/6/2021 11:10:45 PM(UTC)
Lansweeper User View Customization
by  DarkOne77  
Go to last post Go to first unread
Last post: 5/6/2021 10:50:30 PM(UTC)
Lansweeper Lsagent service exits with error
by  Orion Poplawski   Go to last post Go to first unread
Last post: 5/6/2021 3:56:29 PM(UTC)
Lansweeper CPU Benchmark Integration
by  neil.mowforth  
Go to last post Go to first unread
Last post: 5/6/2021 1:17:39 PM(UTC)