Add New-TemporaryDirectory cmdlet by KirtiRamchandani · Pull Request #27549 · PowerShell/PowerShell
PR Summary
Add New-TemporaryDirectory to Microsoft.PowerShell.Utility.
The new cmdlet follows the shape of New-TemporaryFile: it supports ShouldProcess, uses low confirmation impact, exports from the Utility module on Windows and Unix, and returns a System.IO.DirectoryInfo for a unique directory under the system temp path.
PR Context
Fixes #25754.
The working group recommended adding New-TemporaryDirectory so users can create temporary directories without calling [System.IO] directly. That matters in constrained and restricted language modes where direct .NET type access is not available.
Validation
git diff --check- Parsed the touched PowerShell scripts and module manifests with
System.Management.Automation.Language.Parser Start-PSBuild -Clean -PSModuleRestore -UseNuGetOrgStart-PSPester -Path test/powershell/Modules/Microsoft.PowerShell.Utility/New-TemporaryDirectory.Tests.ps1 -Tag CI -SkipTestToolBuild -UseNuGetOrg(4 passed)Start-PSPester -Path test/powershell/engine/Basic/DefaultCommands.Tests.ps1 -Tag CI -UseNuGetOrg(290 passed)- Manual built-shell smoke test confirmed
New-TemporaryDirectoryreturnsSystem.IO.DirectoryInfo, creates the directory, and places it under[System.IO.Path]::GetTempPath()
PR Checklist
- I have read the CONTRIBUTING document.
- If this PR is work in progress, I am opening the PR as a draft.
- The PR is made against the
masterbranch. - My commit messages follow the repository guidelines.
- I have added tests or validation that prove my fix is effective or that my feature works.
- I have added necessary documentation, if appropriate.
- Breaking changes
- None
- User-facing changes
- Documentation needed
- Testing - New and feature
- Added focused Pester coverage