Skip to content

Document New-TemporaryDirectory cmdlet #12676

Closed

Description

@AndyBodnar

Summary

Document the new New-TemporaryDirectory cmdlet being added in PowerShell.

Cmdlet Details

  • Name: New-TemporaryDirectory
  • Module: Microsoft.PowerShell.Utility

Synopsis

Creates a new temporary directory and returns a DirectoryInfo object.

Parameters

Parameter Type Required Description
-Prefix String No Specifies a prefix for the temporary directory name

Examples

# Create a temporary directory
$tempDir = New-TemporaryDirectory

# Create a temporary directory with a prefix
$tempDir = New-TemporaryDirectory -Prefix "MyApp_"

Notes

  • Uses .NET's Directory.CreateTempSubdirectory() API
  • Returns a System.IO.DirectoryInfo object
  • Supports -WhatIf and -Confirm parameters

Activity

  1. added
    area-utility
    hold-for-pr
    hold-for-release
    on Jan 19, 2026
  2. Thatgfsj commented on Jun 21, 2026

    @Thatgfsj

    Note: There is also an alternative implementation PR at PowerShell/PowerShell#27086 (by Thatgfsj (@Thatgfsj)) that adds the same New-TemporaryDirectory cmdlet.

    The Cmdlets Working Group is currently deciding which PR to accept (see PR #27086 comment).

    Implementation details for PR #27086:

    • Mirrors the New-TemporaryFile pattern exactly
    • Uses do/while loop with DirectoryInfo.Exists check to avoid name collisions (matching PathUtils.CreateTemporaryDirectory() pattern)
    • Supports -WhatIf and -Confirm via ShouldProcess
    • Returns System.IO.DirectoryInfo
    • Includes Pester tests
  3. added
    hold-for-pr
    and removed
    hold-for-pr
    on Jul 27, 2026
  4. removed
    hold-for-pr
    hold-for-release
    on Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-utility

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions