Skip to content

New-TemporaryDirectory or New-TemporaryItem or New-Item -Temporary #25754

@anonhostpi

Description

@anonhostpi

Summary of the new feature / enhancement

Currently, there is only one option for creating temporary items without relying on [System.IO] calls and that is New-TemporaryFile.

Since users subjected to Constrained (CLM) or Restricted (RLM) Language Modes can not use [System.IO], if they want to create a directory, they must use:

New-TemporaryFile | % { rm $_; ni $_ -ItemType Directory }

Which seems counter-intuitive

Proposed technical implementation details (optional)

As proposed previously, a few potential solutions exist:

  • Create a new cmdlet/function called New-TemporaryDirectory that functions identically to New-TemporaryFile, but for dirs.
  • Rename New-TemporaryFile to New-TemporaryItem and add support for -ItemType Directory
  • Add a -Temporary switch to New-Item

This previous issue was closed, because it offloaded support for temporary paths to dotnet and [System.IO].

While using [System.IO] works in Full Language Mode (FLM), it does not for CLM, RLM, and NLM (No Language Mode)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issuesWG-ReviewedA Working Group has reviewed this and made a recommendation

    Type

    No type

    Projects

    Status

    Reviewed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions