Table of contents
ISE
TOC
Collapse the table of content
Expand the table of content

New-TemporaryFile

JuanPablo Jofre|Last Updated: 12/17/2016
|
3 Contributors

SYNOPSIS

Creates a temporary file.

SYNTAX

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

DESCRIPTION

The New-TemporaryFile cmdlet creates an empty file that has the .tmp file name extension. This cmdlet names the file tmpNNNN.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.

EXAMPLES

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.

PARAMETERS

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

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

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 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

© 2017 Microsoft