PowerTip: Use PowerShell to Create Temporary File Name

PowerTip: Use PowerShell to Create Temporary File Name

  • Comments 3
  • Likes

Summary: Use Windows PowerShell to create a temporary file name.

Hey, Scripting Guy! Question I need to output data to a file, but I do not need a permanent file name and location because
           the file will be later deleted. How can I easily use Windows PowerShell to create a temporary file name?

Hey, Scripting Guy! Answer Use the GetTempFileName static method from the System.IO.Path .NET Framework class:

[System.IO.Path]::GetTempFileName()

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • thanks

  • Be aware, though, simply getting the filename also creates a placeholder!