Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions reference/5.1/CimCmdlets/Remove-CimInstance.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ Accept wildcard characters: False
Specifies a query to run on the CIM server. You can specify the query dialect using the
**QueryDialect** parameter.

If the value specified contains double quotes ("), single quotes ('), or a backslash (\\), you must
escape those characters by prefixing them with the backslash (\\) character. If the value specified
If the value specified contains double quotes ("), single quotes ('), or a backslash (`\`), you must
escape those characters by prefixing them with the backslash (`\`) character. If the value specified
uses the WQL LIKE operator, then you must escape the following characters by enclosing them in
square brackets (\[\]): percent (%), underscore (_), or opening square bracket (\[).
square brackets (`[]`): percent (%), underscore (`_`), or opening square bracket (`[`).

```yaml
Type: System.String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,8 @@ PS C:\ps-test>
Now, create a new command breakpoint with an action. The following command sets
a command breakpoint with an action that logs the value of the `$scriptName`
variable when the function is called. Because the Break keyword is not used in
the action, execution does not stop. (The backtick (`) is the line-continuation
character.)
the action, execution does not stop. (The backtick (`` ` ``) is the
line-continuation character.)

```powershell
PS C:\ps-test> Set-PSBreakpoint -command psversion -script test.ps1 `
Expand All @@ -777,7 +777,7 @@ PS C:\ps-test> Set-PSBreakpoint -command psversion -script test.ps1 `
You can also add actions that set conditions for the breakpoint. In the
following command, the command breakpoint is executed only if the execution
policy is set to RemoteSigned, the most restrictive policy that still permits
you to run scripts. (The backtick (`) is the continuation character.)
you to run scripts. (The backtick (`` ` ``) is the continuation character.)

```powershell
PS C:\ps-test> Set-PSBreakpoint -script test.ps1 -command psversion `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ You can also use the `Select-Object` and `Format-List` cmdlets to display the
property values of an object. `Select-Object` and `Format-List` each have a
**Property** parameter. You can use the **Property** parameter to specify one
or more properties and their values. Or, you can use the wildcard character
(\*) to represent all the properties.
(`*`) to represent all the properties.

For example, the following command displays the values of all the properties
of the PowerShell.exe file.
Expand Down
6 changes: 3 additions & 3 deletions reference/5.1/Microsoft.PowerShell.Core/About/about_WQL.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ slowly.

A typical WMI query begins with a Select statement that gets all properties or
particular properties of a WMI class. To select all properties of a WMI class,
use an asterisk (\*). The From keyword specifies the WMI class.
use an asterisk (`*`). The From keyword specifies the WMI class.

A Select statement has the following format:

Expand Down Expand Up @@ -611,8 +611,8 @@ All operators, including the Like operators are valid with the Or and And
operators. And, you can combine the Or and And operators in a single query
with parentheses that tell Windows PowerShell which clauses to process first.

This command uses the Windows PowerShell continuation character (`) divide the
command into two lines.
This command uses the Windows PowerShell continuation character (`` ` ``) divide
the command into two lines.

```powershell
$q = "Select * from Win32_Process `
Expand Down
117 changes: 62 additions & 55 deletions reference/5.1/Microsoft.PowerShell.Management/Clear-Content.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Management
ms.date: 10/18/2018
ms.date: 05/11/2022
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/clear-content?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Clear-Content
Expand All @@ -17,22 +17,24 @@ Deletes the contents of an item, but does not delete the item.
### Path (Default)

```
Clear-Content [-Path] <String[]> [-Filter <String>] [-Include <String[]>] [-Exclude <String[]>] [-Force]
[-Credential <PSCredential>] [-WhatIf] [-Confirm] [-UseTransaction] [-Stream <String>] [<CommonParameters>]
Clear-Content [-Path] <String[]> [-Filter <String>] [-Include <String[]>] [-Exclude <String[]>]
[-Force] [-Credential <PSCredential>] [-WhatIf] [-Confirm] [-UseTransaction] [-Stream <String>]
[<CommonParameters>]
```

### LiteralPath

```
Clear-Content -LiteralPath <String[]> [-Filter <String>] [-Include <String[]>] [-Exclude <String[]>] [-Force]
[-Credential <PSCredential>] [-WhatIf] [-Confirm] [-UseTransaction] [-Stream <String>] [<CommonParameters>]
Clear-Content -LiteralPath <String[]> [-Filter <String>] [-Include <String[]>]
[-Exclude <String[]>] [-Force] [-Credential <PSCredential>] [-WhatIf] [-Confirm] [-UseTransaction]
[-Stream <String>] [<CommonParameters>]
```

## DESCRIPTION

The `Clear-Content` cmdlet deletes the contents of an item, such as deleting the text from a file, but it does not delete the item.
As a result, the item exists, but it is empty.
The `Clear-Content` is similar to `Clear-Item`, but it works on items with contents, instead of items with values.
The `Clear-Content` cmdlet deletes the contents of an item, such as deleting the text from a file,
but it does not delete the item. As a result, the item exists, but it is empty. `Clear-Content` is
similar to `Clear-Item`, but it works on items with contents, instead of items with values.

## EXAMPLES

Expand All @@ -42,31 +44,37 @@ The `Clear-Content` is similar to `Clear-Item`, but it works on items with conte
Clear-Content "..\SmpUsers\*\init.txt"
```

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.
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.

### Example 2: Delete content of all files with a wildcard

```powershell
Clear-Content -Path "*" -Filter "*.log" -Force
```

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.
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.

### Example 3: Clear all data from a stream

This example shows how the `Clear-Content` cmdlet clears the content from an alternate data stream while leaving the stream intact.
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 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.
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.
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.

```powershell
Get-Content C:\Test\Copy-Script.ps1 -Stream Zone.Identifier
Expand All @@ -92,7 +100,7 @@ Get-Content C:\Test\Copy-Script.ps1 -Stream Zone.Identifier

> [!NOTE]
> This parameter is not supported by any providers installed with PowerShell. To impersonate another
> user, or elevate your credentials when running this cmdlet, use Invoke-Command.
> user, or elevate your credentials when running this cmdlet, use `Invoke-Command`.

```yaml
Type: System.Management.Automation.PSCredential
Expand All @@ -108,10 +116,9 @@ Accept wildcard characters: False

### -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.
Enter a path element or pattern, such as "*.txt".
Wildcards are permitted.
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. Enter a path element or pattern, such as
`*.txt`. Wildcards are permitted.

```yaml
Type: System.String[]
Expand All @@ -127,10 +134,10 @@ Accept wildcard characters: True

### -Filter

Specifies a filter in the provider's format or language.
The value of this parameter qualifies the **Path** parameter.
The syntax of the filter, including the use of wildcards, depends on the provider.
Filters are more efficient than other parameters, because the provider applies them when retrieving the objects, rather than having PowerShell filter the objects after they are retrieved.
Specifies a filter in the provider's format or language. The value of this parameter qualifies the
**Path** parameter. The syntax of the filter, including the use of wildcards, depends on the
provider. Filters are more efficient than other parameters, because the provider applies them when
retrieving the objects, rather than having PowerShell filter the objects after they are retrieved.

```yaml
Type: System.String
Expand Down Expand Up @@ -162,10 +169,8 @@ Accept wildcard characters: False

### -Include

Specifies, as a string array, content that this cmdlet clears.
The value of this parameter qualifies the **Path** parameter.
Enter a path element or pattern, such as "*.txt".
Wildcards are permitted.
Specifies, as a string array, content that this cmdlet clears. The value of this parameter qualifies
the **Path** parameter. Enter a path element or pattern, such as `*.txt`. Wildcards are permitted.

```yaml
Type: System.String[]
Expand All @@ -181,11 +186,10 @@ Accept wildcard characters: True

### -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.
No characters are interpreted as wildcards.
If the path includes escape characters, enclose it in single quotation marks.
Single quotation marks tell having PowerShell not to interpret any characters as escape sequences.
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. No characters are interpreted as wildcards.
If the path includes escape characters, enclose it in single quotation marks (`'`). Single quotation
marks tell having PowerShell not to interpret any characters as escape sequences.

```yaml
Type: System.String[]
Expand All @@ -201,12 +205,10 @@ Accept wildcard characters: False

### -Path

Specifies the paths to the items from which content is deleted.
Wildcards are permitted.
The paths must be paths to items, not to containers.
For example, you must specify a path to one or more files, not a path to a directory.
Wildcards are permitted.
This parameter is required, but the parameter name ("Path") is optional.
Specifies the paths to the items from which content is deleted. Wildcards are permitted. The paths
must be paths to items, not to containers. For example, you must specify a path to one or more
files, not a path to a directory. Wildcards are permitted. This parameter is required, but the
parameter name (**Path**) is optional.

```yaml
Type: System.String[]
Expand All @@ -226,12 +228,14 @@ Specifies an alternative data stream for content.
If the stream does not exist, this cmdlet creates it.
Wildcard characters are not supported.

**Stream** is a dynamic parameter that the FileSystem provider adds to `Clear-Content`.
This parameter works only in file system drives.
**Stream** is a dynamic parameter that the FileSystem provider adds to `Clear-Content`. This
parameter works only in file system drives, and will clear the content of alternative data streams
on both files and directories.

You can use the `Clear-Content` cmdlet to change the content of the Zone.Identifier alternate data stream.
However, we do not recommend this as a 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.
You can use the `Clear-Content` cmdlet to change the content of any alternate data stream, such as
`Zone.Identifier`. However, we do not recommend this as a 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.

This parameter was introduced in Windows PowerShell 3.0.

Expand All @@ -249,9 +253,9 @@ Accept wildcard characters: False

### -UseTransaction

Includes the command in the active transaction.
This parameter is valid only when a transaction is in progress.
For more information, see [about_transactions](../Microsoft.PowerShell.Core/About/about_Transactions.md).
Includes the command in the active transaction. This parameter is valid only when a transaction is
in progress. For more information, see
[about_transactions](../Microsoft.PowerShell.Core/About/about_Transactions.md).

```yaml
Type: System.Management.Automation.SwitchParameter
Expand Down Expand Up @@ -283,8 +287,7 @@ Accept wildcard characters: False

### -WhatIf

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

```yaml
Type: System.Management.Automation.SwitchParameter
Expand All @@ -300,7 +303,10 @@ 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](../Microsoft.PowerShell.Core/About/about_CommonParameters.md).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
-WarningAction, and -WarningVariable. For more information, see
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

Expand All @@ -316,8 +322,9 @@ This cmdlet does not return any objects.

## NOTES

You can use `Clear-Content` with the PowerShell FileSystem provider and with other providers that manipulate content.
To clear items that are not considered to be content, such as items managed by the PowerShell Certificate or Registry providers, use `Clear-Item`.
You can use `Clear-Content` with the PowerShell FileSystem provider and with other providers that
manipulate content. To clear items that are not considered to be content, such as items managed by
the PowerShell Certificate or Registry providers, use `Clear-Item`.

The `Clear-Content` cmdlet is designed to work with the data exposed by any provider.
To list the providers available in your session, type `Get-PsProvider`.
Expand Down
Loading