< Back

New-TemporaryFile

Tue Jan 29, 2019 10:21 pm

NAME New-TemporaryFile



SYNOPSIS

Creates a temporary file.





SYNTAX

New-TemporaryFile [-Confirm] [-WhatIf] [<CommonParameters>]





DESCRIPTION

The New-TemporaryFile cmdlet creates an empty file that has the .tmp file name extension. This cmdlet names the file `tmp`NNNN`.tmp`, where NNNN

is a random hexadecimal number. The cmdlet creates the file in your $Env:Temp folder.



This cmdlet creates temporary files that you can use in scripts.





PARAMETERS

-Confirm [<SwitchParameter>]

Prompts you for confirmation before running the cmdlet.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-WhatIf [<SwitchParameter>]

Shows what would happen if the cmdlet runs. The cmdlet is not run.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

System.IO.FileInfo

This cmdlet returns a FileInfo object that represents the temporary file.





NOTES









Example 1: Create a temporary file



PS C:\\>$TempFile = New-TemporaryFile



This command generates a .tmp file in your temporary folder, and then stores a reference to the file in the $TempFile variable. You can use this

file later in your script.



RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/?LinkId=821836