Add New-TemporaryDirectory cmdlet - #27549
Justin Chung (jshigetomi) merged 11 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds the new New-TemporaryDirectory cmdlet to PowerShell Utility, wires it into module exports/default command verification, and introduces Pester coverage + documentation status update.
Changes:
- Adds
New-TemporaryDirectorycmdlet implementation (NewTemporaryDirectoryCommand.cs). - Exports the cmdlet from
Microsoft.PowerShell.Utility(Windows/Unix manifests) and registers it in default-command verification. - Adds Pester tests for the cmdlet and updates the cmdlet test-status documentation table.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/powershell/engine/Basic/DefaultCommands.Tests.ps1 | Adds New-TemporaryDirectory to the default cmdlet/alias verification matrix. |
| test/powershell/Modules/Microsoft.PowerShell.Utility/New-TemporaryDirectory.Tests.ps1 | Introduces Pester coverage for creation/uniqueness/WhatIf/output type. |
| src/Modules/Windows/Microsoft.PowerShell.Utility/Microsoft.PowerShell.Utility.psd1 | Exports New-TemporaryDirectory on Windows. |
| src/Modules/Unix/Microsoft.PowerShell.Utility/Microsoft.PowerShell.Utility.psd1 | Exports New-TemporaryDirectory on Unix. |
| src/Microsoft.PowerShell.Commands.Utility/commands/utility/NewTemporaryDirectoryCommand.cs | Implements the cmdlet with SupportsShouldProcess and error handling. |
| docs/testing-guidelines/PowerShellCoreTestStatus.md | Marks New-TemporaryDirectory as delivered/tested in the status table. |
|
The @PowerShell/wg-powershell-cmdlets discussed this. There's an existing older PR (#26679) that attempts to resolve the same issue, however, it appears that author has not followed-up on existing feedback, therefore we recommend moving forward with this PR. However, we ask that the |
Expose Directory.CreateTempSubdirectory prefix support and add Pester coverage for custom directory name prefixes.
969ef08 to
06d71c7
Compare
|
Steve Lee (@SteveL-MSFT) Ryan Yates (@kilasuit) Thatgfsj (@Thatgfsj) |
Sean Wheeler (sdwheeler)
left a comment
There was a problem hiding this comment.
Add HelpUri
|
Justin Chung (@jshigetomi) Steve Lee (@SteveL-MSFT) Sean Wheeler (@sdwheeler) Are we good to merge this? |
|
Justin Chung (@jshigetomi) Steve Lee (@SteveL-MSFT) can we close/merge this branch? |
|
Justin Chung (@jshigetomi) All checks passed. :) LGTM, or should I rebase this before merging? |
|
Kirtikumar Anandrao Ramchandani (@KirtiRamchandani) give me one second let me review it. I think you brought over most or all changes suggested in the other PR |
|
Ryan Yates (@kilasuit) Steve Lee (@SteveL-MSFT) Kirtikumar Anandrao Ramchandani (@KirtiRamchandani) Sorry about the back and forth with the other PR. I wanted to give the other author a chance to contribute since he created the PR first. This change has been delayed for a while because of it, and I don't think it justifies any more delay when this PR is ready to go. |
|
Justin Chung (@jshigetomi), that was quick, thanks! Yes, while suggesting a change that I discovered as an edge case in the other PR, I got it fixed here too. :P |
Completely fine and understandable as a reviewer to give a chance to the first to make a PR. And yeah, that was good of these reviewers to give a fair chance. :) Thank you very much! |
|
In the other PR #27086 this Testing Guidelines File was also updated Justin Chung (@jshigetomi) does this file also need updating in this PR as it was updated with the Addition of |
|
Ryan Yates (@kilasuit) That is a good point. I will bring this up with the maintainers |
f83ccdd
into
PowerShell:master
|
Justin Chung (@jshigetomi) You must have been too hasty. This code requires correction in almost every line, it is better to cancel it than fix it. |
|
Ilya (@iSazonov) maybe we can have a followup pr? Can you list the specific lines or patterns you like to be changed? I will make a pr to polish this shortly trying to identify the lines, I think I can infer the ones you are pointing to. |
PR Summary
Add
New-TemporaryDirectorytoMicrosoft.PowerShell.Utility.The new cmdlet follows the shape of
New-TemporaryFile: it supportsShouldProcess, uses low confirmation impact, exports from the Utility module on Windows and Unix, and returns aSystem.IO.DirectoryInfofor a unique directory under the system temp path.PR Context
Fixes #25754.
The working group recommended adding
New-TemporaryDirectoryso 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 --checkSystem.Management.Automation.Language.ParserStart-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)New-TemporaryDirectoryreturnsSystem.IO.DirectoryInfo, creates the directory, and places it under[System.IO.Path]::GetTempPath()PR Checklist
masterbranch.