Powershell: Get path to a temporary directory

Created on 28 Mar 2017  路  4Comments  路  Source: PowerShell/PowerShell

Now, New-TemporaryFile cmdlet creates path to a temporary file. Sometimes we want to have path to a temporary directory.

Proposal is to add a Directory switch to get path to new temporary directory.

Area-Cmdlets-Utility Issue-Enhancement Waiting - DotNetCore

Most helpful comment

I've also needed this.

I think the name would become (eg) New-TemporaryItem. Or perhaps add a -Temporary switch to the existing New-Item and let the provider figure out what that means.

All 4 comments

I've also needed this.

I think the name would become (eg) New-TemporaryItem. Or perhaps add a -Temporary switch to the existing New-Item and let the provider figure out what that means.

I can agree that New-Item -Temporary would work, it is not quite as obvious as New-TemporaryFile, New-TemporaryDirectory, or even New-TemporaryItem.

Adding this to New-Item should allow for temporary files and directories to be created on a -Path other than the platform "temp" directory. If -Path is not specified, the provider should know the platform "temp" directory.

@iSazonov Should we mark this as blocked due to https://github.com/dotnet/corefx/issues/24001 as welll?

The .Net team has now created a new tracking issue as they are now committed to implementing various improvements to the temp file APIs that will cover this. We can expect this to be available in .net 5
https://github.com/dotnet/runtime/issues/2048

Was this page helpful?
0 / 5 - 0 ratings