Created
November 2, 2018 00:34
-
-
Save jfrantz1-r7/a344caec114101d21b9b509cc888b886 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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