DellWarrantyServiceTag.psm1
# Started from https://www.powershellgallery.com/packages/Get-DellWarranty/2.0.0.0 Function Get-DellWarrantyServiceTag { <# .SYNOPSIS Get DELL warranty servicetag .DESCRIPTION Get DELL Model, ShipDate, WarrantyStartDate, WarrantyEndDate, WarrantyLevel. .PARAMETER ServiceTag The dell ServiceTag. .PARAMETER ClientKey Get API client key on DELL techdirect https://techdirect.dell.com/Portal - go to APIs - request API key. .PARAMETER ClientSecret Get API client secret on DELL techdirect https://techdirect.dell.com/Portal - go to APIs - request API key. .EXAMPLE Get-DellWarrantyServiceTag -ServiceTag "<servicetag>" -ClientKey "<clientkey>" -ClientSecret "<clientsecret>" | Format-Table .NOTES author: Simon Willemen (thanks to Connor Hill) #> [CmdletBinding()] Param( [Parameter(Mandatory = $true)][String] $ServiceTag ,[Parameter(Mandatory = $true)][String] $ClientKey ,[Parameter(Mandatory = $true)][String] $ClientSecret ) [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $Auth = Invoke-WebRequest -UseBasicParsing -uri "https://apigtwb2c.us.dell.com/auth/oauth/v2/token?client_id=$ClientKey&client_secret=$ClientSecret&grant_type=client_credentials" -Method Post $AuthSplit = $Auth.Content -split ('"') $AuthKey = $AuthSplit[3] $Response = Invoke-WebRequest -UseBasicParsing -uri "https://apigtwb2c.us.dell.com/PROD/sbil/eapi/v5/asset-entitlements?servicetags=$ServiceTag" -Method Get -Headers @{"Authorization" = "bearer $AuthKey"; "Accept" = "application/json" } $Content = $Response.Content | ConvertFrom-Json [datetime]$WarrantyEndDate = (($Content.entitlements.endDate).split("T"))[-2] [datetime]$WarrantyStartDate = (($Content.entitlements.startDate).split("T"))[-2] [string]$WarrantyLevel = ($Content.entitlements.serviceLevelDescription)[-1] [datetime]$ShipDate = (($Content.shipDate).split("T"))[0] [string]$Model = $Content.systemDescription New-Object -TypeName PSObject -Property @{ ServiceTag = [string]$ServiceTag WarrantyEndDate = [datetime]$WarrantyEndDate WarrantyStartDate = [datetime]$WarrantyStartDate WarrantyLevel = [string]$WarrantyLevel ShipDate = [datetime]$ShipDate Model = [string]$Model } } |