PowerShell New-TemporaryFile

Create a tempfile with PowerShell

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