Clear Contents of a File

Execute the Script to clear the complete contents of a File. Supply the File Path as a Parameter.

Script

<#
.SYNOPSIS
This script can be used to clear contents of a file.
.DESCRIPTION
This script can be used to clear contents of a file.
.EXAMPLE
C:\PS> C:\Script\Clear_File.ps1 C:\Users\gautam-2374\Desktop test.txt
Clears the contents of the file.
#>

param([String] $path)
“File Content”
#Gets the content of a file.

Get-Content $path
#Clears the content of a file.

Clear-Content $path
“File Content Cleared!”
Get-Content $path

 

 

Clear_File

Leave a Reply