, , ,

Create a tempfile with PowerShell

1–2 minutes
2 comments on Create a tempfile with PowerShell
PowerShell New-TemporaryFile

When I was using PowerShell in the early stages it was limited in some features, now with PowerShell version 5 Microsoft added some great new features to it. This time it’s about creating a tempfile. I already wrote a blog post in 2011 how you can create a tempfile in older version of PowerShell using .NET:


$tempFile = [System.IO.Path]::GetTempFileName()

With PowerShell 5 you got a native cmdlet for this:


$tempFile = New-TemporaryFile

2 responses

  1. Ryan Ephgrave Avatar

    Very cool. I’ve always used the New-GUID cmdlet to come up with my temp file names, but this seems easier!

    1. Thomas Maurer Avatar

      Yep it is good to have such functions as native PowerShell cmdlets :)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.