Summary of the new feature / enhancement
Summary
Start-ThreadJob should support -LiteralPath parameter (with -PSPath and -LP aliases) to match Start-Job's functionality and handle cross-platform file paths that may contain wildcard characters.
Problem
PowerShell is now cross-platform, and characters traditionally used as wildcards (*, ?, [, ]) may be present in filenames on non-Windows systems (e.g., Linux, macOS). Currently, Start-ThreadJob only has a -FilePath parameter, which may cause issues when:
- A legitimate filename contains wildcard characters on Unix-like systems
- Users need to ensure paths are interpreted literally without pattern matching
- Users want API consistency between
Start-Job and Start-ThreadJob
Current Behavior
Start-ThreadJob only supports:
Start-ThreadJob -FilePath "path/to/script.ps1"
The -FilePath parameter rejects paths with wildcard characters (see GetScriptBlockFromFile method):
if (WildcardPattern.ContainsWildcardCharacters(filePath))
{
throw new ArgumentException("FilePath cannot contain wildcards.");
}
Proposed technical implementation details (optional)
Proposed Solution
Add a -LiteralPath parameter to Start-ThreadJob with:
- Aliases:
-PSPath, -LP (matching Start-Job)
- Behavior: Interprets paths literally without wildcard evaluation
- Mutual exclusivity:
-FilePath and -LiteralPath should be in different parameter sets
Example usage:
# For a file literally named "test[1].ps1" on Linux
Start-ThreadJob -LiteralPath "/home/user/scripts/test[1].ps1"
# With aliases
Start-ThreadJob -PSPath "/home/user/scripts/test[1].ps1"
Start-ThreadJob -LP "/home/user/scripts/test[1].ps1"
Summary of the new feature / enhancement
Summary
Start-ThreadJobshould support-LiteralPathparameter (with-PSPathand-LPaliases) to matchStart-Job's functionality and handle cross-platform file paths that may contain wildcard characters.Problem
PowerShell is now cross-platform, and characters traditionally used as wildcards (
*,?,[,]) may be present in filenames on non-Windows systems (e.g., Linux, macOS). Currently,Start-ThreadJobonly has a-FilePathparameter, which may cause issues when:Start-JobandStart-ThreadJobCurrent Behavior
Start-ThreadJobonly supports:The
-FilePathparameter rejects paths with wildcard characters (seeGetScriptBlockFromFilemethod):Proposed technical implementation details (optional)
Proposed Solution
Add a
-LiteralPathparameter toStart-ThreadJobwith:-PSPath,-LP(matchingStart-Job)-FilePathand-LiteralPathshould be in different parameter setsExample usage: