Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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)
Add Comment
Please, Sign In to add comment