powershell - WMI Warranty information -


i have powershell script(1) collects warranty information dell system , display screen. have second script(2) creates wmi namespace , (3)one class. trying information gathered warranty script end in wmi class can pull through sccm. code below have far. appreciated. (1)

{     $service = new-webserviceproxy -uri http://{143.166.84.118}/services/assetservice.asmx?wsdl      if($args.count -ne 0){         $serial = $args[0]     }     else {         $system = get-wmiobject win32_systemenclosure         $serial = $system.serialnumber     }     $guid = [guid]::newguid()     $info = $service.getassetinformation($guid,'check_warranty.ps1',$serial)     if($info.count -eq 0)     {         write-host "machine not dell"     }     else     {         $warranty = $info[0].entitlements[0]         $expires = $warranty.enddate         $days_left = $warranty.daysleft         if($days_left -eq 0)         {             write-host "warranty has expired"         }         else{             `enter code here`             set objwmiservice = getobject("winmgts:\\computer\root\warranty")             set colitems = objwmiservice.execquery("select * warranty_warranty")              objitem.warranty = $expires             objitem.put_             next              write-host "warranty expires $expires."             write-host "warranty valid $days_left days."         }     } } 

(2)

'create namespace  strcomputer = "."  set objwmiservice = getobject("winmgmts:\\" & strcomputer & "\root")  set objitem = objwmiservice.get("__namespace") set objnamespace = objitem.spawninstance_  objnamespace.name = "warranty" objnamespace.put_ ' 

(3)

' $newclass = new-object system.management.managementclass `     ("root\warranty", [string]::empty, $null);   $newclass["__class"] = "warranty";   $newclass.qualifiers.add("static", $true) $newclass.properties.add("warranty", `     [system.management.cimtype]::string, $false) $newclass.properties["warranty"].qualifiers.add("key", $true)   $newclass.put()'`enter code here` 


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -