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 Rest API for Scanning
by  Brian Smith   Go to last post Go to first unread
Last post: Today at 7:35:27 PM(UTC)
Lansweeper Language translation not working anymore
by  Florian  
Go to last post Go to first unread
Last post: Today at 6:03:19 PM(UTC)
Lansweeper Use current user for scanning credentials?
by  pryan67   Go to last post Go to first unread
Last post: Today at 6:01:33 PM(UTC)
Lansweeper Bluetooth Info
by  FrankSc  
Go to last post Go to first unread
Last post: Today at 5:42:59 PM(UTC)
Lansweeper Question about Scanning Assets and Password Encryption
by  FrankSc   Go to last post Go to first unread
Last post: Today at 5:23:05 PM(UTC)
Lansweeper How to enable HTTPS in ver 6.0.150.60
by  Duncan.Miles  
Go to last post Go to first unread
Last post: Today at 1:11:19 PM(UTC)
Lansweeper INFO DateTimeService time refresh
by  miharix   Go to last post Go to first unread
Last post: Yesterday at 3:22:29 PM(UTC)
Lansweeper MS Edge Chromium LanSweeper Extension development
by  Slim D  
Go to last post Go to first unread
Last post: 1/15/2021 11:39:29 AM(UTC)