File tree Expand file tree Collapse file tree
Segment/Segment/Asset Management Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ $APIKey = " <INSERT_YOUR_API_KEY>"
2+ $uri = " https://zncustlabs-admin.zeronetworks.com/api/v1" # <---- UPDATE WITH YOUR API URL
3+
4+ # Headers
5+ $znHeaders = New-Object " System.Collections.Generic.Dictionary[[String],[String]]"
6+ $znHeaders.Add (" Authorization" , $APIKey )
7+ $znHeaders.Add (" content-type" , " application/json" )
8+
9+ $apiString = " assets/queued?_limit=1&_offset=0&_filters=&order=asc&orderColumns[]=name&showInactive=false&with_count=true"
10+
11+ $assetsToCheck = @ ()
12+
13+ $fullURI = " $uri /$apiString "
14+
15+ # Get the total number of assets
16+ $allAssets = Invoke-RestMethod - Uri $fullURI - Method Get - Headers $znHeaders
17+
18+ $i = 0
19+
20+ # Page through results if needed
21+ for (;$i -le ($allAssets.Count );) {
22+ $assetsToCheck += (Invoke-RestMethod - Uri " $uri /assets/queued?_limit=400&_offset=$i &_filters=&with_count=true&order=asc&orderColumns[]=name" - Method Get - Headers $znHeaders ).items
23+ $i = $i + 400
24+ }
25+
26+ # Extract all asset IDs
27+ $assetIds = $assetsToCheck | ForEach-Object { $_.id }
28+
29+ # Build payload
30+ $payload = @ {
31+ items = $assetIds
32+ extendByDays = 30
33+ # maintenanceWindowId = "" # replace if needed
34+ } | ConvertTo-Json
35+
36+ # PUT request to extend learning
37+ $extendUri = " $uri /assets/actions/queue"
38+
39+ Invoke-RestMethod - Uri $extendUri - Method Put - Headers $znHeaders - Body $payload
You can’t perform that action at this time.
0 commit comments