How to create a temporary file using PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

To create a temporary file with the PowerShell, we can use the New-TemporaryFile command. This command creates a temporary file tmp<NNNN>.tmp where NNNN represents the random hexadecimal number.


PS C:\> New-TemporaryFile

Directory: C:\Users\Administrator.AUTOMATIONLAB\AppData\Local\Temp

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        4/10/2021   9:14 PM              0 tmpF624.tmp

The output path is selected based on the path defined at Path.GetTempPath()

Updated on 12-Apr-2021 11:10:28