-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLenovoDeviceInfo.ps1
33 lines (25 loc) · 1.01 KB
/
LenovoDeviceInfo.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
[CmdletBinding()]
param (
[Parameter()]
[String]
$baseURL = "https://support.lenovo.com/us/en/api/v4/mse/getproducts?productId=",
[String]
[ValidateScript({Test-Path $_})]
$ModelTextFile = "$env:SystemDrive\Temp\LenovoModels.txt",
[String]
$OutputCSV = "$env:SystemDrive\Temp\LenovoModels.csv"
)
$ModelIDs = Get-Content -Path $ModelTextFile
$mainObj = @()
FOREACH ($Model in $ModelIDs) {
$URL = $baseURL + $Model
$WebContent = (Invoke-Webrequest -Uri $URL -UseBasicParsing -ContentType 'Application/JSON' -ErrorAction SilentlyContinue).Content | ConvertFrom-JSON
IF ($WebContent) {
$obj = New-Object psobject
$obj | Add-Member -MemberType NoteProperty -Name ModelID -Value $Model
$obj | Add-Member -MemberType NoteProperty -Name ModelName -Value $WebContent.Name
$obj | Add-Member -MemberType NoteProperty -Name IsSupported -Value $WebContent.IsSupported
$mainObj += $obj
}
}
$mainObj | Export-Csv -Path $OutputCSV -NoTypeInformation