# get-GetTempFileName.ps1
# Creates a uniquely named, zero-byte file in the temp dir
# Thomas Lee - tfl@psp.co.uk
# Get file name (and create the file!):
$fn1 = [system.io.path]::GetTempFileName()
# Display Results
"File name returned: $fn1"
ls $fn1
# delete the file
Del $fn1
This script produces the following output:
PSH [C:\foo]: .\get-tempfilename.ps1
File name returned: C:\Documents and Settings\tfl\Local Settings\Temp\tmp6A.tmp
Directory: Microsoft.PowerShell.Core\FileSystem::C:\Documents and Settings\tfl\Local Settings\Temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 7/13/2008 7:41 PM 0 tmp6A.tmp
PSH [C:\foo]: