New-TemporaryFile
Creates a temporary file.
구문
Default (기본값)
New-TemporaryFile
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
This cmdlet creates temporary files that you can use in scripts.
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 TEMP folder.
This cmdlet uses the Path.GetTempPath() method to find your TEMP folder. This method checks for the existence of environment variables in the following order and uses the first path found:
On Windows platforms:
- The path specified by the TMP environment variable.
- The path specified by the TEMP environment variable.
- The path specified by the USERPROFILE environment variable.
- The Windows directory.
On non-Windows platforms: Uses the path specified by the TMPDIR environment variable.
예제
Example 1: Create a temporary file
$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.
매개 변수
-Confirm
Prompts you for confirmation before running the cmdlet.
매개 변수 속성
형식: | SwitchParameter |
Default value: | False |
와일드카드 지원: | False |
DontShow: | False |
별칭: | cf |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
매개 변수 속성
형식: | SwitchParameter |
Default value: | False |
와일드카드 지원: | False |
DontShow: | False |
별칭: | wi |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
출력
FileInfo
This cmdlet returns a FileInfo object that represents the temporary file.