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
10 changes: 5 additions & 5 deletions reference/5.1/Microsoft.PowerShell.Core/About/about_Scopes.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: Explains the concept of scope in PowerShell and shows how to set and change the scope of elements.
Locale: en-US
ms.date: 07/22/2024
ms.date: 02/02/2025
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_scopes?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
title: about_Scopes
---
# about_Scopes

## Short description

Explains the concept of scope in PowerShell and shows how to set and change
the scope of elements.

Expand All @@ -32,8 +33,8 @@ The following are the basic rules of scope:
scopes are child scopes of that parent.
- An item is visible in the scope that it was created and in any child scopes,
unless you explicitly make it private.
- You can declare variables, aliases, functions, and PowerShell drives for a
scope outside of the current scope.
- Using scope modifiers, you can declare variables, aliases, functions, and
PowerShell drives for a scope outside of the current scope.
- An item that you created within a scope can be changed only in the scope in
which it was created, unless you explicitly specify a different scope.
- When code running in a runspace references an item, PowerShell searches the
Expand Down Expand Up @@ -259,8 +260,7 @@ the following contexts:
**ComputerName**, **HostName**, **SSHConnection** or **Session** parameters
(remote session)
- Background jobs, started with `Start-Job` (out-of-process session)
- Thread jobs, started via `Start-ThreadJob` or `ForEach-Object -Parallel`
(separate thread session)
- Thread jobs, started via `Start-ThreadJob` (separate thread session)

Depending on the context, embedded variable values are either independent
copies of the data in the caller's scope or references to it. In remote and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: Explains the concept of scope in PowerShell and shows how to set and change the scope of elements.
Locale: en-US
ms.date: 07/22/2024
ms.date: 02/02/2025
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_scopes?view=powershell-7.4&WT.mc_id=ps-gethelp
schema: 2.0.0
title: about_Scopes
---
# about_Scopes

## Short description

Explains the concept of scope in PowerShell and shows how to set and change
the scope of elements.

Expand All @@ -32,8 +33,8 @@ The following are the basic rules of scope:
scopes are child scopes of that parent.
- An item is visible in the scope that it was created and in any child scopes,
unless you explicitly make it private.
- You can declare variables, aliases, functions, and PowerShell drives for a
scope outside of the current scope.
- Using scope modifiers, you can declare variables, aliases, functions, and
PowerShell drives for a scope outside of the current scope.
- An item that you created within a scope can be changed only in the scope in
which it was created, unless you explicitly specify a different scope.
- When code running in a runspace references an item, PowerShell searches the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Explains the concept of scope in PowerShell and shows how to set and change the scope of elements.
Locale: en-US
ms.date: 07/22/2024
ms.date: 02/02/2025
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_scopes?view=powershell-7.5&WT.mc_id=ps-gethelp
schema: 2.0.0
title: about_Scopes
Expand Down Expand Up @@ -33,8 +33,8 @@ The following are the basic rules of scope:
scopes are child scopes of that parent.
- An item is visible in the scope that it was created and in any child scopes,
unless you explicitly make it private.
- You can declare variables, aliases, functions, and PowerShell drives for a
scope outside of the current scope.
- Using scope modifiers, you can declare variables, aliases, functions, and
PowerShell drives for a scope outside of the current scope.
- An item that you created within a scope can be changed only in the scope in
which it was created, unless you explicitly specify a different scope.
- When code running in a runspace references an item, PowerShell searches the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ In this example, `Start-Job` runs a `Get-Counter` command as a background job on
To view the performance counter output from the job, use the `Receive-Job` cmdlet.

```powershell
Start-Job -ScriptBlock {Get-Counter -Counter "\LogicalDisk(_Total)\% Free Space" -MaxSamples 1000}
Start-Job -ScriptBlock {
Get-Counter -Counter "\LogicalDisk(_Total)\% Free Space" -MaxSamples 1000
}
```

```Output
Expand Down Expand Up @@ -262,7 +264,8 @@ The pipeline is used with the `Where-Object` cmdlet to find a subset of the path
counter sets complete list of counter paths, remove the pipeline (`|`) and `Where-Object` command.

The `$_` is an automatic variable for the current object in the pipeline.
For more information, see [about_Automatic_Variables](../Microsoft.PowerShell.Core/About/about_Automatic_Variables.md).
For more information, see
[about_Automatic_Variables](../Microsoft.PowerShell.Core/About/about_Automatic_Variables.md).

```powershell
(Get-Counter -ListSet Memory).Paths | Where-Object { $_ -like "*Cache*" }
Expand Down Expand Up @@ -659,4 +662,4 @@ In PowerShell 7, when using the **ListSet** parameter, `Get-Counter` can't retri

[Start-Job](../Microsoft.PowerShell.Core/Start-Job.md)

[Where-Object](..//Microsoft.PowerShell.Core/Where-Object.md)
[Where-Object](../Microsoft.PowerShell.Core/Where-Object.md)
55 changes: 31 additions & 24 deletions reference/7.5/Microsoft.PowerShell.Diagnostics/Get-WinEvent.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ with the asterisk (`*`) wildcard to display each property.

### Example 3: Configure the classic Security log

This command gets an **EventLogConfiguration** object that represents the classic **Security** log. The
object is then used to configure settings for the log, such as max file size, file path, and whether the
log is enabled.
This command gets an **EventLogConfiguration** object that represents the classic **Security** log.
The object is then used to configure settings for the log, such as max file size, file path, and
whether the log is enabled.

```powershell
$log = Get-WinEvent -ListLog Security
Expand Down Expand Up @@ -196,17 +196,18 @@ ProviderLatency : 1000
ProviderControlGuid :
```

The `Get-WinEvent` cmdlet uses the **ListLog** parameter to specify the **Security** log. The object is
saved to a variable. The **MaximumSizeInBytes** property is set to 1 gigabyte on the object. The
The `Get-WinEvent` cmdlet uses the **ListLog** parameter to specify the **Security** log. The object
is saved to a variable. The **MaximumSizeInBytes** property is set to 1 gigabyte on the object. The
**SaveChanges** method is called to push the change to the system inside of a try block to handle
access violations. The `Get-WinEvent` cmdlet is called again on the **Security** log and piped to the
`Format-List` cmdlet to verify that the **MaximumSizeInBytes** property has been saved on the machine.
access violations. The `Get-WinEvent` cmdlet is called again on the **Security** log and piped to
the `Format-List` cmdlet to verify that the **MaximumSizeInBytes** property has been saved on the
machine.

### Example 4: Get event logs from a server

This command only gets event logs on the local computer that contain events. It's possible for a
log's **RecordCount** to be null or zero. The example uses the `$_` variable. For more information,
see [about_Automatic_Variables](../Microsoft.PowerShell.Core/about/about_automatic_variables.md).
see [about_Automatic_Variables](../Microsoft.PowerShell.Core/About/about_Automatic_Variables.md).

```powershell
Get-WinEvent -ListLog * -ComputerName localhost | Where-Object { $_.RecordCount }
Expand All @@ -233,7 +234,8 @@ is a property of the object with a non-null value.

This example gets objects that represent the **Application** event logs on three computers:
Server01, Server02, and Server03. The **ForEach** keyword is used because the **ComputerName**
parameter accepts only one value. For more information, see [about_Foreach](../Microsoft.PowerShell.Core/about/about_Foreach.md).
parameter accepts only one value. For more information, see
[about_Foreach](../Microsoft.PowerShell.Core/About/about_Foreach.md).

```powershell
$S = 'Server01', 'Server02', 'Server03'
Expand Down Expand Up @@ -345,7 +347,8 @@ This command lists the Event Ids that the **Microsoft-Windows-GroupPolicy** even
along with the event description.

```powershell
(Get-WinEvent -ListProvider Microsoft-Windows-GroupPolicy).Events | Format-Table Id, Description
(Get-WinEvent -ListProvider Microsoft-Windows-GroupPolicy).Events |
Format-Table Id, Description
```

```Output
Expand Down Expand Up @@ -505,7 +508,7 @@ is required.

```powershell
Get-WinEvent -Path 'C:\Tracing\TraceLog.etl' -Oldest |
Sort-Object -Property TimeCreated -Descending |
Sort-Object -Property TimeCreated -Descending |
Select-Object -First 100
```

Expand All @@ -526,7 +529,7 @@ reading from an `.etl` file, but the **Oldest** parameter applies to each file.

```powershell
Get-WinEvent -Path 'C:\Tracing\TraceLog.etl', 'C:\Test\Windows PowerShell.evtx' -Oldest |
Where-Object { $_.Id -eq '403' }
Where-Object { $_.Id -eq '403' }
```

The `Get-WinEvent` cmdlet gets log information from the archived files. The **Path** parameter uses
Expand Down Expand Up @@ -573,8 +576,9 @@ Get-WinEvent -LogName 'Windows PowerShell' -FilterXPath $XPath

This example uses the **FilterHashtable** parameter to get events from the **Application** log. The
hash table uses **key/value** pairs. For more information about the **FilterHashtable** parameter,
see [Creating Get-WinEvent queries with FilterHashtable](/powershell/scripting/samples/Creating-Get-WinEvent-queries-with-FilterHashtable).
For more information about hash tables, see [about_Hash_Tables](../Microsoft.PowerShell.Core/about/about_hash_tables.md).
see [Creating Get-WinEvent queries with FilterHashtable](/powershell/scripting/samples/creating-get-winevent-queries-with-filterhashtable).
For more information about hash tables, see
[about_Hash_Tables](../Microsoft.PowerShell.Core/About/about_Hash_Tables.md).

```powershell
$Date = (Get-Date).AddDays(-2)
Expand Down Expand Up @@ -739,8 +743,9 @@ Help.

Use an XML query to create a complex query that contains several XPath statements. The XML format
also allows you to use a **Suppress XML** element that excludes events from the query. For more
information about the XML schema for event log queries, see [Query Schema](/windows/win32/wes/queryschema-schema)
and the XML Event Queries section of [Event Selection](/previous-versions/aa385231(v=vs.85)).
information about the XML schema for event log queries, see
[Query Schema](/windows/win32/wes/queryschema-schema) and the XML Event Queries section of
[Event Selection](/previous-versions/aa385231(v=vs.85)).

You may also create a **Suppress** element using the **FilterHashtable** parameter.

Expand All @@ -760,7 +765,8 @@ Accept wildcard characters: False

Specifies an XPath query that this cmdlet select events from one or more logs.

For more information about the XPath language, see [XPath Reference](/previous-versions/dotnet/netframework-4.0/ms256115(v=vs.100))
For more information about the XPath language, see
[XPath Reference](/previous-versions/dotnet/netframework-4.0/ms256115(v=vs.100))
and the Selection Filters section of [Event Selection](/previous-versions/aa385231(v=vs.85)).

```yaml
Expand Down Expand Up @@ -841,8 +847,8 @@ cmdlet.
> [!NOTE]
> PowerShell does not limit the amount of logs you can request. However, the `Get-WinEvent` cmdlet
> queries the Windows API which has a limit of 256. This can make it difficult to filter through all
> of your logs at one time. You can work around this by using a `foreach` loop to iterate through each
> log like this: `Get-WinEvent -ListLog * | ForEach-Object{ Get-WinEvent -LogName $_.LogName }`
> of your logs at one time. You can work around this by using a `foreach` loop to iterate through
> each log like this: `Get-WinEvent -ListLog * | ForEach-Object{ Get-WinEvent -LogName $_.LogName }`

```yaml
Type: System.String[]
Expand Down Expand Up @@ -939,7 +945,8 @@ Accept wildcard characters: True

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).
-WarningAction, and -WarningVariable. For more information, see
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

Expand Down Expand Up @@ -980,13 +987,13 @@ Environment (Windows PE).

## RELATED LINKS

[about_Automatic_Variables](../Microsoft.PowerShell.Core/about/about_automatic_variables.md)
[about_Automatic_Variables](../Microsoft.PowerShell.Core/About/about_Automatic_Variables.md)

[about_Foreach](../Microsoft.PowerShell.Core/about/about_Foreach.md)
[about_Foreach](../Microsoft.PowerShell.Core/About/about_Foreach.md)

[about_Hash_Tables](../Microsoft.PowerShell.Core/about/about_hash_tables.md)
[about_Hash_Tables](../Microsoft.PowerShell.Core/About/about_Hash_Tables.md)

[Creating Get-WinEvent queries with FilterHashtable](/powershell/scripting/samples/Creating-Get-WinEvent-queries-with-FilterHashtable)
[Creating Get-WinEvent queries with FilterHashtable](/powershell/scripting/samples/creating-get-winevent-queries-with-filterhashtable)

[Format-Table](../Microsoft.PowerShell.Utility/Format-Table.md)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ set to `False`.
### Example 7: Use Filters with Add-Content

You can specify a filter to the `Add-Content` cmdlet. When using filters to qualify the **Path**
parameter, you need to include a trailing asterisk (`*`) to indicate the contents of the
path.
parameter, you need to include a trailing asterisk (`*`) to indicate the contents of the path.

The following command adds the word "Done" the content of all `*.txt` files in the `C:\Temp`
directory.
Expand Down Expand Up @@ -235,7 +234,7 @@ The acceptable values for this parameter are as follows:
Beginning with PowerShell 6.2, the **Encoding** parameter also allows numeric IDs of registered code
pages (like `-Encoding 1251`) or string names of registered code pages (like
`-Encoding "windows-1251"`). For more information, see the .NET documentation for
[Encoding.CodePage](/dotnet/api/system.text.encoding.codepage?view=netcore-2.2).
[Encoding.CodePage](xref:System.Text.Encoding.CodePage%2A).

Starting with PowerShell 7.4, you can use the `Ansi` value for the **Encoding** parameter to pass
the numeric ID for the current culture's ANSI code page without having to specify it manually.
Expand Down Expand Up @@ -429,8 +428,8 @@ You can use the `Add-Content` cmdlet to change the content of any alternate data
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 PowerShell 3.0. As of PowerShell 7.2, `Add-Content` can
target alternative data streams on both files and directories.
This parameter was introduced in PowerShell 3.0. As of PowerShell 7.2, `Add-Content` can target
alternative data streams on both files and directories.

```yaml
Type: System.String
Expand Down
19 changes: 10 additions & 9 deletions reference/7.5/Microsoft.PowerShell.Management/Clear-Item.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ Clears the contents of an item, but does not delete the item.
### Path (Default)

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

### LiteralPath

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

## DESCRIPTION
Expand Down Expand Up @@ -180,7 +180,8 @@ typed. No characters are interpreted as wildcards. If the path includes escape c
it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters
as escape sequences.

For more information, see [about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md).
For more information, see
[about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md).

```yaml
Type: System.String[]
Expand Down Expand Up @@ -247,10 +248,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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ Accept wildcard characters: True

### -Filter

Specifies a filter to qualify the **Path** parameter. The [FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md)
provider is the only installed PowerShell provider that supports the use of filters. You can find
the syntax for the **FileSystem** filter language in [about_Wildcards](../Microsoft.PowerShell.Core/About/about_Wildcards.md).
Filters are more efficient than other parameters, because the provider applies them when the cmdlet
gets the objects rather than having PowerShell filter the objects after they are retrieved.
Specifies a filter to qualify the **Path** parameter. The
[FileSystem](../Microsoft.PowerShell.Core/About/about_FileSystem_Provider.md) provider is the only
installed PowerShell provider that supports the use of filters. You can find the syntax for the
**FileSystem** filter language in
[about_Wildcards](../Microsoft.PowerShell.Core/About/about_Wildcards.md). Filters are more efficient
than other parameters, because the provider applies them when the cmdlet gets the objects rather
than having PowerShell filter the objects after they are retrieved.

```yaml
Type: System.String
Expand Down Expand Up @@ -153,7 +155,8 @@ typed. No characters are interpreted as wildcards. If the path includes escape c
it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters
as escape sequences.

For more information, see [about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md).
For more information, see
[about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md).

```yaml
Type: System.String[]
Expand Down Expand Up @@ -253,10 +256,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 Down
Loading