progrocker

Untitled

Dec 15th, 2017
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $uri = 'https://css.api.hp.com/productWarranty/v1/queries'
  2.  
  3. $serial = (Get-WmiObject Win32_SystemEnclosure).SerialNumber
  4. $modelSKU = (Get-WmiObject Win32_ComputerSystem | Select-Object *).SystemSKUNumber
  5. $model = (Get-WmiObject Win32_ComputerSystem | Select-Object *).Model
  6.  
  7. #Get HP Access Token
  8. $tokenuri = 'https://css.api.hp.com/oauth/v1/token'
  9. $apitokenbody = @{
  10.     apiKey    = '<KEY GOES HERE>'
  11.     apiSecret = '<SECRET GOES HERE>'
  12.     grantType = 'client_credentials'
  13.     scope     = 'warranty'
  14.  
  15. }
  16. #Get The access token needed for the Warranty API call. Access tokens expire
  17. $accesstoken = (Invoke-RestMethod -uri $tokenuri -Body $apitokenbody -Method Post -ContentType application/x-www-form-urlencoded -Verbose).Root.access_token
  18.  
  19. #Get HP Warranty Information
  20. #HP Warranty Check
  21. $hpwarranty = @{
  22.     Params =
  23.     @{
  24.         sn = "$serial"
  25.         pn = "$modelSKU"
  26.     }
  27.  
  28. } | ConvertTo-Json
  29. $warrantyinfo = Invoke-RestMethod -uri $uri -Body $hpwarranty -Headers @{Authorization = "Bearer $accesstoken"} -Method Post -ContentType application/json -Verbose
Advertisement
Add Comment
Please, Sign In to add comment