iNNOKENTIY21
Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
Код: enum OS { Windows_10_64 = 45 Windows_10_32 = 44 Windows_8_1_64 = 41 Windows_8_1_32 = 40 Windows_8_32 = 35 Windows_8_64 = 36 Windows_7_64 = 30 Windows_7_32 = 29 Others = 8 } class AsusPDDrivers { [OS] $OS [string] $Url [string] $Motherboard hidden [string] $APIUrl = "https://www.asus.com/support/api/product.asmx/GetPDDrivers?website=us" [PSCustomObject] $DriverTools AsusPDDrivers([OS] $OS, [string] $Motherboard) { if (!$OS) {Throw "OS is null!"} if (!$Motherboard) {Throw "Motherboard is null!"} $this.OS = $OS $this.Motherboard = $Motherboard $this.Url = ( $this.APIUrl + "&osid=" + [int] $this.OS + "&model=" + $this.Motherboard ) $this.GetDriverTools() } [string[]] GetSectionNames() { return ($this.DriverTools | Select-Object name).Name } [PSCustomObject] GetLastInSection([string] $SectionName) { if (!$SectionName) {Throw "Section name is null!"} return ($this.DriverTools | Where-Object Name -EQ $SectionName).Files[0] } [PSCustomObject[]] GetLatest() { $result = foreach ($SectionName in $this.GetSectionNames()) { $this.GetLastInSection($SectionName) } return $result } [PSCustomObject] NotContains([PSCustomObject] $PreviousFiles) { if (!$PreviousFiles) {Throw "Previous files is null!"} return $this.DriverTools.Files | Where-Object {$Previous.id -notcontains $_.Id} } hidden [void] GetDriverTools() { [PSCustomObject] $Responce = [PSCustomObject]::new() try { $Responce = Invoke-RestMethod $this.Url } catch { Throw $_.Exception.Message } if ($Responce.Status -eq "SUCCESS") { $this.DriverTools = $Responce.Result.Obj } else { Throw "Request failed" } } }[font=monospace][/font] |
|