파일 시스템용 Clear-Content

업데이트 날짜: 2014년 10월

적용 대상: Windows PowerShell 2.0, Windows PowerShell 3.0, Windows PowerShell 4.0, Windows PowerShell 5.0

항목의 내용을 삭제하지만 항목 자체는 삭제하지 않습니다.

구문

Clear-Content [-Stream <string>] [<CommonParameters>]

설명

파일 시스템에서 Clear-Content는 파일의 내용을 지우지만 파일을 삭제하지는 않습니다. 폴더에는 아무 영향도 없습니다.

참고: 이 사용자 지정 cmdlet 도움말 파일은 파일 시스템 드라이브에서 Clear-Content cmdlet이 작동하는 방식에 대해 설명합니다. 모든 드라이브의 Clear-Content cmdlet에 대한 자세한 내용을 보려면 "Get-HelpClear-Content -Path $null"을 입력하거나 Clear-Content(https://go.microsoft.com/fwlink/?LinkID=113282)(영문)를 참조하세요.

매개 변수

-Stream <string>

지정된 대체 데이터 스트림의 내용을 삭제하지만 대체 데이터 스트림은 삭제하지 않습니다. 스트림 이름을 입력합니다. 와일드카드는 지원되지 않습니다.

Stream은 파일 시스템 공급자가 Set-Content cmdlet에 추가하는 동적 매개 변수입니다. 이 매개 변수는 파일 시스템 드라이브에만 작동합니다.

Clear-Content cmdlet을 사용하여 대체 데이터 스트림의 내용을 지웁니다. 하지만 인터넷에서 다운로드한 파일을 차단하는 보안 검사를 제거하는 것은 권장되는 방법이 아닙니다. 다운로드된 파일이 안전한지 확인하려면 Unblock-File cmdlet을 사용합니다.

이 매개 변수는 Windows PowerShell 3.0에서 도입되었습니다.

필수 여부

false

위치

명명됨

기본값

파이프라인 입력 적용 여부

false

와일드카드 문자 허용 여부

false

<CommonParameters>

이 cmdlet은 일반 매개 변수 -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, -OutVariable, -Verbose, -WarningAction 및 -WarningVariable을 지원합니다. 자세한 내용은 about_CommonParameters를 참조하세요.

입력 및 출력

입력 유형은 cmdlet에 파이프할 수 있는 개체의 유형입니다. 반환 유형은 cmdlet에서 반환되는 개체의 유형입니다.

입력

출력

예제 1

C:\PS>Get-Content C:\Test\Copy-Script.ps1 -Stream Zone.Identifier

[ZoneTransfer]
ZoneId=3

C:\PS>Clear-Content C:\Test\Copy-Script.ps1 -Stream Zone.Identifier

C:\PS>Get-Content C:\Test\Copy-Script.ps1 -Stream Zone.Identifier
C:\PS>

Description
-----------
This example shows how the Clear-Content cmdlet clears the content from an alternate data stream while leaving the stream intact.

The first command uses the Get-Content cmdlet to get the content of the Zone.Identifier stream in the Copy-Script.ps1 file, which was downloaded from the Internet.

The second command uses the Clear-Content cmdlet to clear the content. 

The third command repeats the first command. It verifies that the content is cleared, but the stream remains. If the stream were deleted, the command would generate an error.

You can use a method like this one to clear the content of an alternate data stream. However, it is not the recommended way to eliminate security checks that block files that are downloaded from the Internet. If you verify that a downloaded file is safe, use the Unblock-File cmdlet.





예제 2

C:\PS>Clear-Content ..\SmpUsers\*\init.txt

Description
-----------
This command deletes all of the content from the "init.txt" files in all subdirectories of the SmpUsers directory. The files are not deleted, but they are empty.





예제 3

C:\PS>Clear-Content -Path * -Filter *.log -Force

Description
-----------
This command deletes the contents of all files in the current directory with the ".log" file name extension, including files with the read-only attribute. The asterisk (*) in the path represents all items in the current directory. The Force parameter makes the command effective on read-only files. Using a filter to restrict the command to files with the ".log" file name extension instead of specifying "*.log" in the path makes the operation faster.





예제 4

C:\PS>Clear-Content c:\Temp\* -Include Smp* -Exclude *2* -WhatIf

Description
-----------
This command requests a prediction of what would happen if you submitted the command: "clear-content c:\temp\* -include smp* -exclude *2*". The result lists the files that would be cleared; in this case, files in the Temp directory whose names begin with "Smp", unless the file names include a "2". To execute the command, run it again without the Whatif parameter.





See Also

Concepts

파일 시스템 공급자

Other Resources

Clear-Content
Get-Content
Get-ChildItem
Get-Content
Get-Item
Remove-Item
Set-Content
Test-Path