ahahum wrote:
sandve wrote:
staadmin wrote:
from What LS suppoort is saying, this appears to be an issue with the change of Dell's web site. When I run this tool the Purchase date is OK but the warranty date is showing as -Warranty Date: '1/1/0001' Anyone have any idea how to fix this tool to show correct Warranty date? Any help is appreciated!
Here's a PowerShell script that will update the DB with info from Dells webservice.
The script looks good! Thank you for posting it!
Anyone give me a tip on how to modify this to use the lansweeper database on a remote SQL server?
I'm not very acclimated to powershell yet...it's on the to-do list.
Thanks!
I was able to change the code slightly to allow for connection to a remote sqlserver.
# Updates LanSweeper database with Dell warranty information
# Some code taken from http://poshcode.org/2482
Get-PSSnapin –registered
Add-PSSnapin SqlServerProviderSnapin100
Add-PSSnapin SqlServerCmdletSnapin100
Get-PSSnapin SQL*
cls
$SQLSVR = "Server\Instance"
$DB = "lansweeperdb"
$User = "username"
$Pwd = "Password"
$Query = "SELECT SerialNumber, Computername FROM lansweeperdb.dbo.tblSystemEnclosure WHERE LEN(serialnumber) = 7 AND Manufacturer LIKE 'Dell%'"
$SQLQry = Invoke-Sqlcmd -SuppressProviderContextWarning -ServerInstance $SQLSVR -Database $DB -Username $User -Password $Pwd -Query $Query
Foreach ($n in $SQLQry){
$SrvTag = $n | select -ExpandProperty serialnumber
$CompName = $n | select -ExpandProperty Computername
Write-Host
Write-Host
Write-Host $SrvTag ":" $CompName
$DummyGUID = New-Object GUID('11111111-1111-1111-1111-111111111111')
$AppName = "LS_DellWarrantyInfo.ps1"
$proxy = New-WebServiceProxy -URI 'http://xserv.dell.com/services/AssetService.asmx'
$proxy.GetAssetInformation($DummyGUID, $AppName, $SrvTag) | ForEach-Object {
$PurchaseDate = $_.AssetHeaderData.SystemShipDate
$WarrantyEndDate = get-date('02/23/1965')
Write-Host
Write-Host "Information for Service Tag" $_.AssetHeaderData.ServiceTag
Write-Host "Model:" $_.AssetHeaderData.SystemType $_.AssetHeaderData.SystemModel
Write-Host "Ship Date:" $_.AssetHeaderData.SystemShipDate.ToString('d')
$_ |
Select-Object -ExpandProperty Entitlements |
Select-Object -Property ServiceLevelDescription,Provider,StartDate,EndDate | ForEach-Object {
"{0,20}{1,-50}" -f "Entitlement:",$_.ServiceLevelDescription.Split(',')[1]
"{0,20} {1,-50}" -f "Provided by:",(% { if ($_.Provider -eq 'DELL') { 'Dell' } else {'Unisys'} })
"{0,20} {1,-50}" -f 'Starts:',$_.StartDate.ToString('d')
"{0,20} {1,-50}" -f 'Ends:',$_.EndDate.ToString('d')
if ($_.EndDate -gt $WarrantyEndDate) { $WarrantyEndDate = $_.EndDate }
}
Write-Host "Warranty End Date:" $WarrantyEndDate.ToString('d')
}
$SQLcommand = "UPDATE dbo.tblCompCustom SET Warrantydate = '$WarrantyEndDate', PurchaseDate = '$PurchaseDate' WHERE Computername = '$CompName' IF @@ROWCOUNT = 0 Insert into dbo.tblCompCustom (Computername, Warrantydate, Purchasedate) Values ('$CompName', '$WarrantyEndDate', '$PurchaseDate')"
Write-Host $SQLcommand
Invoke-Sqlcmd -SuppressProviderContextWarning -ServerInstance $SQLSVR -Database $DB -Username $User -Password $Pwd $SQLcommand
}
This worked for me.