Jump to content

Joe.McCall

Members
  • Content Count

    70
  • Joined

  • Last visited

  • Days Won

    8

Joe.McCall last won the day on February 1

Joe.McCall had the most liked content!

Community Reputation

16 Good

My Information

  • Location
    Tri Cities, WA USA
  • Agent Count
    1000 - 1500 Agents

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. The functions I posted on March 9 and March 11 are independent of the code in the original post.
  2. Updated functions for the new Dell v5 API. They switched to OAUTH2, so you have to request a new API key and get a client ID & secret from them. First is updated Get-DellWarrantyInfo, which is reworked with the new API and request format. Function Get-DellWarrantyInfo { Param( [Parameter( Mandatory = $true, ParameterSetName = '', ValueFromPipeline = $true)] [Array]$ServiceTags, [Parameter( Mandatory = $true, ParameterSetName = '', ValueFromPipeline = $true)] [Array]$AccessToken ) $AuthHeader = @{Authorization="Bearer $AccessToken"} $JobResponse = Invoke-RestMethod -Method Get -Uri "https://apigtwb2c.us.dell.com/PROD/sbil/eapi/v5/asset-entitlements?servicetags=$ServiceTags" -headers $AuthHeader -ContentType 'application/json' $AllComputerWarranties = $JobResponse | ?{ $_.entitlements } | %{ $ThisComputerApiResponse = $_ $ShipDate = $ThisComputerApiResponse.shipDate $ThisComputerWarranties = $ThisComputerApiResponse.entitlements | ?{ $_.ServiceLevelCode -notlike "D" } $WarrantyStart = $ThisComputerWarranties | sort startDate | Select -First 1 -ExpandProperty startDate $WarrantyEnd = $ThisComputerWarranties | sort EndDate | Select -Last 1 -ExpandProperty endDate if(-not [String]::IsNullOrEmpty($ShipDate) -and -not [String]::IsNullOrEmpty($WarrantyEnd)) { New-Object psobject -Property @{"WarrantyEndDate"=[DateTime]::Parse($WarrantyEnd.SubString(0,10));"ShipDate"=[DateTime]::Parse($ShipDate.SubString(0,10));"SerialNumber"=$_.ServiceTag} } else { Write-Warning "Invalid Warranty Info received for ServiceTag: $($ThisComputerApiResponse.ServiceTag) ShipDate: $ShipDate WarrantyEnd: $WarrantyEnd `r`n$($ThisComputerWarranties)" } } $AllComputerWarranties } And the tweaked Update-MissingDellWarranties function, which now requires ClientID and ClientSecret instead of just an API key. Function Update-MissingDellWarranties { Param( [Parameter( Mandatory = $true, ParameterSetName = '', ValueFromPipeline = $true)] [string]$DellClientId, [Parameter( Mandatory = $true, ParameterSetName = '', ValueFromPipeline = $true)] [string]$DellClientSecret ) $ComputersMissingWarranty = Get-LabtechData -Query "select ComputerID, BiosVer, (case WarrantyEnd when '0000-00-00 00:00:00' then '1979-01-01' else WarrantyEnd end) as 'WarrantyEnd' from computers where BiosMFG = 'Dell' and length(trim(BiosVer)) = 7 and (WarrantyEnd='0000-00-00 00:00:00' or assetdate > WarrantyEnd)" if($ComputersMissingWarranty.Count -eq 0) { "No Dell computers missing warranty" return } $uri = "https://apigtwb2c.us.dell.com/auth/oauth/v2/token" if(-not $AccessToken) { $AuthResponse = Invoke-RestMethod -Method Post -Uri $uri -Body "client_id=$DellClientID&client_secret=$DellClientSecret&grant_type=client_credentials" -ContentType "application/x-www-form-urlencoded" if(-not $AuthResponse) { "Dell API timed out while obtaining access token. Plese try again later" return } $AccessToken = $AuthResponse | select -ExpandProperty access_token } Write-Host "AccessToken: $AccessToken" $Chunks = Split-Array -inArray $ComputersMissingWarranty -size 100 foreach($Chunk in $Chunks){ $WarrantyInfoArray = @() $WarrantyInfoArray += Get-DellWarrantyInfo -ServiceTags $($Chunk.BiosVer -join ',') -AccessToken $AccessToken $WarrantyInfoArray | %{ $WarrantyInfo = $_ $ComputerID = $ComputersMissingWarranty | ?{$_.biosver -like $WarrantyInfo.SerialNumber} | select -first 1 -ExpandProperty ComputerID Update-WarrantyInLabTech -ComputerID $ComputerID -ShipDate $WarrantyInfo.ShipDate -WarrantyEndDate $WarrantyInfo.WarrantyEndDate } } }
  3. @scubes13 @MidbossQ Quick and dirty using the HPWarranty powershell module. In my debugging I found that the start and end dates were coming back as arrays (some times as many as 3 dates each), but the first entry seems the be the active warranty/care pack entitlement. Ran successfully against a couple hundred workstations in our db. Function Update-MissingHPWarranties-PSModule { $HPComputers = Get-LabtechData -query "select ComputerID, BiosVer sn, (case WarrantyEnd when '0000-00-00 00:00:00' then '1979-01-01' else WarrantyEnd end) as 'WarrantyEnd', inv_chassis.SKUNumber pn from computers join inv_chassis using(computerid) where BiosMFG like 'h%p%' and (WarrantyEnd='0000-00-00 00:00:00' or assetdate > WarrantyEnd)" "$($HPComputers.Count) HP computers found in need of warranty information" for($i=0;$i -lt $HPComputers.Count;$i++) { $WarrantyInfo = Get-HPIncWarrantyEntitlement -SerialNumber $HPComputers[$i].sn -ProductNumber $HPComputers[$i].pn if($WarrantyInfo.OverallEntitlementStartDate -ne $null) { try { if(($WarrantyInfo.OverallEntitlementEndDate | Measure-Object).Count -gt 1) { $end = $([DateTime]::Parse($WarrantyInfo.OverallEntitlementEndDate[0])) }else{ $end = $([DateTime]::Parse($WarrantyInfo.OverallEntitlementEndDate)) } if(($WarrantyInfo.OverallEntitlementStartDate | Measure-Object).Count -gt 1) { $start = $([DateTime]::Parse($WarrantyInfo.OverallEntitlementStartDate[0])) }else{ $start = $([DateTime]::Parse($WarrantyInfo.OverallEntitlementStartDate)) } Update-WarrantyInLabTech -ComputerID $HPComputers[$i].ComputerID -ShipDate $start -WarrantyEndDate $end -ErrorAction Stop } catch { Write-Output "Error updating $($HPComputers[$i].ComputerID): End date: $end" } } else { Write-Output "No Warranty Info returned for $($HPComputers[$i].ComputerID)" } } }
  4. Use Shell, rather than Console Shell. Anything console runs in the user's context, which even under a local admin should not be elevated by default. Shell runs as the System account. Just make sure your config file has <Display Level="None" AcceptEULA="TRUE" /> for the silent flag.
  5. I have a search that grabs probe computers that also have a cache directory set (see attached image). Script runs against the group. Typical setup for us has the cache and probe on the same box, single server networks.
  6. Gen10 servers use the Agentless Management Service, which installs the System Management Assistant Service but it is disabled by default. Change it to auto-start and configure SNMP role in Windows like you did for previous generations, works like a charm. I have a remote monitor that runs on all my G10 servers: "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass try{$svc = Get-Service -Name sma -ErrorAction Stop;if($svc.StartType -eq 'Disabled'){Set-Service -Name sma -StartupType Automatic;Start-Service -Name sma;Write-Host "Set to Auto-Start";}else{Write-Host "Set to Auto-Start";}}catch{Write-Host "Failed to get service status:" $_.Exception.Message}
  7. It went through fine without the quotes on MaraiDB, but I noticed it highlighted in SQLyog so I figured I would mention it, in case there are potential issues with other mySQL versions.
  8. Insert INTO groupagents ( GroupdID ,SearchID ,Name The SQL statement has a typo on GroupID. Might also be good to add quotes around the Name column (`Name`).
  9. Run this as a shell command in your script (do not use Shell as Admin, as any "as Admin" command runs without elevated permissions if UAC is enabled). @powershell -NoProfile -ExecutionPolicy bypass -Command "(iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))) >$null 2>&1" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
  10. https://developers.hp.com/hp-product-warranty/forum/api-down Just a heads up, if you hadn't already noticed that HP warranty information was not updating, the warranty API is still offline for "retooling" (apparently since April 9).
  11. Probe templates out of sync is a known issue, it will basically always show that for any of the built-in templates once you start adding your own (ie, adding new routers/switches/etc under the existing device templates tree). Aside from some printers, most of the devices we manage had to be added via custom templates.
  12. Message LIKE '%Group Name:Administrators%' AND Message NOT LIKE '%Account Name:%$%' You will need wildcards to match on something inside the string. Testing against my db, the log entries I have are all computer accounts, so the NOT LIKE filters those out.
  13. Ran this patch on Tuesday and had no issues until today. Had all logins start failing abruptly this afternoon and had to reboot the Automate server to get back in.
  14. Attached an updated version of my BIOS update script. It uses a PowerShell function to locate the BIOS update executable instead of relying on fixed path variables, which will resolve issues with various models that unpack with different folder structures. HP SDM - BIOS Update.xml
×
×
  • Create New...