Skip to content

Instantly share code, notes, and snippets.

@jfrantz1-r7
Created November 7, 2018 19:20
Show Gist options
  • Save jfrantz1-r7/bba06c3a9dd86a4468258aaa8b72ccfb to your computer and use it in GitHub Desktop.
Save jfrantz1-r7/bba06c3a9dd86a4468258aaa8b72ccfb to your computer and use it in GitHub Desktop.
#Uncomment the below lines if you aren't using a valid cert
#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
$Page = 0
#Change the username and password to a global administrator in InsightVM
$Username = "username"
$Password = "password"
$Headers = @{ Authorization = "Basic {0}" -f [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $Username,$Password))) }
DO {
$assets = Invoke-RestMethod -URI "<URL>/api/3/assets?&size=500&page=$($Page)" -Headers $Headers -Method Get
$deleteassets = $assets.resources
foreach ($d in $deleteassets) {
Invoke-RestMethod -URI "<URL>/api/3/assets/$($d.id)" -Method Get -Headers $Headers | select id
write-host $d.id + " has been deleted"
}
$Page++
} While ($Page -le 1500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment