You are currently viewing PowerShell Clear-Content Cmdlet

PowerShell Clear-Content Cmdlet

PowerShell Clear-Content Cmdlet

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed Set-Content cmdlet in PowerShell.

https://cloudaffaire.com/powershell-set-content-cmdlet/

In this blog post, we will discuss Clear-Content cmdlet in PowerShell. You can use Clear-Content cmdlet to delete the contents of a file. Clear-Content cmdlet removes the existing contents of the file, but the file itself is not deleted. To delete the file along with its content use, Remove-Item cmdlet.

Clear-Content Cmdlet Syntax:

Clear-Content Cmdlet Argument List:

  • Confirm: Prompts you for confirmation before running the cmdlet.
  • Credential: Impersonate another user, or elevate your credentials when running this cmdlet.
  • Exclude: Specifies, as a string array, strings that this cmdlet omits from the path to the content. The value of this parameter qualifies the Path parameter.
  • Filter: Specifies a filter in the provider’s format or language. The value of this parameter qualifies the Path parameter.
  • Force: Forces the command to run without asking for user confirmation.
  • -Include: Specifies, as a string array, content that this cmdlet clears. The value of this parameter qualifies the Path parameter.
  • LiteralPath: Specifies the paths to the items from which content is deleted. Unlike the Path parameter, the value of LiteralPath is used exactly as it is typed.
  • Path: Specifies the paths to the items from which content is deleted. Wildcards are permitted.
  • Stream: Specifies an alternative data stream for content. If the stream does not exist, this cmdlet creates it. Wildcard characters are not supported.
  • UseTransaction: Includes the command in the active transaction. This parameter is valid only when a transaction is in progress.
  • WhatIf: Shows what would happen if the cmdlet runs. The cmdlet is not run.

PowerShell Clear-Content Cmdlet:

Hope you have enjoyed this article. In the next blog post, we will discuss New-Item cmdlet in PowerShell.

To get more details on PowerShell, kindly follow below official documentation

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about?view=powershell-5.1

 

Leave a Reply