Written by 5:22 pm Microsoft, PowerShell, Windows, Windows Server • 2 Comments

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

Tags: , , , , , , Last modified: January 7, 2019
Close Search Window