For quite some time we have had warranty reporting for Dell, Lenovo, and GETAC devices. We used to also support Microsoft devices but, unfortunately, both Microsoft and HP have taken their warranty API’s offline. We have chosen not to bring this functionality into Intune as we expect that Microsoft will add it natively to Intune soon. However, some customers need the data now, so we are providing this solution as a work-around until we see what the native Intune warranty information looks like once it is released.
We aren’t going to pretend this is a complete, robust solution but it will give you the warranty end date in a report. Hopefully this is helpful while we wait for Microsoft to bring us a better solution.
Note: The script has code in it to collect warranty data for Microsoft devices however Microsoft has taken their API offline.
############ Enable Warranty Vendors ###############
$DellWarranty = $true
$LenovoWarranty = $false
$MicrosoftWarranty = $false
$GetacWarranty = $false
##### Warranty Vendor API Keys
$DellClientID = "XXXXXXXX"
$DellClientSecret = "XXXXXXXXX"
$LenovoClientID = ""
######### functions ##########
function Get-DellWarranty([Parameter(Mandatory = $true)]$SourceDevice, $client) {
$AuthURI = "https://apigtwb2c.us.dell.com/auth/oauth/v2/token"
if ($Global:TokenAge -lt (get-date).AddMinutes(-55)) { $global:Token = $null }
If ($null -eq $global:Token) {
$OAuth = "$DellClientID`:$DellClientSecret"
$Bytes = [System.Text.Encoding]::ASCII.GetBytes($OAuth)
$EncodedOAuth = [Convert]::ToBase64String($Bytes)
$headersAuth = @{ "authorization" = "Basic $EncodedOAuth" }
$Authbody = 'grant_type=client_credentials'
$AuthResult = Invoke-RESTMethod -Method Post -Uri $AuthURI -Body $AuthBody -Headers $HeadersAuth
$global:token = $AuthResult.access_token
$Global:TokenAge = (get-date)
}
$headersReq = @{ "Authorization" = "Bearer $global:Token" }
$ReqBody = @{ servicetags = $SourceDevice }
$WarReq = Invoke-RestMethod -Uri "https://apigtwb2c.us.dell.com/PROD/sbil/eapi/v5/asset-entitlements" -Headers $headersReq -Body $ReqBody -Method Get -ContentType "application/json"
if ($warreq.entitlements.serviceleveldescription) {
$WarObj = [PSCustomObject]@{
'Provider' = 'Dell'
'Product' = $warreq.productLineDescription
'SerialNumber' = $SourceDevice
'Warranty' = $warreq.entitlements.serviceleveldescription -join "`n"
'StartDate' = (($warreq.entitlements.startdate | sort-object -Descending | select-object -last 1) -split 'T')[0]
'EndDate' = (($warreq.entitlements.enddate | sort-object | select-object -last 1) -split 'T')[0]
'Client' = $Client
}
}
else {
$WarObj = [PSCustomObject]@{
'Provider' = 'Dell'
'Product' = $null
'SerialNumber' = $SourceDevice
'Warranty' = 'Could not get warranty information'
'StartDate' = $null
'EndDate' = $null
'Client' = $Client
}
}
return $WarObj
}
function Get-LenovoWarranty([Parameter(Mandatory = $true)]$SourceDevice, $client) {
$headersReq = @{ "ClientID" = $LenovoClientID }
$WarReq = Invoke-RestMethod -Uri "http://supportapi.lenovo.com/V2.5/Warranty?Serial=$SourceDevice" -Headers $headersReq -Method Get -ContentType "application/json"
try{
$Warlist = $WarReq.Warranty | Where-Object {($_.ID -eq "36Y") -or ($_.ID -eq "3EZ") -or ($_.ID -eq "12B") -or ($_.ID -eq "1EZ")}
$WarObj = [PSCustomObject]@{
'Provider' = 'Lenovo'
'Product' = $WarReq.Product
'SerialNumber' = $SourceDevice
'Warranty' = $Warlist.Name -join "`n"
'StartDate' = (($Warlist.Start | sort-object -Descending | select-object -last 1) -split 'T')[0]
'EndDate' = (($Warlist.End | sort-object | select-object -last 1) -split 'T')[0]
'Client' = $Client
}
}catch{
$WarObj = [PSCustomObject]@{
'Provider' = 'Lenovo'
'Product' = $null
'SerialNumber' = $SourceDevice
'Warranty' = 'Could not get warranty information'
'StartDate' = $null
'EndDate' = $null
'Client' = $Client
}
}
return $WarObj
}
function Get-MSWarranty([Parameter(Mandatory = $true)]$SourceDevice, $client) {
$body = ConvertTo-Json @{
sku = "Surface_"
SerialNumber = $SourceDevice
ForceRefresh = $false
}
$PublicKey = Invoke-RestMethod -Uri 'https://surfacewarrantyservice.azurewebsites.net/api/key' -Method Get
$AesCSP = New-Object System.Security.Cryptography.AesCryptoServiceProvider
$AesCSP.GenerateIV()
$AesCSP.GenerateKey()
$AESIVString = [System.Convert]::ToBase64String($AesCSP.IV)
$AESKeyString = [System.Convert]::ToBase64String($AesCSP.Key)
$AesKeyPair = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("$AESIVString,$AESKeyString"))
$bodybytes = [System.Text.Encoding]::UTF8.GetBytes($body)
$bodyenc = [System.Convert]::ToBase64String($AesCSP.CreateEncryptor().TransformFinalBlock($bodybytes, 0, $bodybytes.Length))
$RSA = New-Object System.Security.Cryptography.RSACryptoServiceProvider
$RSA.ImportCspBlob([System.Convert]::FromBase64String($PublicKey))
$EncKey = [System.Convert]::ToBase64String($rsa.Encrypt([System.Text.Encoding]::UTF8.GetBytes($AesKeyPair), $false))
$FullBody = @{
Data = $bodyenc
Key = $EncKey
} | ConvertTo-Json
$WarReq = Invoke-RestMethod -uri "https://surfacewarrantyservice.azurewebsites.net/api/v2/warranty" -Method POST -body $FullBody -ContentType "application/json"
if ($WarReq.warranties) {
$WarObj = [PSCustomObject]@{
'Provider' = 'Microsoft'
'Product' = $WarReq.device.title
'SerialNumber' = $SourceDevice
'Warranty' = $WarReq.warranties.name -join "`n"
'StartDate' = (($WarReq.warranties.effectivestartdate | sort-object -Descending | select-object -last 1) -split 'T')[0]
'EndDate' = (($WarReq.warranties.effectiveenddate | sort-object | select-object -last 1) -split 'T')[0]
'Client' = $Client
}
}
else {
$WarObj = [PSCustomObject]@{
'Provider' = 'Microsoft'
'Product' = $null
'SerialNumber' = $SourceDevice
'Warranty' = 'Could not get warranty information'
'StartDate' = $null
'EndDate' = $null
'Client' = $Client
}
}
return $WarObj
}
function Get-GetacWarranty([Parameter(Mandatory = $true)]$SourceDevice, $client) {
$WarReq = Invoke-RestMethod -Uri https://api.getac.us/rma-manager/rma/verify-serial?serial=$SerialNumber -Method Get -ContentType "application/json"
try{
$WarObj = [PSCustomObject]@{
'Provider' = 'Getac'
'Product' = $WarReq.model
'SerialNumber' = $SourceDevice
'Warranty' = $WarReq.warrantyType
'StartDate' = $null
'EndDate' = (($warreq.endDeviceWarranty | sort-object | select-object -last 1) -split 'T')[0]
'Client' = $Client
}
}catch{
$WarObj = [PSCustomObject]@{
'Provider' = 'Getac'
'Product' = $null
'SerialNumber' = $SourceDevice
'Warranty' = 'Could not get warranty information'
'StartDate' = $null
'EndDate' = $null
'Client' = $Client
}
}
return $WarObj
}
##############################
########### Main #############
##############################
$Bios = Get-WmiObject Win32_Bios
$Make = $Bios.Manufacturer
$SerialNumber = $Bios.SerialNumber
If ($DellWarranty -and $Make -eq "Dell Inc."){
write-host "Dell computer found" -ForegroundColor Green
$WarObj = Get-DellWarranty -SourceDevice $SerialNumber -Client $env:COMPUTERNAME
}
ElseIf($LenovoWarranty -and $Make -eq "LENOVO") {
write-host "LENOVO computer found" -ForegroundColor Green
$WarObj = Get-LenovoWarranty -SourceDevice $SerialNumber -Client $env:COMPUTERNAME
}
ElseIf ($MicrosoftWarranty -and $Make -eq "Microsoft Corporation") {
write-host "Microsoft computer found" -ForegroundColor Green
$WarObj = Get-MSWarranty -SourceDevice $SerialNumber -Client $env:COMPUTERNAME
}
ElseIf ($GetacWarranty -and $Make -eq "INSYDE Corp.") {
write-host "Getac computer found" -ForegroundColor Green
$WarObj = Get-GetacWarranty -SourceDevice $SerialNumber -Client $env:COMPUTERNAME
}
Else{
write-host "$Make warranty not supported" -ForegroundColor Red
$WarObj = $null
}
$WarObj
$EndDate = $WarObj.EndDate
if ($WarObj){
# Set Vars for WMI Info
Write-Host $EndDate
Exit 0
}
else {
Write-Host 'Not Found'
Exit 1
}
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |