Open
Conversation
- Declare Targets and OutputPath as mandatory parameters instead of relying on ambient scope variables. - Replace string concatenation with Join-Path for cross-platform correctness and readability. - Add ShouldProcess guard so -WhatIf and -Confirm behave correctly. - Mirror same fix in the generated monolithic Invoke-Locksmith.ps1. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR corrects and hardens the internal New-OutputPath helper that creates per-forest output directories, ensuring it no longer relies on ambient variables and properly honors -WhatIf/-Confirm.
Changes:
- Adds explicit, mandatory
TargetsandOutputPathparameters toNew-OutputPath(previously relied on$Targets/$OutputPathfrom outer scope). - Replaces manual path concatenation with
Join-Pathfor more robust path construction. - Activates
SupportsShouldProcessbehavior by guarding directory creation with$PSCmdlet.ShouldProcess(...).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Private/New-OutputPath.ps1 | Makes the helper self-contained (declared parameters), uses Join-Path, and enables -WhatIf/-Confirm via ShouldProcess. |
| Invoke-Locksmith.ps1 | Mirrors the same New-OutputPath corrections in the monolithic script version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes correctness and style issues in
New-OutputPath, a private helper function that creates per-forest output directories.Changes
Private/New-OutputPath.ps1$Targetsand$OutputPathwere missing from theparam()block; the function previously relied on ambient scope variables, which is fragile and undocumented.$OutputPath + "\" + $forestwithJoin-Path -Path $OutputPath -ChildPath $forestfor cross-platform correctness.SupportsShouldProcesswas declared inCmdletBindingbut$PSCmdlet.ShouldProcess()was never called; added the guard so-WhatIf/-Confirmwork correctly.Invoke-Locksmith.ps1(monolithic)Notes
New-OutputPathis currently dead code (no call sites exist in the module), but it is loaded by the build pipeline and should be correct.