Skip to content

Instantly share code, notes, and snippets.

@jfrantz1-r7
Created November 2, 2018 00:34
Show Gist options
  • Save jfrantz1-r7/a344caec114101d21b9b509cc888b886 to your computer and use it in GitHub Desktop.
Save jfrantz1-r7/a344caec114101d21b9b509cc888b886 to your computer and use it in GitHub Desktop.
import requests
# this url is to your console API endpoint
url = "https://<console IP>:3780/api/3/assets/search?size=500&page=0"
# quick and dirty, stores creds (you can use cyberark's api to pull down creds)
r = requests.post(url, auth=('nxadmin', 'nxpassword'), json={"filters": [{"field":"last-scan-date", "operator": "is-earlier-than","value": 90}], "match": "all"}, verify=False)
# requests library lets us natively have json for a response
assets = r.json()
# loops through every asset pulled back that hasn't been scanned and deletes it
for i in assets["resources"]:
asset_id = i["id"]
url = "https://<console ip>:3780/api/3/assets/" + str(asset_id)
requests.delete(url, auth=('nxadmin', 'nxpassword'), verify=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment