You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(segment): run asset discovery under -DryRun even for new groups
Dry-run previously short-circuited before subnet expansion/asset
discovery whenever the target group didn't exist yet, so it reported
zero information about what would actually happen. Discovery is
read-only (GET calls only), so it now always runs; only the group
membership check (which needs a real group ID) is skipped when the
group doesn't exist, with discovered assets still counted and
reported in that case.
Verified end-to-end against a real tenant: -DryRun -Server correctly
found the 2 expected server assets in 10.1.11.0/24.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
# Membership can't be checked against a group that doesn't exist (Remove mode: not at all;
1232
+
# Add mode: only reachable here under -DryRun, since a non-dry-run always creates the group).
1233
+
if ($RemoveAssets) {
1234
+
Write-Host"Group '$GroupName' does not exist - nothing to remove ($($Assets.Count) matching asset(s) found, but there is no group to check membership against). Skipping."
1235
+
}
1236
+
else {
1237
+
Write-Host"[DRY RUN] Group '$GroupName' does not exist yet - would create it and add all $($Assets.Count) matching asset(s) to it (a new group has no existing members to skip)"
Copy file name to clipboardExpand all lines: Segment/Segment/Asset Management/Create Custom Group from Asset Subnets/README.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -170,11 +170,12 @@ Every run mirrors all console output to a timestamped log file at `logs\New-Cust
170
170
171
171
## Dry Run Mode
172
172
173
-
Use the `-DryRun` switch to preview what changes would be made without actually applying them:
173
+
Use the `-DryRun` switch to preview what changes would be made without actually applying them. All read-only work still runs - group existence checks, subnet expansion, and asset discovery are never skipped, so the reported `AssetsFound`/`AssetsAffected` counts are always real:
174
174
175
175
- Group existence is still checked, but missing groups are **not** created
176
-
- Matching assets are still discovered and checked against current group membership
177
-
- The request body that would be sent to add members is displayed, but no mutating API calls are made
176
+
- Matching assets are still discovered regardless of whether the group exists yet
177
+
- If the group already exists, current membership is still checked (read-only) and the request body that would be sent to add/remove members is displayed, but no mutating API calls are made
178
+
- If the group doesn't exist yet (Add mode) or doesn't exist at all (Remove mode), membership can't be checked against it - discovered assets are still counted and reported, just without a per-asset membership diff (Add mode assumes all of them would be added, since a new group has no existing members to skip)
178
179
- The local JSON record is still updated for groups that already exist, but not for groups that would only be created in a non-dry-run pass
0 commit comments