How-To (NGTS): Add or remove Workspaces from a Scope
94
Created On 12/02/26 19:37 PM - Last Modified 12/02/26 21:59 PM
Objective
This article covers how to add or remove Workspaces from a Scope within NGTS.
You can view the existing Scope-to-Workspace assignment on the "System Settings > Certificate Settings > Workspaces" page.
Environment
NGTS
Procedure
- You must have a service account to acquire an access token. Refer to our official docs: https://pan.dev/scm/api/config/ngts/ngts-api/#authentication
- Paste the following script in PowerShell ISE and update the values in Step #0 to match your environment. This script will remove all Workspaces from the target Scope.
-
### Step 0 - Update these values to match your environment $tsg_id = <TSG-ID> $clientId = "<CLIENT-ID>" $clientSecret = "<CLIENT-SECRET>" $scope_name = "<SCOPE-NAME>" $scope_description = "<SCOPE-DESCRIPTION>" # Blank value will result in a blank description field ### Step 1 - Get access token $basicAuth = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("${clientId}:${clientSecret}")) $jwt = Invoke-RestMethod -Method Post ` -Uri "https://auth.apps.paloaltonetworks.com/oauth2/access_token" ` -Headers @{ Authorization = "Basic $basicAuth" } ` -ContentType "application/x-www-form-urlencoded" ` -Body "grant_type=client_credentials&scope=tsg_id:$tsg_id" $access_token = $jwt.access_token Write-Host "Token ending in $($access_token.Substring($access_token.Length - 10))" -ForegroundColor Green ### Step 2 - Get Scope info Invoke-RestMethod -Method Get ` -Uri "https://api.strata.paloaltonetworks.com/iam/v1/scopes/$scope_name" ` -Headers @{Authorization = "Bearer $access_token"} ` -OutVariable response2 ### Step 3 - Update Scope info (Remove all workspaces from a Scope object) $body = @{description = $scope_description;resources = @()} | ConvertTo-Json -Depth 3 Invoke-RestMethod -Method Put ` -Uri "https://api.strata.paloaltonetworks.com/iam/v1/scopes/$scope_name" ` -Headers @{Authorization = "Bearer $access_token"} ` -Body $body ` -OutVariable response3
-
- See example output of the script. The resources list should become blank if successful.
- You can add Workspaces to a Scope as follows:
- Add a single workspace:
-
### Update scope info (Add one workspace to a scope object) $body = @{ description = $scope_description resources = @( @{ resource_type = "ngts_workspace" resource_id = "1002" } ) } | ConvertTo-Json -Depth 3 $response = Invoke-RestMethod -Method Put ` -Uri "https://api.strata.paloaltonetworks.com/iam/v1/scopes/$scope_name" ` -Headers @{ Authorization = "Bearer $access_token" } ` -ContentType "application/json" ` -Body $body $response
-
- Add multiple workspaces:
-
### Update scope info (Add multiple workspaces to a scope object) $body = @{ description = $scope_description resources = @( @{ resource_type = "ngts_workspace" resource_id = "1002" }, @{ resource_type = "ngts_workspace" resource_id = "1003" } ) } | ConvertTo-Json -Depth 3 $response = Invoke-RestMethod -Method Put ` -Uri "https://api.strata.paloaltonetworks.com/iam/v1/scopes/$scope_name" ` -Headers @{ Authorization = "Bearer $access_token" } ` -ContentType "application/json" ` -Body $body $response
-
- Add a single workspace:
- Get current Scope info:
-
### Step 2 - Get Scope info Invoke-RestMethod -Method Get ` -Uri "https://api.strata.paloaltonetworks.com/iam/v1/scopes/$scope_name" ` -Headers @{Authorization = "Bearer $access_token"} ` -OutVariable response2
-
- Process complete.
Additional Information
Modifying the Scope's assigned Workspaces is not currently an option in the UI, so it must be done via API.