Invoke - Get Dell Warranty PowerShell with OAuth 2.0 - Windows (CIT)
Log In or Register to download the BES file, and more.

1 Votes

Description

This fixlet queries Dell's Service Website for current warranty information and writes the results to the Dell Folder of the ProgramData directory of the System Drive. A valid API Key and Secret must be used.

User has retrieved “client_id” and client_secret” from TechDirect API

Team - https://techdirect.dell.com/portal.30/Login.aspx

NOTE: This fixlet has no relevance to aid in re-application. It will reapply as often as you tell it to. You should add this to a baseline or action it alone and specify a reapplication frequency of anywhere from days to weeks. 

NOTE: This fixlet has no default action because it requires every endpoint to make an external web request. This request does not traverse the BigFix infrastructure and does require internet access.


Property Details

ID26710
StatusProduction - Fully Tested and Ready for Production
TitleInvoke - Get Dell Warranty PowerShell with OAuth 2.0 - Windows (CIT)
DomainBESC
SourceInternal
Source Release Date10/19/2020 12:00:00 AM
KeywordsDell Warranty, API, OAuth 2.0
Added by on 10/23/2020 11:50:52 AM
Last Modified by on 10/23/2020 11:50:52 AM
Counters 566 Views / 7 Downloads
User Rating 1 star 2 star 3 star 4 star 5 star * Average over 0 ratings. ** Log In or Register to add your rating.

Relevance

isWindows (Relevance 1172)
Used in 1130 fixlets and 535 analyses   * Results in a true/false
Show indented relevance
windows of operating system
Used in 5 fixlets   * Results in a true/false
Show indented relevance
exists string value whose (it as lowercase contains "dell") of selects "Manufacturer, Model from Win32_ComputerSystem" of wmi

Actions

Action 1 (default)

Action Link Click here to deploy this action.
Script Type BigFix Action Script
parameter "PowerShellExe"="{ pathname of file ((it as string) of value "Path" of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" of native registry) }"
parameter "ServiceTags"="{(string values of selects "SerialNumber from Win32_BIOS" of wmi)}"
parameter "dellFolder"="{name of drive of system folder & "\ProgramData\Dell"}"

action parameter query "ApiKey" with description "Please enter the Dell API Key"
action parameter query "KeySecret" with description "Please enter Dell API Secret"

delete __createfile
delete run.ps1

createfile until _end_
Param(
[Parameter(Mandatory = $true)]
$ServiceTags,
[Parameter(Mandatory = $true)]
$ApiKey,
[Parameter(Mandatory = $true)]
$KeySecret
)

[String]$servicetags = $ServiceTags -join ", "

$AuthURI = "https://apigtwb2c.us.dell.com/auth/oauth/v2/token"
$OAuth = "$ApiKey`:$KeySecret"
$Bytes = [System.Text.Encoding]::ASCII.GetBytes($OAuth)
$EncodedOAuth = [Convert]::ToBase64String($Bytes)
$Headers = @{{ }
$Headers.Add("authorization", "Basic $EncodedOAuth")
$Authbody = 'grant_type=client_credentials'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Try {{
$AuthResult = Invoke-RESTMethod -Method Post -Uri $AuthURI -Body $AuthBody -Headers $Headers
$Global:token = $AuthResult.access_token
}
Catch {{
$ErrorMessage = $Error[0]
Write-Error $ErrorMessage
BREAK
}
Write-Host "Access Token is: $token`n"

$headers = @{{"Accept" = "application/xml" }
$headers.Add("Authorization", "Bearer $token")

$params = @{{ }
$params = @{{servicetags = $servicetags; Method = "GET" }

$Global:response = Invoke-RestMethod -Uri "https://apigtwb2c.us.dell.com/PROD/sbil/eapi/v5/asset-entitlements" -Headers $headers -Body $params -Method Get -ContentType "application/xml" -OutFile "{name of drive of system folder}\ProgramData\Dell\BigFixDellWarranty.xml"
_end_

move __createfile run.ps1

if {not exist folder (parameter "dellFolder")}
folder create "{parameter "dellFolder"}"
endif

waithidden "{parameter "PowershellExe"}" -ExecutionPolicy Bypass -File run.ps1 -ServiceTags "{parameter "ServiceTags"}" -ApiKey "{parameter "ApiKey"}" -KeySecret "{parameter "KeySecret"}"
Success Criteria

This action will be considered successful when all lines of the action script have completed successfully.


Sharing

Social Media:
Share this page on Yammer

Comments

Log In or Register to leave comments!