Skip to content

Instantly share code, notes, and snippets.

@jfrantz1-r7
Created November 15, 2018 15:20
Show Gist options
  • Save jfrantz1-r7/c3a995b30e30cdd39df6067b0a2e1f48 to your computer and use it in GitHub Desktop.
Save jfrantz1-r7/c3a995b30e30cdd39df6067b0a2e1f48 to your computer and use it in GitHub Desktop.
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
#Change the username and password to a global administrator in InsightVM
$Page = 0
$Username = ""
$Password = ""
$Body = @"
{"match":"all","filters":[{"field":"last-scan-date","operator":"is earlier than","value":90}]}
"@
$Headers = @{ Authorization = "Basic {0}" -f [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $Username,$Password))) }
Invoke-RestMethod -URI "https://nexpose.hertz.com/api/3/assets/search?size=1000&page=$($Page)" -Headers $Headers -Method Post -Body $Body -ContentType "application/json"
#DO {
# $assets = Invoke-RestMethod -URI "https://nexpose.hertz.com/api/3/assets/search?size=1000&page=$($Page)" -Headers $Headers -Method Post -Body $Body -ContentType "application/json"
# $deleteassets = $assets.resources
# foreach ($d in $deleteassets) {
# Invoke-RestMethod -URI "https://nexpose.hertz.com/api/3/assets/$($d.id)" -Method Delete -Headers $Headers
# Write-Host $d.id
# }
# $Page
# $Page++
#} While ($Page -le 200)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment