Updates from: 05/27/2021 03:27:32
Service Microsoft Docs article Related commit history on GitHub Change details
Microsoft.PowerShell.Core About Alias Provider (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Core/About/about_Alias_Provider.md
---
-description: Alias
-keywords: powershell,cmdlet
+description: Alias
Locale: en-US Last updated 10/18/2018
+no-loc: [Alias, Definition, AllScope, Option, None, Constant, Private]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_alias_provider?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Alias Provider
cmdlets.
## Types exposed by this provider Each alias is an instance of the
-[System.Management.Automation.AliasInfo](/dotnet/api/system.management.automation.aliasinfo) class.
+[System.Management.Automation.AliasInfo](/dotnet/api/system.management.automation.aliasinfo)
+class.
## Navigating the Alias drive
path.
> [!NOTE] > PowerShell uses aliases to allow you a familiar way to work with provider > paths. Commands such as `dir` and `ls` are now aliases for
-> [Get-ChildItem](xref:Microsoft.PowerShell.Management.Get-ChildItem),
-> `cd` is an alias for [Set-Location](xref:Microsoft.PowerShell.Management.Set-Location). and `pwd` is
-> an alias for [Get-Location](xref:Microsoft.PowerShell.Management.Get-Location).
+> [Get-ChildItem](xref:Microsoft.PowerShell.Management.Get-ChildItem), `cd` is
+> an alias for
+> [Set-Location](xref:Microsoft.PowerShell.Management.Set-Location). and `pwd`
+> is an alias for
+> [Get-Location](xref:Microsoft.PowerShell.Management.Get-Location).
### Displaying the Contents of the Alias: drive
$Alias:ls
### Get all aliases for a specific cmdlet This command gets a list of the aliases that are associated with the
-`Get-ChildItem` cmdlet. It uses the **Definition** property, which stores
-the cmdlet name.
+`Get-ChildItem` cmdlet. It uses the **Definition** property, which stores the
+cmdlet name.
```powershell Get-Item -Path Alias:* | Where-Object {$_.Definition -eq "Get-ChildItem"}
Get-Item -Path Alias:* | Where-Object {$_.Definition -eq "Get-ChildItem"}
### Create an alias from the Alias: drive This command creates the `serv` alias for the `Get-Service` cmdlet. Because the
-current location is in the `Alias:` drive, the `-Path` parameter is not
-needed.
+current location is in the `Alias:` drive, the `-Path` parameter is not needed.
This command also uses the `-Options` dynamic parameter to set the **AllScope**
-option on the alias. The `-Options` parameter is available in
-the `New-Item` cmdlet only when you are in the `Alias:` drive. The dot (`.`)
-indicates the current directory, which is the alias drive.
+option on the alias. The `-Options` parameter is available in the `New-Item`
+cmdlet only when you are in the `Alias:` drive. The dot (`.`) indicates the
+current directory, which is the alias drive.
``` PS Alias:\> New-Item -Path . -Name serv -Value Get-Service -Options "AllScope"
You can use this command in any PowerShell drive.
Remove-Item -Path Alias:serv ```
-This command deletes aliases that begin with "s".
-It does not delete read-only aliases.
+This command deletes aliases that begin with "s". It does not delete read-only
+aliases.
```powershell Clear-Item -Path Alias:s*
Clear-Item -Path Alias:s*
### Delete read-only aliases This command deletes all aliases from the current session, except those with a
-value of `Constant` for their **Options** property. The `-Force`
-parameter allows the command to delete aliases whose **Options** property has a
-value of `ReadOnly`.
+value of `Constant` for their **Options** property. The `-Force` parameter
+allows the command to delete aliases whose **Options** property has a value of
+`ReadOnly`.
```powershell Remove-Item Alias:* -Force
provider-enabled drive.
Determines the value of the **Options** property of an alias. - **None**: No options. This value is the default.-- **Constant**:The alias cannot be deleted and its properties cannot be changed.
- **Constant** is available only when you create an alias. You cannot change the
- option of an existing alias to **Constant**.
+- **Constant**:The alias cannot be deleted and its properties cannot be
+ changed. **Constant** is available only when you create an alias. You cannot
+ change the option of an existing alias to **Constant**.
- **Private**:The alias is visible only in the current scope, not in the child
- scopes.
-- **ReadOnly**:The properties of the alias cannot be changed except by using the
- `-Force` parameter. You can use `Remove-Item` to delete the alias.
+ scopes.
+- **ReadOnly**:The properties of the alias cannot be changed except by using
+ the `-Force` parameter. You can use `Remove-Item` to delete the alias.
- **AllScope**:The alias is copied to any new scopes that are created. #### Cmdlets supported
Beginning in Windows PowerShell 3.0, you can get customized help topics for
provider cmdlets that explain how those cmdlets behave in a file system drive. To get the help topics that are customized for the file system drive, run a
-[Get-Help](xref:Microsoft.PowerShell.Core.Get-Help) command in a file system drive or use the `-Path`
-parameter of [Get-Help](xref:Microsoft.PowerShell.Core.Get-Help) to specify a file system drive.
+[Get-Help](xref:Microsoft.PowerShell.Core.Get-Help) command in a file system
+drive or use the `-Path` parameter of
+[Get-Help](xref:Microsoft.PowerShell.Core.Get-Help) to specify a file system
+drive.
```powershell Get-Help Get-ChildItem
Microsoft.PowerShell.Core About Aliases (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Core/About/about_Aliases.md
--- description: Describes how to use alternate names for cmdlets and commands in PowerShell.
-keywords: powershell,cmdlet
Locale: en-US Last updated 11/27/2017
+no-loc: [Authenticode, Alias]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_aliases?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Aliases --- # about_Aliases
-## SHORT DESCRIPTION
-Describes how to use alternate names for cmdlets and commands in
-PowerShell.
+## Short description
+Describes how to use alternate names for cmdlets and commands in PowerShell.
-## LONG DESCRIPTION
+## Long description
An alias is an alternate name or nickname for a cmdlet or for a command element, such as a function, script, file, or executable file. You can use the alias instead of the command name in any PowerShell commands.
-To create an alias, use the New-Alias cmdlet. For example, the following
-command creates the "gas" alias for the `Get-AuthenticodeSignature` cmdlet:
+To create an alias, use the `New-Alias` cmdlet. For example, the following
+command creates the `gas` alias for the `Get-AuthenticodeSignature` cmdlet:
```powershell New-Alias -Name gas -Value Get-AuthenticodeSignature
New-Alias -Name gas -Value Get-AuthenticodeSignature
After you create the alias for the cmdlet name, you can use the alias instead of the cmdlet name. For example, to get the Authenticode signature for the
-SqlScript.ps1 file, type:
+`SqlScript.ps1` file, type:
```powershell Get-AuthenticodeSignature SqlScript.ps1
Or, type:
gas SqlScript.ps1 ```
-If you create "word" as the alias for Microsoft Office Word, you can type
+If you create `word` as the alias for Microsoft Office Word, you can type
"word" instead of the following: ```powershell "C:\Program Files\Microsoft Office\Office11\Winword.exe" ```
-## BUILT-IN ALIASES
+## Built in aliases
-PowerShell includes a set of built-in aliases, including "cd" and "chdir" for
-the Set-Location cmdlet, and "ls" and "dir" for the Get-ChildItem cmdlet.
+PowerShell includes a set of built-in aliases, including `cd` and `chdir` for
+the `Set-Location` cmdlet, and `ls` and `dir` for the `Get-ChildItem` cmdlet.
To get all the aliases on the computer, including the built-in aliases, type:
To get all the aliases on the computer, including the built-in aliases, type:
Get-Alias ```
-## ALIAS CMDLETS
+## Alias cmdlets
PowerShell includes the following cmdlets, which are designed for working with aliases:
For example, type:
Get-Help Export-Alias -Detailed ```
-## CREATING AN ALIAS
+## Creating an alias
-To create a new alias, use the New-Alias cmdlet. For example, to create the
-"gh" alias for Get-Help, type:
+To create a new alias, use the `New-Alias` cmdlet. For example, to create the
+`gh` alias for `Get-Help`, type:
```powershell New-Alias -Name gh -Value Get-Help
New-Alias -Name gh -Value Get-Help
You can use the alias in commands, just as you would use the full cmdlet name, and you can use the alias with parameters.
-For example, to get detailed Help for the Get-WmiObject cmdlet, type:
+For example, to get detailed Help for the `Get-CimInstance` cmdlet, type:
```powershell
-Get-Help Get-WmiObject -Detailed
+Get-Help Get-CimInstance -Detailed
``` Or, type: ```powershell
-gh Get-WmiObject -Detailed
+gh Get-CimInstance -Detailed
```
-## SAVING ALIASES
+## Saving aliases
The aliases that you create are saved only in the current session. To use the aliases in a different session, add the alias to your PowerShell profile. Or,
-use the Export-Alias cmdlet to save the aliases to a file.
+use the `Export-Alias` cmdlet to save the aliases to a file.
For more information, type:
For more information, type:
Get-Help about_Profiles ```
-## GETTING ALIASES
+## Getting aliases
To get all the aliases in the current session, including the built-in aliases, the aliases in your PowerShell profiles, and the aliases that you have created
in the current session, type:
Get-Alias ```
-To get particular aliases, use the Name parameter of the Get-Alias cmdlet. For
+To get particular aliases, use the Name parameter of the `Get-Alias` cmdlet. For
example, to get aliases that begin with "p", type: ```powershell
Get-Alias -Name p*
``` To get the aliases for a particular item, use the Definition parameter. For
-example, to get the aliases for the Get-ChildItem cmdlet type:
+example, to get the aliases for the `Get-ChildItem` cmdlet type:
```powershell Get-Alias -Definition Get-ChildItem ```
-### GET-ALIAS OUTPUT
+### Get-Alias output
-Get-Alias returns only one type of object, an AliasInfo object
-(System.Management.Automation.AliasInfo). The name of aliases that don't
-include a hyphen, such as "cd" are displayed in the following format:
+`Get-Alias` returns only one type of object, an **AliasInfo** object
+(**System.Management.Automation.AliasInfo**). The name of aliases that don't
+include a hyphen, such as `cd` are displayed in the following format:
```powershell Get-Alias ac
hyphen. These are likely to be preferred substitute names for cmdlets and
functions, instead of typical abbreviations or nicknames, and the author might not want them to be as evident.
-## ALTERNATE NAMES FOR COMMANDS WITH PARAMETERS
+## Alternate names for commands with parameters
You can assign an alias to a cmdlet, script, function, or executable file. You cannot assign an alias to a command and its parameters. For example, you can
For more information about functions, type:
Get-Help about_Functions ```
-## ALIAS OBJECTS
+## Alias objects
PowerShell aliases are represented by objects that are instances of the System.Management.Automation.AliasInfo class. For more information about this type of object, see [AliasInfo Class][aliasinfo] in the PowerShell SDK. To view the properties and methods of the alias objects, get the aliases.
-Then, pipe them to the Get-Member cmdlet. For example:
+Then, pipe them to the `Get-Member` cmdlet. For example:
```powershell Get-Alias | Get-Member ``` To view the values of the properties of a specific alias, such as the `dir`
-alias, get the alias. Then, pipe it to the Format-List cmdlet. For example,
-the following command gets the "dir" alias. Next, the command pipes the alias
-to the Format-List cmdlet. Then, the command uses the Property parameter of
-Format-List with a wildcard character (\*) to display all the properties of
+alias, get the alias. Then, pipe it to the `Format-List` cmdlet. For example,
+the following command gets the `dir` alias. Next, the command pipes the alias
+to the `Format-List` cmdlet. Then, the command uses the Property parameter of
+`Format-List` with a wildcard character (`*`) to display all the properties of
the `dir` alias. The following command performs these tasks: ```powershell Get-Alias -Name dir | Format-List -Property * ```
-## PowerShell ALIAS PROVIDER
+## PowerShell Alias provider
PowerShell includes the Alias provider. The Alias provider lets you view the aliases in PowerShell as though they were on a file system drive.
For more information about the PowerShell Alias provider, type:
Get-Help Alias ```
-## SEE ALSO
+## See also
- [New-Alias](xref:Microsoft.PowerShell.Utility.New-Alias) - [Get-Alias](xref:Microsoft.PowerShell.Utility.Get-Alias)
Microsoft.PowerShell.Core About Arithmetic Operators (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Core/About/about_Arithmetic_Operators.md
---
-description: Describes the operators that perform arithmetic in PowerShell.
-keywords: powershell,cmdlet
+description: Describes the operators that perform arithmetic in PowerShell.
Locale: en-US Last updated 10/08/2020 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_arithmetic_operators?view=powershell-5.1&WT.mc_id=ps-gethelp
Title: about Arithmetic Operators
--- # about_Arithmetic_Operators
-## SHORT DESCRIPTION
+## Short description
Describes the operators that perform arithmetic in PowerShell.
-## LONG DESCRIPTION
+## Long description
Arithmetic operators calculate numeric values. You can use one or more arithmetic operators to add, subtract, multiply, and divide values, and to
PowerShell supports the following arithmetic operators:
The bitwise operators only work on integer types.
-## OPERATOR PRECEDENCE
+## Operator precedence
PowerShell processes arithmetic operators in the following order:
$a = $a + 1
$b[$a] = $tmp ```
-## DIVISION AND ROUNDING
+## Division and rounding
When the quotient of a division operation is an integer, PowerShell rounds the value to the nearest integer. When the value is `.5`, it rounds to the
You can use the `[Math]` class to get different rounding behavior.
For more information, see the [Math.Round](/dotnet/api/system.math.round) method.
-## ADDING AND MULTIPLYING NON-NUMERIC TYPES
+## Adding and multiplying non numeric types
You can add numbers, strings, arrays, and hash tables. And, you can multiply numbers, strings, and arrays. However, you cannot multiply hash
B
C ```
-You can also perform arithmetic operations on objects of different types.
-The operation that PowerShell performs is determined by the Microsoft .NET
-Framework type of the leftmost object in the operation. PowerShell tries to
-convert all the objects in the operation to the .NET Framework type of the
-first object. If it succeeds in converting the objects, it performs the
-operation appropriate to the .NET Framework type of the first object. If it
-fails to convert any of the objects, the operation fails.
+You can also perform arithmetic operations on objects of different types. The
+operation that PowerShell performs is determined by the Microsoft .NET type of
+the leftmost object in the operation. PowerShell tries to convert all the
+objects in the operation to the .NET type of the first object. If it succeeds
+in converting the objects, it performs the operation appropriate to the .NET
+type of the first object. If it fails to convert any of the objects, the
+operation fails.
The following examples demonstrate the use of the addition and multiplication operators; in operations that include different object
$array
2 ```
-## TYPE CONVERSION TO ACCOMMODATE RESULT
+## Type conversion to accommodate result
-PowerShell automatically selects the .NET Framework numeric type that best
-expresses the result without losing precision. For example:
+PowerShell automatically selects the .NET numeric type that best expresses the
+result without losing precision. For example:
```powershell 2 + 3.1
System.Int32
System.Double ```
-If the result of an operation is too large for the type, the type of the
-result is widened to accommodate the result, as in the following example:
+If the result of an operation is too large for the type, the type of the result
+is widened to accommodate the result, as in the following example:
```powershell (512MB).GetType().FullName
System.Int32
System.Double ```
-The type of the result will not necessarily be the same as one of the
-operands. In the following example, the negative value cannot be cast to an
-unsigned integer, and the unsigned integer is too large to be cast to
-`Int32`:
+The type of the result will not necessarily be the same as one of the operands.
+In the following example, the negative value cannot be cast to an unsigned
+integer, and the unsigned integer is too large to be cast to `Int32`:
```powershell ([int32]::minvalue + [uint32]::maxvalue).gettype().fullname
System.Int64
In this example, `Int64` can accommodate both types.
-The `System.Decimal` type is an exception. If either operand has the
-Decimal type, the result will be of the Decimal type. If the result is too
-large for the Decimal type, it will not be cast to Double. Instead, an
-error results.
+The `System.Decimal` type is an exception. If either operand has the **Decimal**
+type, the result will be of the Decimal type. If the result is too large for
+the **Decimal** type, it will not be cast to Double. Instead, an error results.
|Expression |Result | |-------------------------|-----------------------------------------------|
error results.
|`[Decimal]::maxvalue + 1`|`Value was either too large or too small for a`| | |`Decimal.` |
-## ARITHMETIC OPERATORS AND VARIABLES
+## Arithmetic operators and variables
-You can also use arithmetic operators with variables. The operators act on
-the values of the variables. The following examples demonstrate the use of
+You can also use arithmetic operators with variables. The operators act on the
+values of the variables. The following examples demonstrate the use of
arithmetic operators with variables: | Expression |Result |
arithmetic operators with variables:
|`$intA = 6`<br/>`$intB = 4`<br/>`$intA + $intB`|`10` | |`$a = "Power"`<br/>`$b = "Shell"`<br/>`$a + $b`|`PowerShell`|
-## ARITHMETIC OPERATORS AND COMMANDS
+## Arithmetic operators and commands
Typically, you use the arithmetic operators in expressions with numbers,
-strings, and arrays. However, you can also use arithmetic operators with
-the objects that commands return and with the properties of those objects.
+strings, and arrays. However, you can also use arithmetic operators with the
+objects that commands return and with the properties of those objects.
-The following examples show how to use the arithmetic operators in
-expressions with PowerShell commands:
+The following examples show how to use the arithmetic operators in expressions
+with PowerShell commands:
```powershell (get-date) + (new-timespan -day 1) ```
-The parenthesis operator forces the evaluation of the `get-date` cmdlet and
-the evaluation of the `new-timespan -day 1` cmdlet expression, in that
-order. Both results are then added using the `+` operator.
+The parenthesis operator forces the evaluation of the `Get-Date` cmdlet and the
+evaluation of the `New-TimeSpan -Day 1` cmdlet expression, in that order. Both
+results are then added using the `+` operator.
```powershell Get-Process | Where-Object { ($_.ws * 2) -gt 50mb }
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
967 30 58804 59496 416 930.97 2508 WINWORD ```
-In the above expression, each process working space (`$_.ws`) is multiplied
-by `2`; and, the result, compared against `50mb` to see if it is greater
-than that.
+In the above expression, each process working space (`$_.ws`) is multiplied by
+`2`; and, the result, compared against `50mb` to see if it is greater than
+that.
-## Bitwise Operators
+## Bitwise operators
PowerShell supports the standard bitwise operators, including bitwise-AND (`-bAnd`), the inclusive and exclusive bitwise-OR operators (`-bOr` and `-bXor`), and bitwise-NOT (`-bNot`).
-Beginning in PowerShell 2.0, all bitwise operators work with 64-bit
-integers.
+Beginning in PowerShell 2.0, all bitwise operators work with 64-bit integers.
Beginning in PowerShell 3.0, the `-shr` (shift-right) and `-shl` (shift-left) are introduced to support bitwise arithmetic in PowerShell.
structure for the number 10 is 00001010 (based on 1 byte), and the bit
structure for the number 3 is 00000011. When you use a bitwise operator to compare 10 to 3, the individual bits in each byte are compared.
-In a bitwise AND operation, the resulting bit is set to 1 only when both
-input bits are 1.
+In a bitwise AND operation, the resulting bit is set to 1 only when both input
+bits are 1.
``` 1010 (10)
input bits are 1.
``` In a bitwise OR (inclusive) operation, the resulting bit is set to 1 when
-either or both input bits are 1. The resulting bit is set to 0 only when
-both input bits are set to 0.
+either or both input bits are 1. The resulting bit is set to 0 only when both
+input bits are set to 0.
``` 1010 (10)
right operand determine how many bits of the left operand are shifted.
|`[int]::MinValue -shr 1`| -1073741824| | 0xC0000000 | |`-1 -shr 1` | -1 | | 0xFFFFFFFF |
-## SEE ALSO
+## See also
- [about_arrays](about_Arrays.md) - [about_assignment_operators](about_Assignment_Operators.md)
Microsoft.PowerShell.Core About Arrays (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Core/About/about_Arrays.md
description: Describes arrays, which are data structures designed to store collections of items. Locale: en-US Last updated 08/26/2020
+no-loc: [Count, Length, LongLength, Rank, ForEach, Clear, Default, First, Last, SkipUntil, Until, Split, Tuple]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_arrays?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Arrays
and 4000), type:
As a result, the `$ia` array can contain only integers.
-You can create arrays that are cast to any supported type in the Microsoft
-.NET Framework. For example, the objects that `Get-Process` retrieves to
-represent processes are of the **System.Diagnostics.Process** type. To create a
-strongly typed array of process objects, enter the following command:
+You can create arrays that are cast to any supported type in the .NET. For
+example, the objects that `Get-Process` retrieves to represent processes are of
+the **System.Diagnostics.Process** type. To create a strongly typed array of
+process objects, enter the following command:
```powershell [Diagnostics.Process[]]$zz = Get-Process
$a[+0..2+4..6+8]
### Iterations over array elements
-You can also use looping constructs, such as ForEach, For, and While loops, to
-refer to the elements in an array. For example, to use a ForEach loop to
-display the elements in the `$a` array, type:
+You can also use looping constructs, such as `ForEach`, `For`, and `While`
+loops, to refer to the elements in an array. For example, to use a `ForEach`
+loop to display the elements in the `$a` array, type:
```powershell $a = 0..9
foreach ($element in $a) {
9 ```
-The Foreach loop iterates through the array and returns each value in the
+The `Foreach` loop iterates through the array and returns each value in the
array until reaching the end of the array.
-The For loop is useful when you are incrementing counters while examining the
-elements in an array. For example, to use a For loop to return every other
+The `For` loop is useful when you are incrementing counters while examining the
+elements in an array. For example, to use a `For` loop to return every other
value in an array, type: ```powershell
for ($i = 0; $i -le ($a.length - 1); $i += 2) {
8 ```
-You can use a While loop to display the elements in an array until a defined
+You can use a `While` loop to display the elements in an array until a defined
condition is no longer true. For example, to display the elements in the `$a` array while the array index is less than 4, type:
while($i -lt 4) {
### Count or Length or LongLength
-To determine how many items are in an array, use the `Length` property or its
-`Count` alias. `Longlength` is useful if the array contains more than
+To determine how many items are in an array, use the **Length** property or its
+**Count** alias. **Longlength** is useful if the array contains more than
2,147,483,647 elements. ```powershell
True
### Clear Sets all element values to the _default value_ of the array's element type.
-The Clear() method does not reset the size of the array.
+The `Clear()` method does not reset the size of the array.
In the following example `$a` is an array of objects.
$intA
Allows to iterate over all elements in the array and perform a given operation for each element of the array.
-The ForEach method has several overloads that perform different operations.
+The `ForEach` method has several overloads that perform different operations.
``` ForEach(scriptblock expression)
This method was added in PowerShell v4.
> the scriptblock is the only parameter. Also, there must not be a space > between the method and the opening parenthesis or brace.
-The following example shows how use the foreach method. In this case the
+The following example shows how use the `ForEach` method. In this case the
intent is to generate the square value of the elements in the array. ```powershell
TWO
THREE ```
-Just like the `-ArgumentList` parameter of `ForEach-Object`, the `arguments`
-parameter allows the passing of an array of arguments to a script block
-configured to accept them.
+Just like the `-ArgumentList` parameter of `ForEach-Object`, the `Arguments`
+parameter allows the passing of an array of values to a script block configured
+to accept them.
> [!NOTE] > Starting in Windows PowerShell 3.0 retrieving properties and executing > methods for each item in a collection can also be accomplished using "Methods
-> of scalar objects and collections" You can read more about that here
+> of scalar objects and collections". You can read more about that here
> [about_methods](about_methods.md). ### Where
Microsoft.PowerShell.Core About Assignment Operators (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Core/About/about_Assignment_Operators.md
$d
7 ```
-## Microsoft .NET Framework types
+## Microsoft .NET types
By default, when a variable has only one value, the value that is assigned to the variable determines the data type of the variable. For example, the
type:
$a = 6 ```
-To find the .NET Framework type of a variable, use the **GetType** method and
-its **FullName** property, as follows. Be sure to include the parentheses after
-the **GetType** method name, even though the method call has no arguments:
+To find the .NET type of a variable, use the **GetType** method and its
+**FullName** property, as follows. Be sure to include the parentheses after the
+**GetType** method name, even though the method call has no arguments:
```powershell $a = 6
$a
9 ```
-You can cast a new scalar variable as any .NET Framework type by placing the
-type name in brackets that precede either the variable name or the first
-assignment value. When you cast a variable, you can determine the types of data
-that can be stored in the variable. And, you can determine how the variable
-behaves when you manipulate it.
+You can cast a new scalar variable as any .NET type by placing the type name in
+brackets that precede either the variable name or the first assignment value.
+When you cast a variable, you can determine the types of data that can be
+stored in the variable. And, you can determine how the variable behaves when
+you manipulate it.
For example, the following command casts the variable as a string type:
example, the following command casts the variable as a `string []` array type:
[string []] $a = "one", "two", "three" ```
-PowerShell variables can be any .NET Framework data type. In addition, you can
-assign any fully qualified .NET Framework data type that is available in the
-current process. For example, the following command specifies a
-`System.DateTime` data type:
+PowerShell variables can be any .NET data type. In addition, you can assign any
+fully qualified .NET data type that is available in the current process. For
+example, the following command specifies a `System.DateTime` data type:
```powershell [System.DateTime]$a = "5/31/2005"
Microsoft.PowerShell.Core About Automatic Variables (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md
--- description: Describes variables that store state information for PowerShell. These variables are created and maintained by PowerShell. Locale: en-US Previously updated : 03/29/2021 Last updated : 05/13/2021
+no-loc: [Reset, Current]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Automatic Variables
is particularly useful for finding the name of the current script.
Beginning in PowerShell 3.0, `MyInvocation` has the following new properties.
-| Property | Description |
-| ------------- | --------------------------------------------------- |
-| **PSScriptRoot** | Contains the full path to the script that invoked |
-| | the current command. The value of this property is |
-| | populated only when the caller is a script. |
-| **PSCommandPath** | Contains the full path and file name of the script |
-| | that invoked the current command. The value of this |
-| | property is populated only when the caller is a |
-| | script. |
+- **PSScriptRoot** - Contains the full path to the script that invoked the
+ current command. The value of this property is populated only when the caller
+ is a script.
+- **PSCommandPath** - Contains the full path and file name of the script that
+ invoked the current command. The value of this property is populated only
+ when the caller is a script.
Unlike the `$PSScriptRoot` and `$PSCommandPath` automatic variables, the **PSScriptRoot** and **PSCommandPath** properties of the `$MyInvocation`
-automatic variable contain information about the invoker or calling script,
-not the current script.
+automatic variable contain information about the invoker or calling script, not
+the current script.
### $NestedPromptLevel
following items:
| Property | Description | | ------------------------- | --------------------------------------------- | | **BuildVersion** | The build number of the current version |
-| **CLRVersion** | The version of the common language runtime |
-| | (CLR) |
-| **PSCompatibleVersions** | Versions of PowerShell that are compatible |
-| | with the current version |
-| **PSEdition** | This property has the value of 'Desktop', for |
-| | Windows Server and Windows client versions. |
-| | This property has the value of 'Core' for |
-| | PowerShell running under Nano Server or |
-| | Windows IOT. |
-| **PSRemotingProtocolVersion** | The version of the PowerShell remote |
-| | management protocol. |
-| **PSVersion** | The PowerShell version number |
-| **SerializationVersion** | The version of the serialization method |
-| **WSManStackVersion** | The version number of the WS-Management stack |
+- **CLRVersion** - The version of the common language runtime (CLR)
+- **PSCompatibleVersions** - Versions of PowerShell that are compatible with
+ the current version
+- **PSEdition** - This property has the value of 'Desktop', for Windows Server
+ and Windows client versions. This property has the value of 'Core' for
+ PowerShell running under Nano Server or Windows IOT.
+- **PSRemotingProtocolVersion** - The version of the PowerShell remote
+ management protocol.
+- **PSVersion** - The PowerShell version number
+- **SerializationVersion** - The version of the serialization method
+- **WSManStackVersion** - The version number of the WS-Management stack
### $PWD
An enumerator contains properties and methods you can use to advance or reset
iteration, or retrieve iteration values. Directly manipulating enumerators isn't considered best practice. -- Within loops, flow control keywords [break](about_Break.md) and [continue](about_Continue.md)
- should be preferred.
+- Within loops, flow control keywords [break](about_Break.md) and
+ [continue](about_Continue.md) should be preferred.
- Within functions that accept pipeline input, it's best practice to use
- Parameters with the **ValueFromPipeline** or
+ parameters with the **ValueFromPipeline** or
**ValueFromPipelineByPropertyName** attributes.
- For more information, see [about_Functions_Advanced_Parameters](about_Functions_Advanced_Parameters.md).
+ For more information, see
+ [about_Functions_Advanced_Parameters](about_Functions_Advanced_Parameters.md).
### MoveNext The [MoveNext](/dotnet/api/system.collections.ienumerator.movenext) method advances the enumerator to the next element of the collection. **MoveNext**
-returns **True** if the enumerator was successfully advanced, **False** if
-the enumerator has passed the end of the collection.
+returns `True` if the enumerator was successfully advanced, `False` if the
+enumerator has passed the end of the collection.
> [!NOTE] > The **Boolean** value returned my **MoveNext** is sent to the output stream.
Num has not changed: two
``` Using the **Reset** method resets the current element in the collection. The
-following example loops through the first two elements **twice** because the
+following example loops through the first two elements _twice_ because the
**Reset** method is called. After the first two loops, the `if` statement fails and the loop iterates through all three elements normally.
Microsoft.PowerShell.Core About Break (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Core/About/about_Break.md
---
-description: Describes a statement you can use to immediately exit `foreach`, `for`, `while`, `do`, `switch`, or `trap` statements.
-keywords: powershell,cmdlet
+description: Describes a statement you can use to immediately exit `foreach`, `for`, `while`, `do`, `switch`, or `trap` statements.
Locale: en-US Last updated 06/04/2020 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_break?view=powershell-5.1&WT.mc_id=ps-gethelp
Execution continues at the next statement after the control block. The
statement supports labels. A label is a name you assign to a statement in a script.
-## Using break in loops
+## Using `break` in loops
When a `break` statement appears in a loop, such as a `foreach`, `for`, `do`, or `while` loop, PowerShell immediately exits the loop.
variable `$i` is incremented by 1. The third time the loop is run, `$i` equals
2, and the `$val` variable equals 30. At this point, the `break` statement runs, and the `foreach` loop exits.
-### Using a labeled break in a loop
+### Using a labeled `break` in a loop
A `break` statement can include a label. If you use the `break` keyword with a label, PowerShell exits the labeled loop instead of exiting the current loop.
loop. No label is needed.
PowerShell does not limit how far labels can resume execution. The label can even pass control across script and function call boundaries.
-## Using break in a switch statement
+## Using `break` in a `switch` statement
In a `switch`construct, `break` causes PowerShell to exit the `switch` code block.
exits. If the four `break` statements are removed from the example, all four
conditions are met. This example uses the `break` statement to display results when the most specific condition is met.
-## Using break in a trap statement
+## Using `break` in a `trap` statement
If the final statement executed in the body of a `trap` statement is `break`, the error object is suppressed and the exception is re-thrown.
At line:10 char:6
+ FullyQualifiedErrorId : RuntimeException ```
-## Do not use break outside of a loop, switch, or trap
+## Do not use `break` outside of a loop, `switch`, or `trap`
When `break` is used outside of a construct that directly supports it (loops, `switch`, `trap`), PowerShell looks _up the call stack_ for an
Microsoft.PowerShell.Core About Execution Policies (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Core/About/about_Execution_Policies.md
---
-description: Describes the PowerShell execution policies and explains how to manage them.
-keywords: powershell,cmdlet
+description: Describes the PowerShell execution policies and explains how to manage them.
Locale: en-US Last updated 08/10/2020
+no-loc: [Bypass, Default, Restricted, Undefined, Process, Scope]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Execution Policies
Title: about Execution Policies
# about_Execution_Policies ## Short Description- Describes the PowerShell execution policies and explains how to manage them. ## Long Description
If no execution policy is set in any scope, the effective execution policy is
### Set a different policy for one session
-You can use the **ExecutionPolicy** parameter of **powershell.exe** to set an
+You can use the **ExecutionPolicy** parameter of `powershell.exe` to set an
execution policy for a new PowerShell session. The policy affects only the current session and child sessions. To set the execution policy for a new session, start PowerShell at the command
-line, such as **cmd.exe** or from PowerShell, and then use the
-**ExecutionPolicy** parameter of **powershell.exe** to set the execution
+line, such as `cmd.exe` or from PowerShell, and then use the
+**ExecutionPolicy** parameter of `powershell.exe` to set the execution
policy. For example:
Configuration nodes in Group Policy Editor in the following paths.
For Windows XP and Windows Server 2003:
-Administrative Templates\Windows Components\Windows PowerShell
+`Administrative Templates\Windows Components\Windows PowerShell`
For Windows Vista and later versions of Windows:
-Administrative Templates\Classic Administrative Templates\
-Windows Components\Windows PowerShell
+`Administrative Templates\Classic Administrative Templates\Windows Components\Windows PowerShell`
Policies set in the Computer Configuration node take precedence over policies set in the User Configuration node.
For more information, see [about_Group_Policy_Settings](about_Group_Policy_Setti
When determining the effective execution policy for a session, PowerShell evaluates the execution policies in the following precedence order: -- Group Policy: MachinePolicy-- Group Policy: UserPolicy-- Execution Policy: Process (or `powershell.exe -ExecutionPolicy`)-- Execution Policy: CurrentUser-- Execution Policy: LocalMachine
+```
+Group Policy: MachinePolicy
+Group Policy: UserPolicy
+Execution Policy: Process (or pwsh.exe -ExecutionPolicy)
+Execution Policy: CurrentUser
+Execution Policy: LocalMachine
+```
## Manage signed and unsigned scripts
Beginning in PowerShell 3.0, you can use the **Stream** parameter of the
from the internet. Use the `Unblock-File` cmdlet to unblock the scripts so that you can run them in PowerShell.
-For more information, see [about_Signing](about_Signing.md), [Get-Item](xref:Microsoft.PowerShell.Management.Get-Item),
-and [Unblock-File](xref:Microsoft.PowerShell.Utility.Unblock-File).
+For more information, see [about_Signing](about_Signing.md),
+[Get-Item](xref:Microsoft.PowerShell.Management.Get-Item), and
+[Unblock-File](xref:Microsoft.PowerShell.Utility.Unblock-File).
> [!NOTE] > Other methods of downloading files may not mark the files as coming from the
Microsoft.PowerShell.Management Get Itemproperty (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Management/Get-ItemProperty.md
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
keywords: powershell,cmdlet Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 10/18/2018 Last updated : 05/25/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/get-itemproperty?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Get-ItemProperty
Get-ItemProperty -LiteralPath <String[]> [[-Name] <String[]>] [-Filter <String>]
## DESCRIPTION
-The `Get-ItemProperty` cmdlet gets the properties of the specified items.
-For example, you can use this cmdlet to get the value of the LastAccessTime property of a file object.
-You can also use this cmdlet to view registry entries and their values.
+The `Get-ItemProperty` cmdlet gets the properties of the specified items. For example, you can use
+this cmdlet to get the value of the LastAccessTime property of a file object. You can also use this
+cmdlet to view registry entries and their values.
## EXAMPLES
Get-ItemProperty C:\Windows
### Example 2: Get the properties of a specific file
-This command gets the properties of the "C:\Test\Weather.xls" file.
-The result is piped to the `Format-List` cmdlet to display the output as a list.
+This command gets the properties of the `C:\Test\Weather.xls` file. The result is piped to the
+`Format-List` cmdlet to display the output as a list.
```powershell Get-ItemProperty C:\Test\Weather.xls | Format-List
Get-ItemProperty C:\Test\Weather.xls | Format-List
### Example 3: Display the value name and data of registry entries in a registry subkey
-This command displays the value name and data of each of the registry entries contained in the "CurrentVersion" registry subkey.
-Note that the command requires that there is a PowerShell drive named `HKLM:` that is mapped to the "HKEY_LOCAL_MACHINE" hive of the registry.
-A drive with that name and mapping is available in PowerShell by default.
-Alternatively, the path to this registry subkey can be specified by using the following alternative path that begins with the provider name followed by two colons:
+This command displays the value name and data of each of the registry entries contained in the
+"CurrentVersion" registry subkey. Note that the command requires that there is a PowerShell drive
+named `HKLM:` that is mapped to the `HKEY_LOCAL_MACHINE` hive of the registry. A drive with that
+name and mapping is available in PowerShell by default. Alternatively, the path to this registry
+subkey can be specified by using the following alternative path that begins with the provider name
+followed by two colons:
-"Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion".
+`Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion`
```powershell Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion
Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion
### Example 4: Get the value name and data of a registry entry in a registry subkey
-This command gets the value name and data of the "ProgramFilesDir" registry entry in the "CurrentVersion" registry subkey.
-The command uses the **Path** parameter to specify the subkey and the Name parameter to specify the value name of the entry.
+This command gets the value name and data of the `ProgramFilesDir` registry entry in the
+`CurrentVersion` registry subkey. The command uses the **Path** parameter to specify the subkey and
+the Name parameter to specify the value name of the entry.
-The command uses a back tick or grave accent (\`), the PowerShell continuation character, to continue the command on the second line.
+The command uses a back tick or grave accent (\`), the PowerShell continuation character, to
+continue the command on the second line.
```powershell Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion -Name "ProgramFilesDir"
Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion -Name "Pr
### Example 5: Get the value names and data of registry entries in a registry key
-This command gets the value names and data of the registry entries in the "PowerShellEngine" registry key.
-The results are shown in the following sample output.
+This command gets the value names and data of the registry entries in the "PowerShellEngine"
+registry key. The results are shown in the following sample output.
```powershell Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine
PSCompatibleVersion : 1.0,2.0
### Example 6: Get, format, and display the results of registry values and data
-This example shows how to format the output of a `Get-ItemProperty` command in a list to make it easy to see the registry values and data and to make it easy to interpret the results.
+This example shows how to format the output of a `Get-ItemProperty` command in a list to make it
+easy to see the registry values and data and to make it easy to interpret the results.
-The first command uses the `Get-ItemProperty` cmdlet to get the registry entries in the **Microsoft.PowerShell** subkey.
-This subkey stores options for the default shell for PowerShell.
-The results are shown in the following sample output.
+The first command uses the `Get-ItemProperty` cmdlet to get the registry entries in the
+`Microsoft.PowerShell` subkey. This subkey stores options for the default shell for PowerShell. The
+results are shown in the following sample output.
-The output shows that there are two registry entries, "Path" and "ExecutionPolicy".
-When a registry key contains fewer than five entries, by default it is displayed in a table, but it is often easier to view in a list.
+The output shows that there are two registry entries, `Path` and `ExecutionPolicy`. When a registry
+key contains fewer than five entries, by default it is displayed in a table, but it is often easier
+to view in a list.
-The second command uses the same `Get-ItemProperty` command.
-However, this time, the command uses a pipeline operator (`|`) to send the results of the command to the `Format-List` cmdlet.
-The `Format-List` command uses the Property parameter with a value of '*' (all) to display all of the properties of the objects in a list.
-The results are shown in the following sample output.
+The second command uses the same `Get-ItemProperty` command. However, this time, the command uses a
+pipeline operator (`|`) to send the results of the command to the `Format-List` cmdlet. The
+`Format-List` command uses the Property parameter with a value of '*' (all) to display all of the
+properties of the objects in a list. The results are shown in the following sample output.
-The resulting display shows the "Path" and "ExecutionPolicy" registry entries, along with several less familiar properties of the registry key object.
-The other properties, prefixed with PS, are properties of PowerShell custom objects, such as the objects that represent the registry keys.
+The resulting display shows the `Path` and `ExecutionPolicy` registry entries, along with several
+less familiar properties of the registry key object. The other properties, prefixed with PS, are
+properties of PowerShell custom objects, such as the objects that represent the registry keys.
```powershell Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
ExecutionPolicy : RemoteSigned
### -Credential
-Specifies a user account that has permission to perform this action.
-The default is the current user.
+Specifies a user account that has permission to perform this action. The default is the current
+user.
-Type a user name, such as "User01" or "Domain01\User01", or enter a **PSCredential** object, such as one generated by the `Get-Credential` cmdlet.
-If you type a user name, you are prompted for a password.
+Type a user name, such as "User01" or "Domain01\User01", or enter a **PSCredential** object, such as
+one generated by the `Get-Credential` cmdlet. If you type a user name, you are prompted for a
+password.
> [!WARNING] > This parameter is not supported by any providers installed with Windows PowerShell.
Accept wildcard characters: False
### -Exclude
-Specifies, as a string array, an item or items that this cmdlet excludes from the operation.
-The value of this parameter qualifies the **Path** parameter.
-Enter a path element or pattern, such as "*.txt".
-Wildcard characters are permitted.
+Specifies, as a string array, an item or items that this cmdlet excludes from the operation. The
+value of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as
+"*.txt". Wildcard characters are permitted.
```yaml Type: System.String[]
Accept wildcard characters: False
### -Filter
-Specifies a filter in the format or language of the provider.
-The value of this parameter qualifies the **Path** parameter.
+Specifies a filter in the format or language of the provider. The value of this parameter qualifies
+the **Path** parameter.
-The syntax of the filter, including the use of wildcard characters, depends on the provider.
-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.
+The syntax of the filter, including the use of wildcard characters, depends on the provider. 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
Accept wildcard characters: True
### -Include
-Specifies, as a string array, an item or items that this cmdlet includes in the operation.
-The value of this parameter qualifies the **Path** parameter.
-Enter a path element or pattern, such as "*.txt".
-Wildcard characters are permitted.
+Specifies, as a string array, an item or items that this cmdlet includes in the operation. The value
+of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as
+"*.txt". Wildcard characters are permitted.
```yaml Type: System.String[]
Accept wildcard characters: False
### -LiteralPath
-Specifies the path to the current location of the property.
-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 PowerShell not to interpret any characters as escape sequences.
+Specifies the path to the current location of the property. 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 PowerShell not to interpret any characters as escape sequences.
```yaml Type: System.String[]
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 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 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
You can pipe a string that contains a path to `Get-ItemProperty`.
### System.Boolean, System.String, System.DateTime
-`Get-ItemProperty` returns an object for each item property that it gets.
-The object type depends on the object that is retrieved.
-For example, in a file system drive, it might return a file or folder.
+`Get-ItemProperty` returns an object for each item property that it gets. The object type depends on
+the object that is retrieved. For example, in a file system drive, it might return a file or folder.
## NOTES
-The `Get-ItemProperty` cmdlet is designed to work with the data exposed by any provider. To list the providers available in your session, type "`Get-PSProvider`". For more information, see about_Providers.
+The `Get-ItemProperty` cmdlet is designed to work with the data exposed by any provider. To list the
+providers available in your session, type "`Get-PSProvider`". For more information, see
+about_Providers.
## RELATED LINKS
Microsoft.PowerShell.Management Get Itempropertyvalue (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Management/Get-ItemPropertyValue.md
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
keywords: powershell,cmdlet Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 10/18/2018 Last updated : 05/25/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/get-itempropertyvalue?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Get-ItemPropertyValue
Get-ItemPropertyValue -LiteralPath <String[]> [-Name] <String[]> [-Filter <Strin
## DESCRIPTION
-The `Get-ItemPropertyValue` gets the current value for a property that you specify when you use the *Name* parameter, located in a path that you specify with either the *Path* or *LiteralPath* parameters.
+The `Get-ItemPropertyValue` gets the current value for a property that you specify when you use the
+**Name** parameter, located in a path that you specify with either the **Path** or **LiteralPath**
+parameters.
## EXAMPLES ### Example 1: Get the value of the ProductID property
-This command gets the value of the **ProductID** property of the "\SOFTWARE\Microsoft\Windows NT\CurrentVersion" object in the Windows Registry provider.
+This command gets the value of the **ProductID** property of the `\SOFTWARE\Microsoft\WindowsNT\CurrentVersion`
+object in the Windows Registry provider.
```powershell Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name ProductID
Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name
### Example 2: Get the last write time of a file or folder
-This command gets the value of the **LastWriteTime** property, or the last time a file or folder was changed, from the "C:\Users\Test\Documents\ModuleToAssembly" folder, working in the FileSystem provider.
+This command gets the value of the **LastWriteTime** property, or the last time a file or folder was
+changed, from the `C:\Program Files\WindowsPowerShell` folder, working in the FileSystem
+provider.
```powershell
-Get-ItemPropertyValue -Path C:\Users\Test\Documents\ModuleToAssembly -Name LastWriteTime
+Get-ItemPropertyValue -Path 'C:\Program Files\WindowsPowerShell' -Name LastWriteTime
``` ```output
Wednesday, September 3, 2014 2:53:22 PM
### Example 3: Get multiple property values of a file or folder
-This command gets the values of the **LastWriteTime**, **CreationTime**, and **Root** properties of a folder.
-The property values are returned in the order in which you specified the property names.
+This command gets the values of the **LastWriteTime**, **CreationTime**, and **Root** properties of
+a folder. The property values are returned in the order in which you specified the property names.
```powershell
-Get-ItemPropertyValue -Path C:\Users\Test\Documents\ModuleToAssembly -Name LastWriteTime,CreationTime,Root
+Get-ItemPropertyValue -Path 'C:\Program Files\WindowsPowerShell' -Name LastWriteTime,CreationTime,Root
``` ```output
-Wednesday, September 3, 2014 2:53:22 PM
-Wednesday, September 3, 2014 2:53:10 PM
+Tuesday, March 23, 2021 6:53:13 AM
+Monday, August 14, 2017 1:42:40 PM
Name : C:\
+FullName : C:\
Parent : Exists : True Root : C:\
-FullName : C:\
Extension :
-CreationTime : 9/1/2014 4:59:45 AM
-CreationTimeUtc : 9/1/2014 11:59:45 AM
-LastAccessTime : 9/27/2014 5:22:02 PM
-LastAccessTimeUtc : 9/28/2014 12:22:02 AM
-LastWriteTime : 9/27/2014 5:22:02 PM
-LastWriteTimeUtc : 9/28/2014 12:22:02 AM
+CreationTime : 10/30/2015 1:28:30 AM
+CreationTimeUtc : 10/30/2015 6:28:30 AM
+LastAccessTime : 5/26/2021 9:24:31 AM
+LastAccessTimeUtc : 5/26/2021 2:24:31 PM
+LastWriteTime : 5/25/2021 7:25:08 AM
+LastWriteTimeUtc : 5/25/2021 12:25:08 PM
Attributes : Hidden, System, Directory
+Mode : d--hs-
BaseName : C:\
-Target :
+Target : {}
LinkType :
-Mode : d--hs-
``` ## PARAMETERS
Mode : d--hs-
Specifies a user account that has permission to perform this action. The default is the current user.
-Type a user name, such as "User01" or "Domain01\User01", or enter a **PSCredential** object, such as one generated by the `Get-Credential` cmdlet.
-If you type a user name, you are prompted for a password.
+Type a user name, such as "User01" or "Domain01\User01", or enter a **PSCredential** object, such as
+one generated by the `Get-Credential` cmdlet. If you type a user name, you are prompted for a
+password.
> [!WARNING] > This parameter is not supported by any providers installed with Windows PowerShell.
Accept wildcard characters: False
### -Exclude
-Specifies, as a string array, an item or items that this cmdlet excludes from the operation.
-The value of this parameter qualifies the **Path** parameter.
-Enter a path element or pattern, such as "*.txt".
-Wildcard characters are permitted.
+Specifies, as a string array, an item or items that this cmdlet excludes from the operation. The
+value of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as
+"*.txt". Wildcard characters are permitted.
```yaml Type: System.String[]
Accept wildcard characters: True
### -Filter
-Specifies a filter in the format or language of the provider.
-The value of this parameter qualifies the **Path** parameter.
+Specifies a filter in the format or language of the provider. The value of this parameter qualifies
+the **Path** parameter.
-The syntax of the filter, including the use of wildcard characters, depends on the provider.
-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.
+The syntax of the filter, including the use of wildcard characters, depends on the provider. 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
Accept wildcard characters: True
### -Include
-Specifies, as a string array, an item or items that this cmdlet includes in the operation.
-The value of this parameter qualifies the **Path** parameter.
-Enter a path element or pattern, such as "*.txt".
-Wildcard characters are permitted.
+Specifies, as a string array, an item or items that this cmdlet includes in the operation. The value
+of this parameter qualifies the **Path** parameter. Enter a path element or pattern, such as
+"*.txt". Wildcard characters are permitted.
```yaml Type: System.String[]
Accept wildcard characters: True
### -LiteralPath
-Specifies the path to the current location of the property.
-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 PowerShell not to interpret any characters as escape sequences.
+Specifies the path to the current location of the property. 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 PowerShell not to interpret any characters as escape sequences.
```yaml Type: System.String[]
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.
+Includes the command in the active transaction. This parameter is valid only when a transaction is
+in progress. For more information, see about_Transactions.
```yaml Type: System.Management.Automation.SwitchParameter
You can pipe a string that contains a path to this cmdlet.
### System.Boolean, System.String, System.DateTime
-This cmdlet returns an object for each item property value that it gets.
-The object type depends on the property value that is retrieved.
-For example, in a file system drive, the cmdlet might return a file or folder.
+This cmdlet returns an object for each item property value that it gets. The object type depends on
+the property value that is retrieved. For example, in a file system drive, the cmdlet might return a
+file or folder.
## NOTES
-This cmdlet is designed to work with the data exposed by any provider. To list the providers available in your session, run the `Get-PSProvider` cmdlet. For more information, see about_Providers.
+This cmdlet is designed to work with the data exposed by any provider. To list the providers
+available in your session, run the `Get-PSProvider` cmdlet. For more information, see
+about_Providers.
## RELATED LINKS
Microsoft.PowerShell.Management Get Psprovider (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Management/Get-PSProvider.md
--- external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
-keywords: powershell,cmdlet
Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 06/09/2017 Last updated : 05/26/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/get-psprovider?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Get-PSProvider ---- # Get-PSProvider ## SYNOPSIS
-Gets information about the specified Windows PowerShell provider.
+Gets information about the specified PowerShell provider.
## SYNTAX
Get-PSProvider [[-PSProvider] <String[]>] [<CommonParameters>]
``` ## DESCRIPTION
-The **Get-PSProvider** cmdlet gets the Windows PowerShell providers in the current session.
-You can get a particular drive or all drives in the session.
-Windows PowerShell providers let you access a variety of data stores as though they were file system drives.
-For information about Windows PowerShell providers, see about_Providers.
+The `Get-PSProvider` cmdlet gets the PowerShell providers in the current session. You can get a
+particular drive or all drives in the session.
+
+PowerShell providers let you access a variety of data stores as though they were file system drives.
+For information about PowerShell providers, see
+[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md).
## EXAMPLES ### Example 1: Display a list of all available providers
-```
-PS C:\> Get-PSProvider
+```powershell
+Get-PSProvider
```
-This command displays a list of all available Windows PowerShell providers.
+This command displays a list of all available PowerShell providers.
-### Example 2: Display a list of all Windows PowerShell providers that begin with specified letters
+### Example 2: Display a list of all PowerShell providers that begin with specified letters
-```
-PS C:\> Get-PSProvider f*, r* | Format-List
+```powershell
+Get-PSProvider f*, r* | Format-List
```
-This command displays a list of all Windows PowerShell providers with names that begin with the letter f or r.
+This command displays a list of all PowerShell providers with names that begin with the letter `f`
+or `r`.
### Example 3: Find snap-ins or module that added providers to your session
+```powershell
+Get-PSProvider | Format-Table Name, Module, PSSnapIn -AutoSize
+```
+
+```Output
+Name Module PSSnapIn
+---- ------ --------
+Registry Microsoft.PowerShell.Core
+Alias Microsoft.PowerShell.Core
+Environment Microsoft.PowerShell.Core
+FileSystem Microsoft.PowerShell.Core
+Function Microsoft.PowerShell.Core
+Variable Microsoft.PowerShell.Core
+Certificate Microsoft.PowerShell.Security
+WSMan Microsoft.WSMan.Management
+```
+
+```powershell
+Get-PSProvider | Where {$_.ModuleName -eq "Microsoft.PowerShell.Security"}
```
-PS C:\> Get-PSProvider | Format-Table name, module, pssnapin -auto
-
-Name Module PSSnapIn
-Test TestModule
-WSMan Microsoft.WSMan.Management
-Alias Microsoft.PowerShell.Core
-Environment Microsoft.PowerShell.Core
-FileSystem Microsoft.PowerShell.Core
-Function Microsoft.PowerShell.Core
-Registry Microsoft.PowerShell.Core
-Variable Microsoft.PowerShell.Core
-Certificate Microsoft.PowerShell.Security
-
-PS C:\> Get-PSProvider | Where {$_.pssnapin -eq "Microsoft.PowerShell.Security"}
+```Output
Name Capabilities Drives ---- ------------ ------ Certificate ShouldProcess {cert} ```
-These commands find the Windows PowerShell snap-ins or modules that added providers to your session.
-All Windows PowerShell elements, including providers, originate in a snap-in or in a module.
+These commands find the PowerShell snap-ins or modules that added providers to your session.
+All PowerShell elements, including providers, originate in a snap-in or in a module.
-These commands use the PSSnapin and Module properties of the **ProviderInfo** object that **Get-PSProvider** returns.
-The values of these properties contain the name of the snap-in or module that adds the provider.
+These commands use the PSSnapin and Module properties of the **ProviderInfo** object that
+`Get-PSProvider` returns. The values of these properties contain the name of the snap-in or module
+that adds the provider.
-The first command gets all of the providers in the session and formats them in a table with the values of their Name, Module, and PSSnapin properties.
+The first command gets all of the providers in the session and formats them in a table with the
+values of their Name, Module, and PSSnapin properties.
-The second command uses the Where-Object cmdlet to get the providers that come from the **Microsoft.PowerShell.Security** snap-in.
+The second command uses the `Where-Object` cmdlet to get the providers that come from the
+**Microsoft.PowerShell.Security** snap-in.
### Example 4: Resolve the path of the Home property of the file system provider
+```powershell
+C:\> Resolve-Path ~
```
-PS C:\> Resolve-Path ~
+```Output
Path ---- C:\Users\User01
+```
+```powershell
PS C:\> (get-psprovider FileSystem).home
+```
+
+```Output
C:\Users\User01 ```
-This example shows that the tilde symbol (~) represents the value of the Home property of the FileSystem provider.
-The Home property value is optional, but for the FileSystem provider, it is defined as $env:homedrive\$env:homepath or $home.
+This example shows that the tilde symbol (~) represents the value of the **Home** property of the
+FileSystem provider. The **Home** property value is optional, but for the **FileSystem** provider,
+it is defined as `$env:homedrive\$env:homepath` or `$home`.
## PARAMETERS ### -PSProvider
-Specifies the name or names of the Windows PowerShell providers about which this cmdlet gets information.
+
+Specifies the name or names of the PowerShell providers about which this cmdlet gets information.
```yaml Type: System.String[]
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](https://go.microsoft.com/fwlink/?LinkID=113216).
+
+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).
## INPUTS
You can pipe one or more provider name strings to this cmdlet.
## OUTPUTS ### System.Management.Automation.ProviderInfo
-This cmdlet returns objects that represent the Windows PowerShell providers in the session.
-## NOTES
+This cmdlet returns objects that represent the PowerShell providers in the session.
-## RELATED LINKS
+## NOTES
## RELATED LINKS
Microsoft.PowerShell.Core About Alias Provider (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Core/About/about_Alias_Provider.md
---
-description: Alias
-keywords: powershell,cmdlet
+description: Alias
Locale: en-US Last updated 10/18/2018
+no-loc: [Alias, Definition, AllScope, Option, None, Constant, Private]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_alias_provider?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Alias Provider
Title: about Alias Provider
# about_Alias_Provider ## Provider name+ Alias ## Drives
cmdlets.
## Types exposed by this provider Each alias is an instance of the
-[System.Management.Automation.AliasInfo](/dotnet/api/system.management.automation.aliasinfo) class.
+[System.Management.Automation.AliasInfo](/dotnet/api/system.management.automation.aliasinfo)
+class.
## Navigating the Alias drive
path.
> [!NOTE] > PowerShell uses aliases to allow you a familiar way to work with provider > paths. Commands such as `dir` and `ls` are now aliases for
-> [Get-ChildItem](xref:Microsoft.PowerShell.Management.Get-ChildItem),
-> `cd` is an alias for [Set-Location](xref:Microsoft.PowerShell.Management.Set-Location). and `pwd` is
-> an alias for [Get-Location](xref:Microsoft.PowerShell.Management.Get-Location).
+> [Get-ChildItem](xref:Microsoft.PowerShell.Management.Get-ChildItem), `cd` is
+> an alias for
+> [Set-Location](xref:Microsoft.PowerShell.Management.Set-Location). and `pwd`
+> is an alias for
+> [Get-Location](xref:Microsoft.PowerShell.Management.Get-Location).
### Displaying the Contents of the Alias: drive
$Alias:ls
### Get all aliases for a specific cmdlet This command gets a list of the aliases that are associated with the
-`Get-ChildItem` cmdlet. It uses the **Definition** property, which stores
-the cmdlet name.
+`Get-ChildItem` cmdlet. It uses the **Definition** property, which stores the
+cmdlet name.
```powershell Get-Item -Path Alias:* | Where-Object {$_.Definition -eq "Get-ChildItem"}
Get-Item -Path Alias:* | Where-Object {$_.Definition -eq "Get-ChildItem"}
### Create an alias from the Alias: drive This command creates the `serv` alias for the `Get-Service` cmdlet. Because the
-current location is in the `Alias:` drive, the `-Path` parameter is not
-needed.
+current location is in the `Alias:` drive, the `-Path` parameter is not needed.
This command also uses the `-Options` dynamic parameter to set the **AllScope**
-option on the alias. The `-Options` parameter is available in
-the `New-Item` cmdlet only when you are in the `Alias:` drive. The dot (`.`)
-indicates the current directory, which is the alias drive.
+option on the alias. The `-Options` parameter is available in the `New-Item`
+cmdlet only when you are in the `Alias:` drive. The dot (`.`) indicates the
+current directory, which is the alias drive.
``` PS Alias:\> New-Item -Path . -Name serv -Value Get-Service -Options "AllScope"
You can use this command in any PowerShell drive.
Remove-Item -Path Alias:serv ```
-This command deletes aliases that begin with "s".
-It does not delete read-only aliases.
+This command deletes aliases that begin with "s". It does not delete read-only
+aliases.
```powershell Clear-Item -Path Alias:s*
Clear-Item -Path Alias:s*
### Delete read-only aliases This command deletes all aliases from the current session, except those with a
-value of `Constant` for their **Options** property. The `-Force`
-parameter allows the command to delete aliases whose **Options** property has a
-value of `ReadOnly`.
+value of `Constant` for their **Options** property. The `-Force` parameter
+allows the command to delete aliases whose **Options** property has a value of
+`ReadOnly`.
```powershell Remove-Item Alias:* -Force
provider-enabled drive.
Determines the value of the **Options** property of an alias. - **None**: No options. This value is the default.-- **Constant**:The alias cannot be deleted and its properties cannot be changed.
- **Constant** is available only when you create an alias. You cannot change the
- option of an existing alias to **Constant**.
+- **Constant**:The alias cannot be deleted and its properties cannot be
+ changed. **Constant** is available only when you create an alias. You cannot
+ change the option of an existing alias to **Constant**.
- **Private**:The alias is visible only in the current scope, not in the child
- scopes.
-- **ReadOnly**:The properties of the alias cannot be changed except by using the
- `-Force` parameter. You can use `Remove-Item` to delete the alias.
+ scopes.
+- **ReadOnly**:The properties of the alias cannot be changed except by using
+ the `-Force` parameter. You can use `Remove-Item` to delete the alias.
- **AllScope**:The alias is copied to any new scopes that are created. #### Cmdlets supported
Beginning in Windows PowerShell 3.0, you can get customized help topics for
provider cmdlets that explain how those cmdlets behave in a file system drive. To get the help topics that are customized for the file system drive, run a
-[Get-Help](xref:Microsoft.PowerShell.Core.Get-Help) command in a file system drive or use the `-Path`
-parameter of [Get-Help](xref:Microsoft.PowerShell.Core.Get-Help) to specify a file system drive.
+[Get-Help](xref:Microsoft.PowerShell.Core.Get-Help) command in a file system
+drive or use the `-Path` parameter of
+[Get-Help](xref:Microsoft.PowerShell.Core.Get-Help) to specify a file system
+drive.
```powershell Get-Help Get-ChildItem
Microsoft.PowerShell.Core About Aliases (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Core/About/about_Aliases.md
--- description: Describes how to use alternate names for cmdlets and commands in PowerShell.
-keywords: powershell,cmdlet
Locale: en-US Last updated 11/27/2017
+no-loc: [Authenticode, Alias]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_aliases?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Aliases --- # about_Aliases
-## SHORT DESCRIPTION
-Describes how to use alternate names for cmdlets and commands in
-PowerShell.
+## Short description
+Describes how to use alternate names for cmdlets and commands in PowerShell.
-## LONG DESCRIPTION
+## Long description
An alias is an alternate name or nickname for a cmdlet or for a command element, such as a function, script, file, or executable file. You can use the alias instead of the command name in any PowerShell commands.
-To create an alias, use the New-Alias cmdlet. For example, the following
-command creates the "gas" alias for the `Get-AuthenticodeSignature` cmdlet:
+To create an alias, use the `New-Alias` cmdlet. For example, the following
+command creates the `gas` alias for the `Get-AuthenticodeSignature` cmdlet:
```powershell New-Alias -Name gas -Value Get-AuthenticodeSignature
New-Alias -Name gas -Value Get-AuthenticodeSignature
After you create the alias for the cmdlet name, you can use the alias instead of the cmdlet name. For example, to get the Authenticode signature for the
-SqlScript.ps1 file, type:
+`SqlScript.ps1` file, type:
```powershell Get-AuthenticodeSignature SqlScript.ps1
Or, type:
gas SqlScript.ps1 ```
-If you create "word" as the alias for Microsoft Office Word, you can type
+If you create `word` as the alias for Microsoft Office Word, you can type
"word" instead of the following: ```powershell "C:\Program Files\Microsoft Office\Office11\Winword.exe" ```
-## BUILT-IN ALIASES
+## Built in aliases
-PowerShell includes a set of built-in aliases, including "cd" and "chdir" for
-the Set-Location cmdlet, and "ls" and "dir" for the Get-ChildItem cmdlet.
+PowerShell includes a set of built-in aliases, including `cd` and `chdir` for
+the `Set-Location` cmdlet, and `ls` and `dir` for the `Get-ChildItem` cmdlet.
To get all the aliases on the computer, including the built-in aliases, type:
To get all the aliases on the computer, including the built-in aliases, type:
Get-Alias ```
-## ALIAS CMDLETS
+## Alias cmdlets
PowerShell includes the following cmdlets, which are designed for working with aliases:
For example, type:
Get-Help Export-Alias -Detailed ```
-## CREATING AN ALIAS
+## Creating an alias
-To create a new alias, use the New-Alias cmdlet. For example, to create the
-"gh" alias for Get-Help, type:
+To create a new alias, use the `New-Alias` cmdlet. For example, to create the
+`gh` alias for `Get-Help`, type:
```powershell New-Alias -Name gh -Value Get-Help
New-Alias -Name gh -Value Get-Help
You can use the alias in commands, just as you would use the full cmdlet name, and you can use the alias with parameters.
-For example, to get detailed Help for the Get-WmiObject cmdlet, type:
+For example, to get detailed Help for the `Get-CimInstance` cmdlet, type:
```powershell
-Get-Help Get-WmiObject -Detailed
+Get-Help Get-CimInstance -Detailed
``` Or, type: ```powershell
-gh Get-WmiObject -Detailed
+gh Get-CimInstance -Detailed
```
-## SAVING ALIASES
+## Saving aliases
The aliases that you create are saved only in the current session. To use the aliases in a different session, add the alias to your PowerShell profile. Or,
-use the Export-Alias cmdlet to save the aliases to a file.
+use the `Export-Alias` cmdlet to save the aliases to a file.
For more information, type:
For more information, type:
Get-Help about_Profiles ```
-## GETTING ALIASES
+## Getting aliases
To get all the aliases in the current session, including the built-in aliases, the aliases in your PowerShell profiles, and the aliases that you have created
in the current session, type:
Get-Alias ```
-To get particular aliases, use the Name parameter of the Get-Alias cmdlet. For
+To get particular aliases, use the Name parameter of the `Get-Alias` cmdlet. For
example, to get aliases that begin with "p", type: ```powershell
Get-Alias -Name p*
``` To get the aliases for a particular item, use the Definition parameter. For
-example, to get the aliases for the Get-ChildItem cmdlet type:
+example, to get the aliases for the `Get-ChildItem` cmdlet type:
```powershell Get-Alias -Definition Get-ChildItem ```
-### GET-ALIAS OUTPUT
+### Get-Alias output
-Get-Alias returns only one type of object, an AliasInfo object
-(System.Management.Automation.AliasInfo). The name of aliases that don't
-include a hyphen, such as "cd" are displayed in the following format:
+`Get-Alias` returns only one type of object, an **AliasInfo** object
+(**System.Management.Automation.AliasInfo**). The name of aliases that don't
+include a hyphen, such as `cd` are displayed in the following format:
```powershell Get-Alias ac
hyphen. These are likely to be preferred substitute names for cmdlets and
functions, instead of typical abbreviations or nicknames, and the author might not want them to be as evident.
-## ALTERNATE NAMES FOR COMMANDS WITH PARAMETERS
+## Alternate names for commands with parameters
You can assign an alias to a cmdlet, script, function, or executable file. You cannot assign an alias to a command and its parameters. For example, you can
For more information about functions, type:
Get-Help about_Functions ```
-## ALIAS OBJECTS
+## Alias objects
PowerShell aliases are represented by objects that are instances of the System.Management.Automation.AliasInfo class. For more information about this type of object, see [AliasInfo Class][aliasinfo] in the PowerShell SDK. To view the properties and methods of the alias objects, get the aliases.
-Then, pipe them to the Get-Member cmdlet. For example:
+Then, pipe them to the `Get-Member` cmdlet. For example:
```powershell Get-Alias | Get-Member ``` To view the values of the properties of a specific alias, such as the `dir`
-alias, get the alias. Then, pipe it to the Format-List cmdlet. For example,
-the following command gets the "dir" alias. Next, the command pipes the alias
-to the Format-List cmdlet. Then, the command uses the Property parameter of
-Format-List with a wildcard character (\*) to display all the properties of
+alias, get the alias. Then, pipe it to the `Format-List` cmdlet. For example,
+the following command gets the `dir` alias. Next, the command pipes the alias
+to the `Format-List` cmdlet. Then, the command uses the Property parameter of
+`Format-List` with a wildcard character (`*`) to display all the properties of
the `dir` alias. The following command performs these tasks: ```powershell Get-Alias -Name dir | Format-List -Property * ```
-## PowerShell ALIAS PROVIDER
+## PowerShell Alias provider
PowerShell includes the Alias provider. The Alias provider lets you view the aliases in PowerShell as though they were on a file system drive.
For more information about the PowerShell Alias provider, type:
Get-Help Alias ```
-## SEE ALSO
+## See also
- [New-Alias](xref:Microsoft.PowerShell.Utility.New-Alias) - [Get-Alias](xref:Microsoft.PowerShell.Utility.Get-Alias)
Microsoft.PowerShell.Core About Arithmetic Operators (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Core/About/about_Arithmetic_Operators.md
---
-description: Describes the operators that perform arithmetic in PowerShell.
-keywords: powershell,cmdlet
+description: Describes the operators that perform arithmetic in PowerShell.
Locale: en-US Last updated 10/08/2020 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_arithmetic_operators?view=powershell-7&WT.mc_id=ps-gethelp
Title: about Arithmetic Operators
--- # about_Arithmetic_Operators
-## SHORT DESCRIPTION
+## Short description
Describes the operators that perform arithmetic in PowerShell.
-## LONG DESCRIPTION
+## Long description
Arithmetic operators calculate numeric values. You can use one or more arithmetic operators to add, subtract, multiply, and divide values, and to
PowerShell supports the following arithmetic operators:
The bitwise operators only work on integer types.
-## OPERATOR PRECEDENCE
+## Operator precedence
PowerShell processes arithmetic operators in the following order:
$a = $a + 1
$b[$a] = $tmp ```
-## DIVISION AND ROUNDING
+## Division and rounding
When the quotient of a division operation is an integer, PowerShell rounds the value to the nearest integer. When the value is `.5`, it rounds to the
You can use the `[Math]` class to get different rounding behavior.
For more information, see the [Math.Round](/dotnet/api/system.math.round) method.
-## ADDING AND MULTIPLYING NON-NUMERIC TYPES
+## Adding and multiplying non numeric types
You can add numbers, strings, arrays, and hash tables. And, you can multiply numbers, strings, and arrays. However, you cannot multiply hash
B
C ```
-You can also perform arithmetic operations on objects of different types.
-The operation that PowerShell performs is determined by the Microsoft .NET
-Framework type of the leftmost object in the operation. PowerShell tries to
-convert all the objects in the operation to the .NET Framework type of the
-first object. If it succeeds in converting the objects, it performs the
-operation appropriate to the .NET Framework type of the first object. If it
-fails to convert any of the objects, the operation fails.
+You can also perform arithmetic operations on objects of different types. The
+operation that PowerShell performs is determined by the Microsoft .NET type of
+the leftmost object in the operation. PowerShell tries to convert all the
+objects in the operation to the .NET type of the first object. If it succeeds
+in converting the objects, it performs the operation appropriate to the .NET
+type of the first object. If it fails to convert any of the objects, the
+operation fails.
The following examples demonstrate the use of the addition and multiplication operators; in operations that include different object
$array
2 ```
-## TYPE CONVERSION TO ACCOMMODATE RESULT
+## Type conversion to accommodate result
-PowerShell automatically selects the .NET Framework numeric type that best
-expresses the result without losing precision. For example:
+PowerShell automatically selects the .NET numeric type that best expresses the
+result without losing precision. For example:
```powershell 2 + 3.1
System.Int32
System.Double ```
-If the result of an operation is too large for the type, the type of the
-result is widened to accommodate the result, as in the following example:
+If the result of an operation is too large for the type, the type of the result
+is widened to accommodate the result, as in the following example:
```powershell (512MB).GetType().FullName
System.Int32
System.Double ```
-The type of the result will not necessarily be the same as one of the
-operands. In the following example, the negative value cannot be cast to an
-unsigned integer, and the unsigned integer is too large to be cast to
-`Int32`:
+The type of the result will not necessarily be the same as one of the operands.
+In the following example, the negative value cannot be cast to an unsigned
+integer, and the unsigned integer is too large to be cast to `Int32`:
```powershell ([int32]::minvalue + [uint32]::maxvalue).gettype().fullname
System.Int64
In this example, `Int64` can accommodate both types.
-The `System.Decimal` type is an exception. If either operand has the
-Decimal type, the result will be of the Decimal type. If the result is too
-large for the Decimal type, it will not be cast to Double. Instead, an
-error results.
+The `System.Decimal` type is an exception. If either operand has the Decimal
+type, the result will be of the **Decimal** type. If the result is too large for
+the **Decimal** type, it will not be cast to **Double**. Instead, an error results.
|Expression |Result | |-------------------------|-----------------------------------------------|
error results.
|`[Decimal]::maxvalue + 1`|`Value was either too large or too small for a`| | |`Decimal.` |
-## ARITHMETIC OPERATORS AND VARIABLES
+## Arithmetic operators and variables
-You can also use arithmetic operators with variables. The operators act on
-the values of the variables. The following examples demonstrate the use of
+You can also use arithmetic operators with variables. The operators act on the
+values of the variables. The following examples demonstrate the use of
arithmetic operators with variables: | Expression |Result |
arithmetic operators with variables:
|`$intA = 6`<br/>`$intB = 4`<br/>`$intA + $intB`|`10` | |`$a = "Power"`<br/>`$b = "Shell"`<br/>`$a + $b`|`PowerShell`|
-## ARITHMETIC OPERATORS AND COMMANDS
+## Arithmetic operators and commands
Typically, you use the arithmetic operators in expressions with numbers,
-strings, and arrays. However, you can also use arithmetic operators with
-the objects that commands return and with the properties of those objects.
+strings, and arrays. However, you can also use arithmetic operators with the
+objects that commands return and with the properties of those objects.
-The following examples show how to use the arithmetic operators in
-expressions with PowerShell commands:
+The following examples show how to use the arithmetic operators in expressions
+with PowerShell commands:
```powershell (get-date) + (new-timespan -day 1) ```
-The parenthesis operator forces the evaluation of the `get-date` cmdlet and
-the evaluation of the `new-timespan -day 1` cmdlet expression, in that
-order. Both results are then added using the `+` operator.
+The parenthesis operator forces the evaluation of the `Get-Date` cmdlet and the
+evaluation of the `New-TimeSpan -Day 1` cmdlet expression, in that order. Both
+results are then added using the `+` operator.
```powershell Get-Process | Where-Object { ($_.ws * 2) -gt 50mb }
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
967 30 58804 59496 416 930.97 2508 WINWORD ```
-In the above expression, each process working space (`$_.ws`) is multiplied
-by `2`; and, the result, compared against `50mb` to see if it is greater
-than that.
+In the above expression, each process working space (`$_.ws`) is multiplied by
+`2`; and, the result, compared against `50mb` to see if it is greater than
+that.
-## Bitwise Operators
+## Bitwise operators
PowerShell supports the standard bitwise operators, including bitwise-AND (`-bAnd`), the inclusive and exclusive bitwise-OR operators (`-bOr` and `-bXor`), and bitwise-NOT (`-bNot`).
-Beginning in PowerShell 2.0, all bitwise operators work with 64-bit
-integers.
+Beginning in PowerShell 2.0, all bitwise operators work with 64-bit integers.
Beginning in PowerShell 3.0, the `-shr` (shift-right) and `-shl` (shift-left) are introduced to support bitwise arithmetic in PowerShell.
structure for the number 10 is 00001010 (based on 1 byte), and the bit
structure for the number 3 is 00000011. When you use a bitwise operator to compare 10 to 3, the individual bits in each byte are compared.
-In a bitwise AND operation, the resulting bit is set to 1 only when both
-input bits are 1.
+In a bitwise AND operation, the resulting bit is set to 1 only when both input
+bits are 1.
``` 1010 (10)
input bits are 1.
``` In a bitwise OR (inclusive) operation, the resulting bit is set to 1 when
-either or both input bits are 1. The resulting bit is set to 0 only when
-both input bits are set to 0.
+either or both input bits are 1. The resulting bit is set to 0 only when both
+input bits are set to 0.
``` 1010 (10)
right operand determine how many bits of the left operand are shifted.
|`[int]::MinValue -shr 1`| -1073741824| | 0xC0000000 | |`-1 -shr 1` | -1 | | 0xFFFFFFFF |
-## SEE ALSO
+## See also
- [about_arrays](about_Arrays.md) - [about_assignment_operators](about_Assignment_Operators.md)
Microsoft.PowerShell.Core About Arrays (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Core/About/about_Arrays.md
description: Describes arrays, which are data structures designed to store collections of items. Locale: en-US Last updated 08/26/2020
+no-loc: [Count, Length, LongLength, Rank, ForEach, Clear, Default, First, Last, SkipUntil, Until, Split, Tuple]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_arrays?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Arrays
and 4000), type:
As a result, the `$ia` array can contain only integers.
-You can create arrays that are cast to any supported type in the Microsoft
-.NET Framework. For example, the objects that `Get-Process` retrieves to
-represent processes are of the **System.Diagnostics.Process** type. To create a
-strongly typed array of process objects, enter the following command:
+You can create arrays that are cast to any supported type in the .NET. For
+example, the objects that `Get-Process` retrieves to represent processes are of
+the **System.Diagnostics.Process** type. To create a strongly typed array of
+process objects, enter the following command:
```powershell [Diagnostics.Process[]]$zz = Get-Process
$a[+0..2+4..6+8]
### Iterations over array elements
-You can also use looping constructs, such as ForEach, For, and While loops, to
-refer to the elements in an array. For example, to use a ForEach loop to
-display the elements in the `$a` array, type:
+You can also use looping constructs, such as `ForEach`, `For`, and `While`
+loops, to refer to the elements in an array. For example, to use a `ForEach`
+loop to display the elements in the `$a` array, type:
```powershell $a = 0..9
foreach ($element in $a) {
9 ```
-The Foreach loop iterates through the array and returns each value in the
+The `Foreach` loop iterates through the array and returns each value in the
array until reaching the end of the array.
-The For loop is useful when you are incrementing counters while examining the
-elements in an array. For example, to use a For loop to return every other
+The `For` loop is useful when you are incrementing counters while examining the
+elements in an array. For example, to use a `For` loop to return every other
value in an array, type: ```powershell
for ($i = 0; $i -le ($a.length - 1); $i += 2) {
8 ```
-You can use a While loop to display the elements in an array until a defined
+You can use a `While` loop to display the elements in an array until a defined
condition is no longer true. For example, to display the elements in the `$a` array while the array index is less than 4, type:
while($i -lt 4) {
### Count or Length or LongLength
-To determine how many items are in an array, use the `Length` property or its
-`Count` alias. `Longlength` is useful if the array contains more than
+To determine how many items are in an array, use the **Length** property or its
+**Count** alias. **Longlength** is useful if the array contains more than
2,147,483,647 elements. ```powershell
True
### Clear Sets all element values to the _default value_ of the array's element type.
-The Clear() method does not reset the size of the array.
+The `Clear()` method does not reset the size of the array.
In the following example `$a` is an array of objects.
$intA
Allows to iterate over all elements in the array and perform a given operation for each element of the array.
-The ForEach method has several overloads that perform different operations.
+The `ForEach` method has several overloads that perform different operations.
``` ForEach(scriptblock expression)
This method was added in PowerShell v4.
> the scriptblock is the only parameter. Also, there must not be a space > between the method and the opening parenthesis or brace.
-The following example shows how use the foreach method. In this case the
+The following example shows how use the `ForEach` method. In this case the
intent is to generate the square value of the elements in the array. ```powershell
TWO
THREE ```
-Just like the `-ArgumentList` parameter of `ForEach-Object`, the `arguments`
-parameter allows the passing of an array of arguments to a script block
-configured to accept them.
+Just like the `-ArgumentList` parameter of `ForEach-Object`, the `Arguments`
+parameter allows the passing of an array of values to a script block configured
+to accept them.
> [!NOTE] > Starting in Windows PowerShell 3.0 retrieving properties and executing > methods for each item in a collection can also be accomplished using "Methods
-> of scalar objects and collections" You can read more about that here
+> of scalar objects and collections". You can read more about that here
> [about_methods](about_methods.md). ### Where
Microsoft.PowerShell.Core About Assignment Operators (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Core/About/about_Assignment_Operators.md
$d
7 ```
-## Microsoft .NET Framework types
+## Microsoft .NET types
By default, when a variable has only one value, the value that is assigned to the variable determines the data type of the variable. For example, the
type:
$a = 6 ```
-To find the .NET Framework type of a variable, use the **GetType** method and
-its **FullName** property, as follows. Be sure to include the parentheses after
-the **GetType** method name, even though the method call has no arguments:
+To find the .NET type of a variable, use the **GetType** method and its
+**FullName** property, as follows. Be sure to include the parentheses after the
+**GetType** method name, even though the method call has no arguments:
```powershell $a = 6
$a
9 ```
-You can cast a new scalar variable as any .NET Framework type by placing the
-type name in brackets that precede either the variable name or the first
-assignment value. When you cast a variable, you can determine the types of data
-that can be stored in the variable. And, you can determine how the variable
-behaves when you manipulate it.
+You can cast a new scalar variable as any .NET type by placing the type name in
+brackets that precede either the variable name or the first assignment value.
+When you cast a variable, you can determine the types of data that can be
+stored in the variable. And, you can determine how the variable behaves when
+you manipulate it.
For example, the following command casts the variable as a string type:
example, the following command casts the variable as a `string []` array type:
[string []] $a = "one", "two", "three" ```
-PowerShell variables can be any .NET Framework data type. In addition, you can
-assign any fully qualified .NET Framework data type that is available in the
-current process. For example, the following command specifies a
-`System.DateTime` data type:
+PowerShell variables can be any .NET data type. In addition, you can assign any
+fully qualified .NET data type that is available in the current process. For
+example, the following command specifies a `System.DateTime` data type:
```powershell [System.DateTime]$a = "5/31/2005"
Microsoft.PowerShell.Core About Automatic Variables (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md
description: Describes variables that store state information for PowerShell. These variables are created and maintained by PowerShell. Locale: en-US Last updated 05/13/2021
+no-loc: [Reset, Current]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Automatic Variables
is particularly useful for finding the name of the current script.
Beginning in PowerShell 3.0, `MyInvocation` has the following new properties.
-| Property | Description |
-| ------------- | --------------------------------------------------- |
-| **PSScriptRoot** | Contains the full path to the script that invoked |
-| | the current command. The value of this property is |
-| | populated only when the caller is a script. |
-| **PSCommandPath** | Contains the full path and file name of the script |
-| | that invoked the current command. The value of this |
-| | property is populated only when the caller is a |
-| | script. |
+- **PSScriptRoot** - Contains the full path to the script that invoked the
+ current command. The value of this property is populated only when the caller
+ is a script.
+- **PSCommandPath** - Contains the full path and file name of the script that
+ invoked the current command. The value of this property is populated only
+ when the caller is a script.
Unlike the `$PSScriptRoot` and `$PSCommandPath` automatic variables, the **PSScriptRoot** and **PSCommandPath** properties of the `$MyInvocation`
-automatic variable contain information about the invoker or calling script,
-not the current script.
+automatic variable contain information about the invoker or calling script, not
+the current script.
### $NestedPromptLevel
Contains a read-only hash table that displays details about the version of
PowerShell that is running in the current session. The table includes the following items:
-| Property | Description |
-| ------------------------- | --------------------------------------------- |
-| **PSVersion** | The PowerShell version number |
-| **PSEdition** | This property has the value of 'Desktop' for |
-| | PowerShell 4 and below as well as PowerShell |
-| | 5.1 on full-featured Windows editions. |
-| | This property has the value of 'Core' for |
-| | PowerShell 6 and above as well as PowerShell |
-| | PowerShell 5.1 on reduced-footprint editions |
-| | like Windows Nano Server or Windows IoT. |
-| **GitCommitId** | The commit Id of the source files, in GitHub, |
-| **OS** | Description of the operating system that |
-| | PowerShell is running on. |
-| **Platform** | Platform that the operating system is running |
-| | on. The value on Linux and macOS is **Unix**. |
-| | See `$IsMacOs` and `$IsLinux`. |
-| **PSCompatibleVersions** | Versions of PowerShell that are compatible |
-| | with the current version |
-| **PSRemotingProtocolVersion** | The version of the PowerShell remote |
-| | management protocol. |
-| **SerializationVersion** | The version of the serialization method |
-| **WSManStackVersion** | The version number of the WS-Management stack |
+- **PSVersion** - The PowerShell version number
+- **PSEdition** This property has the value of 'Desktop' for PowerShell 4 and
+ below as well as PowerShell 5.1 on full-featured Windows editions. This
+ property has the value of `Core` for PowerShell 6 and above as well as
+ PowerShell PowerShell 5.1 on reduced-footprint editions like Windows Nano
+ Server or Windows IoT.
+- **GitCommitId** - The commit Id of the source files, in GitHub,
+- **OS** - Description of the operating system that PowerShell is running on.
+- **Platform** - Platform that the operating system is running on. The value on
+ Linux and macOS is **Unix**. See `$IsMacOs` and `$IsLinux`.
+- **PSCompatibleVersions** - Versions of PowerShell that are compatible with
+ the current version
+- **PSRemotingProtocolVersion** - The version of the PowerShell remote
+ management protocol.
+- **SerializationVersion** - The version of the serialization method
+- **WSManStackVersion** - The version number of the WS-Management stack
### $PWD
An enumerator contains properties and methods you can use to advance or reset
iteration, or retrieve iteration values. Directly manipulating enumerators isn't considered best practice. -- Within loops, flow control keywords [break](about_Break.md) and [continue](about_Continue.md)
- should be preferred.
+- Within loops, flow control keywords [break](about_Break.md) and
+ [continue](about_Continue.md) should be preferred.
- Within functions that accept pipeline input, it's best practice to use
- Parameters with the **ValueFromPipeline** or
+ parameters with the **ValueFromPipeline** or
**ValueFromPipelineByPropertyName** attributes.
- For more information, see [about_Functions_Advanced_Parameters](about_Functions_Advanced_Parameters.md).
+ For more information, see
+ [about_Functions_Advanced_Parameters](about_Functions_Advanced_Parameters.md).
### MoveNext The [MoveNext](/dotnet/api/system.collections.ienumerator.movenext) method advances the enumerator to the next element of the collection. **MoveNext**
-returns **True** if the enumerator was successfully advanced, **False** if
-the enumerator has passed the end of the collection.
+returns `True` if the enumerator was successfully advanced, `False` if the
+enumerator has passed the end of the collection.
> [!NOTE] > The **Boolean** value returned my **MoveNext** is sent to the output stream.
Num has not changed: two
``` Using the **Reset** method resets the current element in the collection. The
-following example loops through the first two elements **twice** because the
+following example loops through the first two elements _twice_ because the
**Reset** method is called. After the first two loops, the `if` statement fails and the loop iterates through all three elements normally.
Microsoft.PowerShell.Core About Break (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Core/About/about_Break.md
---
-description: Describes a statement you can use to immediately exit `foreach`, `for`, `while`, `do`, `switch`, or `trap` statements.
-keywords: powershell,cmdlet
+description: Describes a statement you can use to immediately exit `foreach`, `for`, `while`, `do`, `switch`, or `trap` statements.
Locale: en-US Last updated 06/04/2020 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_break?view=powershell-7&WT.mc_id=ps-gethelp
Execution continues at the next statement after the control block. The
statement supports labels. A label is a name you assign to a statement in a script.
-## Using break in loops
+## Using `break` in loops
When a `break` statement appears in a loop, such as a `foreach`, `for`, `do`, or `while` loop, PowerShell immediately exits the loop.
variable `$i` is incremented by 1. The third time the loop is run, `$i` equals
2, and the `$val` variable equals 30. At this point, the `break` statement runs, and the `foreach` loop exits.
-### Using a labeled break in a loop
+### Using a labeled `break` in a loop
A `break` statement can include a label. If you use the `break` keyword with a label, PowerShell exits the labeled loop instead of exiting the current loop.
loop. No label is needed.
PowerShell does not limit how far labels can resume execution. The label can even pass control across script and function call boundaries.
-## Using break in a switch statement
+## Using `break` in a `switch` statement
In a `switch`construct, `break` causes PowerShell to exit the `switch` code block.
exits. If the four `break` statements are removed from the example, all four
conditions are met. This example uses the `break` statement to display results when the most specific condition is met.
-## Using break in a trap statement
+## Using `break` in a `trap` statement
If the final statement executed in the body of a `trap` statement is `break`, the error object is suppressed and the exception is re-thrown.
Line |
| Attempted to divide by zero. ```
-## Do not use break outside of a loop, switch, or trap
+## Do not use `break` outside of a loop, `switch`, or `trap`
When `break` is used outside of a construct that directly supports it (loops, `switch`, `trap`), PowerShell looks _up the call stack_ for an
Microsoft.PowerShell.Core About Execution Policies (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Core/About/about_Execution_Policies.md
---
-description: Describes the PowerShell execution policies and explains how to manage them.
-keywords: powershell,cmdlet
+description: Describes the PowerShell execution policies and explains how to manage them.
Locale: en-US Last updated 08/10/2020
+no-loc: [Bypass, Default, Restricted, Undefined, Process, Scope]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Execution Policies
If no execution policy is set in any scope, the effective execution policy is
### Set a different policy for one session
-You can use the **ExecutionPolicy** parameter of **pwsh.exe** to set an
-execution policy for a new PowerShell session. The policy affects only the
-current session and child sessions.
+You can use the **ExecutionPolicy** parameter of `pwsh.exe` to set an execution
+policy for a new PowerShell session. The policy affects only the current
+session and child sessions.
To set the execution policy for a new session, start PowerShell at the command
-line, such as **cmd.exe** or from PowerShell, and then use the
-**ExecutionPolicy** parameter of **pwsh.exe** to set the execution policy.
+line, such as `cmd.exe` or from PowerShell, and then use the
+**ExecutionPolicy** parameter of `pwsh.exe` to set the execution policy.
For example:
Configuration nodes in Group Policy Editor in the following paths.
For Windows XP and Windows Server 2003:
-Administrative Templates\Windows Components\Windows PowerShell
+`Administrative Templates\Windows Components\Windows PowerShell`
For Windows Vista and later versions of Windows:
-Administrative Templates\Classic Administrative Templates\
-Windows Components\Windows PowerShell
+`Administrative Templates\Classic Administrative Templates\Windows Components\Windows PowerShell`
Policies set in the Computer Configuration node take precedence over policies set in the User Configuration node.
For more information, see [about_Group_Policy_Settings](about_Group_Policy_Setti
When determining the effective execution policy for a session, PowerShell evaluates the execution policies in the following precedence order: -- Group Policy: MachinePolicy-- Group Policy: UserPolicy-- Execution Policy: Process (or `pwsh.exe -ExecutionPolicy`)-- Execution Policy: CurrentUser-- Execution Policy: LocalMachine
+```
+Group Policy: MachinePolicy
+Group Policy: UserPolicy
+Execution Policy: Process (or pwsh.exe -ExecutionPolicy)
+Execution Policy: CurrentUser
+Execution Policy: LocalMachine
+```
## Manage signed and unsigned scripts
Beginning in PowerShell 3.0, you can use the **Stream** parameter of the
from the internet. Use the `Unblock-File` cmdlet to unblock the scripts so that you can run them in PowerShell.
-For more information, see [about_Signing](about_Signing.md), [Get-Item](xref:Microsoft.PowerShell.Management.Get-Item),
-and [Unblock-File](xref:Microsoft.PowerShell.Utility.Unblock-File).
+For more information, see [about_Signing](about_Signing.md),
+[Get-Item](xref:Microsoft.PowerShell.Management.Get-Item), and
+[Unblock-File](xref:Microsoft.PowerShell.Utility.Unblock-File).
> [!NOTE] > Other methods of downloading files may not mark the files as coming from the
Zone check which avoids the problem.
[Get-Item](xref:Microsoft.PowerShell.Management.Get-Item)
-[Pwsh Console Help](about_pwsh.md)
+[about_Pwsh](about_pwsh.md)
[Set-ExecutionPolicy](xref:Microsoft.PowerShell.Security.Set-ExecutionPolicy)
Microsoft.PowerShell.Management Get Itemproperty (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Management/Get-ItemProperty.md
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
keywords: powershell,cmdlet Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 5/14/2019 Last updated : 05/25/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/get-itemproperty?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Get-ItemProperty
Get-ItemProperty -LiteralPath <String[]> [[-Name] <String[]>] [-Filter <String>]
## DESCRIPTION
-The `Get-ItemProperty` cmdlet gets the properties of the specified items.
-For example, you can use this cmdlet to get the value of the LastAccessTime property of a file
-object. You can also use this cmdlet to view registry entries and their values.
+The `Get-ItemProperty` cmdlet gets the properties of the specified items. For example, you can use
+this cmdlet to get the value of the LastAccessTime property of a file object. You can also use this
+cmdlet to view registry entries and their values.
## EXAMPLES
Get-ItemProperty C:\Windows
### Example 2: Get the properties of a specific file
-This command gets the properties of the `C:\Test\Weather.xls` file.
-The result is piped to the `Format-List` cmdlet to display the output as a list.
+This command gets the properties of the `C:\Test\Weather.xls` file. The result is piped to the
+`Format-List` cmdlet to display the output as a list.
```powershell Get-ItemProperty C:\Test\Weather.xls | Format-List ```
-### Example 3: Display the value name and data of registry entries in a registry subkey
+### Example 3: Get the value name and data of a registry entry in a registry subkey
-This command displays the value name and data of each of the registry entries contained in the
-"CurrentVersion" registry subkey.
+This command gets the value name and data of the `ProgramFilesDir` registry entry in the
+`CurrentVersion` registry subkey. The **Path** specifies the subkey and the **Name** parameter
+specifies the value name of the entry.
```powershell
-Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion
+Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion -Name "ProgramFilesDir"
``` > [!NOTE] > This command requires that there is a PowerShell drive named `HKLM:` that is mapped to the
-> "HKEY_LOCAL_MACHINE" hive of the registry.
+> `HKEY_LOCAL_MACHINE` hive of the registry.
>
-> A drive with that name and mapping is available in PowerShell by default.
-> Alternatively, the path to this registry subkey can be specified by using the following alternative
-> path that begins with the provider name followed by two colons:
+> A drive with that name and mapping is available in PowerShell by default. Alternatively, the path
+> to this registry subkey can be specified by using the following alternative path that begins with
+> the provider name followed by two colons:
> > `Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion`.
-### Example 4: Get the value name and data of a registry entry in a registry subkey
-
-This command gets the value name and data of the "ProgramFilesDir" registry entry in the
-"CurrentVersion" registry subkey.
-The **Path** specifies the subkey and the **Name** parameter specifies the
-value name of the entry.
-
-```powershell
-Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion -Name "ProgramFilesDir"
-```
-
-### Example 5: Get the value names and data of registry entries in a registry key
+### Example 4: Get the value names and data of registry entries in a registry key
-This command gets the value names and data of the registry entries in the "PowerShellEngine"
+This command gets the value names and data of the registry entries in the `PowerShellEngine`
registry key. The results are shown in the following sample output. ```powershell
PSCompatibleVersion : 1.0,2.0
### -Credential > [!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](../Microsoft.PowerShell.Core/Invoke-Command.md).
+> 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](../Microsoft.PowerShell.Core/Invoke-Command.md).
```yaml Type: System.Management.Automation.PSCredential
Accept wildcard characters: False
### -Name
-Specifies the name of the property or properties to retrieve.
-Wildcard characters are permitted.
+Specifies the name of the property or properties to retrieve. Wildcard characters are permitted.
```yaml Type: System.String[]
Accept wildcard characters: True
### -Path
-Specifies the path to the item or items.
-Wildcard characters are permitted.
+Specifies the path to the item or items. Wildcard characters are permitted.
```yaml Type: System.String[]
Microsoft.PowerShell.Management Get Itempropertyvalue (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Management/Get-ItemPropertyValue.md
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
keywords: powershell,cmdlet Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 5/14/2019 Last updated : 05/14/2019 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/get-itempropertyvalue?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Get-ItemPropertyValue
Get-ItemPropertyValue -LiteralPath <String[]> [-Name] <String[]> [-Filter <Strin
## DESCRIPTION The `Get-ItemPropertyValue` gets the current value for a property that you specify when you use the
-*Name* parameter, located in a path that you specify with either the *Path* or *LiteralPath*
+**Name** parameter, located in a path that you specify with either the **Path** or **LiteralPath**
parameters. ## EXAMPLES
Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name
### Example 2: Get the last write time of a file or folder This command gets the value of the **LastWriteTime** property, or the last time a file or folder was
-changed, from the "C:\Users\Test\Documents\ModuleToAssembly" folder, working in the FileSystem
+changed, from the `C:\Program Files\PowerShell` folder, working in the FileSystem
provider. ```powershell
-Get-ItemPropertyValue -Path C:\Users\Test\Documents\ModuleToAssembly -Name LastWriteTime
+Get-ItemPropertyValue -Path 'C:\Program Files\PowerShell' -Name LastWriteTime
``` ```output
This command gets the values of the **LastWriteTime**, **CreationTime**, and **R
a folder. The property values are returned in the order in which you specified the property names. ```powershell
-Get-ItemPropertyValue -Path C:\Users\Test\Documents\ModuleToAssembly -Name LastWriteTime,CreationTime,Root
+Get-ItemPropertyValue -Path 'C:\Program Files\PowerShell' -Name LastWriteTime,CreationTime,Root
``` ```output
-Wednesday, September 3, 2014 2:53:22 PM
-Wednesday, September 3, 2014 2:53:10 PM
-
-Name : C:\
-Parent :
-Exists : True
-Root : C:\
-FullName : C:\
-Extension :
-CreationTime : 9/1/2014 4:59:45 AM
-CreationTimeUtc : 9/1/2014 11:59:45 AM
-LastAccessTime : 9/27/2014 5:22:02 PM
-LastAccessTimeUtc : 9/28/2014 12:22:02 AM
-LastWriteTime : 9/27/2014 5:22:02 PM
-LastWriteTimeUtc : 9/28/2014 12:22:02 AM
-Attributes : Hidden, System, Directory
-BaseName : C:\
-Target :
-LinkType :
-Mode : d--hs-
+Tuesday, March 23, 2021 6:53:13 AM
+Monday, August 14, 2017 1:42:40 PM
+
+Parent :
+Root : C:\
+FullName : C:\
+Extension :
+Name : C:\
+Exists : True
+CreationTime : 10/30/2015 1:28:30 AM
+CreationTimeUtc : 10/30/2015 6:28:30 AM
+LastAccessTime : 5/26/2021 9:25:18 AM
+LastAccessTimeUtc : 5/26/2021 2:25:18 PM
+LastWriteTime : 5/25/2021 7:25:08 AM
+LastWriteTimeUtc : 5/25/2021 12:25:08 PM
+Attributes : Hidden, System, Directory
+Mode : d--hs
+ModeWithoutHardLink : d--hs
+BaseName : C:\
+Target :
+LinkType :
``` ## PARAMETERS
Microsoft.PowerShell.Management Get Psprovider (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Management/Get-PSProvider.md
--- external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
-keywords: powershell,cmdlet
Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 06/09/2017 Last updated : 05/26/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/get-psprovider?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Get-PSProvider
Get-PSProvider [[-PSProvider] <String[]>] [<CommonParameters>]
## DESCRIPTION
-The `Get-PSProvider` cmdlet gets the PowerShell providers in the current session.
-You can get a particular drive or all drives in the session.
+The `Get-PSProvider` cmdlet gets the PowerShell providers in the current session. You can get a
+particular drive or all drives in the session.
PowerShell providers let you access a variety of data stores as though they were file system drives.
-For information about PowerShell providers, see [about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md).
+For information about PowerShell providers, see
+[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md).
## EXAMPLES
This command displays a list of all available PowerShell providers.
Get-PSProvider f*, r* | Format-List ```
-This command displays a list of all PowerShell providers with names that begin with the letter f or
-r.
+This command displays a list of all PowerShell providers with names that begin with the letter `f`
+or `r`.
### Example 3: Find snap-ins or module that added providers to your session ```powershell
-Get-PSProvider | Format-Table name, module, pssnapin -auto
+Get-PSProvider | Format-Table Name, Module, PSSnapIn -AutoSize
``` ```Output
-Name Module PSSnapIn
-Test TestModule
-WSMan Microsoft.WSMan.Management
-Alias Microsoft.PowerShell.Core
-Environment Microsoft.PowerShell.Core
-FileSystem Microsoft.PowerShell.Core
-Function Microsoft.PowerShell.Core
-Registry Microsoft.PowerShell.Core
-Variable Microsoft.PowerShell.Core
-Certificate Microsoft.PowerShell.Security
+Name Module PSSnapIn
+---- ------ --------
+Registry Microsoft.PowerShell.Core
+Alias Microsoft.PowerShell.Core
+Environment Microsoft.PowerShell.Core
+FileSystem Microsoft.PowerShell.Core
+Function Microsoft.PowerShell.Core
+Variable Microsoft.PowerShell.Core
+Certificate Microsoft.PowerShell.Security
+WSMan Microsoft.WSMan.Management
``` ```powershell
-Get-PSProvider | Where {$_.pssnapin -eq "Microsoft.PowerShell.Security"}
+Get-PSProvider | Where {$_.ModuleName -eq "Microsoft.PowerShell.Security"}
``` ```Output
These commands find the PowerShell snap-ins or modules that added providers to y
All PowerShell elements, including providers, originate in a snap-in or in a module. These commands use the PSSnapin and Module properties of the **ProviderInfo** object that
-`Get-PSProvider` returns.
-The values of these properties contain the name of the snap-in or module that adds the provider.
+`Get-PSProvider` returns. The values of these properties contain the name of the snap-in or module
+that adds the provider.
The first command gets all of the providers in the session and formats them in a table with the values of their Name, Module, and PSSnapin properties.
C:\Users\User01
``` This example shows that the tilde symbol (~) represents the value of the **Home** property of the
-FileSystem provider.
-The **Home** property value is optional, but for the **FileSystem** provider, it is defined as
-`$env:homedrive\$env:homepath` or `$home`.
+FileSystem provider. The **Home** property value is optional, but for the **FileSystem** provider,
+it is defined as `$env:homedrive\$env:homepath` or `$home`.
## PARAMETERS
Accept wildcard characters: False
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).
+-WarningAction, and -WarningVariable. For more information, see
+[about_CommonParameters](../Microsoft.PowerShell.Core/About/about_CommonParameters.md).
## INPUTS
Microsoft.PowerShell.Core About Alias Provider (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Core/About/about_Alias_Provider.md
---
-description: Alias
-keywords: powershell,cmdlet
+description: Alias
Locale: en-US Last updated 10/18/2018
+no-loc: [Alias, Definition, AllScope, Option, None, Constant, Private]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_alias_provider?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Alias Provider
Title: about Alias Provider
# about_Alias_Provider ## Provider name+ Alias ## Drives
cmdlets.
## Types exposed by this provider Each alias is an instance of the
-[System.Management.Automation.AliasInfo](/dotnet/api/system.management.automation.aliasinfo) class.
+[System.Management.Automation.AliasInfo](/dotnet/api/system.management.automation.aliasinfo)
+class.
## Navigating the Alias drive
path.
> [!NOTE] > PowerShell uses aliases to allow you a familiar way to work with provider > paths. Commands such as `dir` and `ls` are now aliases for
-> [Get-ChildItem](xref:Microsoft.PowerShell.Management.Get-ChildItem),
-> `cd` is an alias for [Set-Location](xref:Microsoft.PowerShell.Management.Set-Location). and `pwd` is
-> an alias for [Get-Location](xref:Microsoft.PowerShell.Management.Get-Location).
+> [Get-ChildItem](xref:Microsoft.PowerShell.Management.Get-ChildItem), `cd` is
+> an alias for
+> [Set-Location](xref:Microsoft.PowerShell.Management.Set-Location). and `pwd`
+> is an alias for
+> [Get-Location](xref:Microsoft.PowerShell.Management.Get-Location).
### Displaying the Contents of the Alias: drive
$Alias:ls
### Get all aliases for a specific cmdlet This command gets a list of the aliases that are associated with the
-`Get-ChildItem` cmdlet. It uses the **Definition** property, which stores
-the cmdlet name.
+`Get-ChildItem` cmdlet. It uses the **Definition** property, which stores the
+cmdlet name.
```powershell Get-Item -Path Alias:* | Where-Object {$_.Definition -eq "Get-ChildItem"}
Get-Item -Path Alias:* | Where-Object {$_.Definition -eq "Get-ChildItem"}
### Create an alias from the Alias: drive This command creates the `serv` alias for the `Get-Service` cmdlet. Because the
-current location is in the `Alias:` drive, the `-Path` parameter is not
-needed.
+current location is in the `Alias:` drive, the `-Path` parameter is not needed.
This command also uses the `-Options` dynamic parameter to set the **AllScope**
-option on the alias. The `-Options` parameter is available in
-the `New-Item` cmdlet only when you are in the `Alias:` drive. The dot (`.`)
-indicates the current directory, which is the alias drive.
+option on the alias. The `-Options` parameter is available in the `New-Item`
+cmdlet only when you are in the `Alias:` drive. The dot (`.`) indicates the
+current directory, which is the alias drive.
``` PS Alias:\> New-Item -Path . -Name serv -Value Get-Service -Options "AllScope"
You can use this command in any PowerShell drive.
Remove-Item -Path Alias:serv ```
-This command deletes aliases that begin with "s".
-It does not delete read-only aliases.
+This command deletes aliases that begin with "s". It does not delete read-only
+aliases.
```powershell Clear-Item -Path Alias:s*
Clear-Item -Path Alias:s*
### Delete read-only aliases This command deletes all aliases from the current session, except those with a
-value of `Constant` for their **Options** property. The `-Force`
-parameter allows the command to delete aliases whose **Options** property has a
-value of `ReadOnly`.
+value of `Constant` for their **Options** property. The `-Force` parameter
+allows the command to delete aliases whose **Options** property has a value of
+`ReadOnly`.
```powershell Remove-Item Alias:* -Force
provider-enabled drive.
Determines the value of the **Options** property of an alias. - **None**: No options. This value is the default.-- **Constant**:The alias cannot be deleted and its properties cannot be changed.
- **Constant** is available only when you create an alias. You cannot change the
- option of an existing alias to **Constant**.
+- **Constant**:The alias cannot be deleted and its properties cannot be
+ changed. **Constant** is available only when you create an alias. You cannot
+ change the option of an existing alias to **Constant**.
- **Private**:The alias is visible only in the current scope, not in the child
- scopes.
-- **ReadOnly**:The properties of the alias cannot be changed except by using the
- `-Force` parameter. You can use `Remove-Item` to delete the alias.
+ scopes.
+- **ReadOnly**:The properties of the alias cannot be changed except by using
+ the `-Force` parameter. You can use `Remove-Item` to delete the alias.
- **AllScope**:The alias is copied to any new scopes that are created. #### Cmdlets supported
Beginning in Windows PowerShell 3.0, you can get customized help topics for
provider cmdlets that explain how those cmdlets behave in a file system drive. To get the help topics that are customized for the file system drive, run a
-[Get-Help](xref:Microsoft.PowerShell.Core.Get-Help) command in a file system drive or use the `-Path`
-parameter of [Get-Help](xref:Microsoft.PowerShell.Core.Get-Help) to specify a file system drive.
+[Get-Help](xref:Microsoft.PowerShell.Core.Get-Help) command in a file system
+drive or use the `-Path` parameter of
+[Get-Help](xref:Microsoft.PowerShell.Core.Get-Help) to specify a file system
+drive.
```powershell Get-Help Get-ChildItem
Get-Help Get-ChildItem -Path alias:
[about_Aliases](../About/about_Aliases.md) [about_Providers](../About/about_Providers.md)-
Microsoft.PowerShell.Core About Aliases (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Core/About/about_Aliases.md
--- description: Describes how to use alternate names for cmdlets and commands in PowerShell.
-keywords: powershell,cmdlet
Locale: en-US Last updated 11/27/2017
+no-loc: [Authenticode, Alias]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_aliases?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Aliases --- # about_Aliases
-## SHORT DESCRIPTION
-Describes how to use alternate names for cmdlets and commands in
-PowerShell.
+## Short description
+Describes how to use alternate names for cmdlets and commands in PowerShell.
-## LONG DESCRIPTION
+## Long description
An alias is an alternate name or nickname for a cmdlet or for a command element, such as a function, script, file, or executable file. You can use the alias instead of the command name in any PowerShell commands.
-To create an alias, use the New-Alias cmdlet. For example, the following
-command creates the "gas" alias for the `Get-AuthenticodeSignature` cmdlet:
+To create an alias, use the `New-Alias` cmdlet. For example, the following
+command creates the `gas` alias for the `Get-AuthenticodeSignature` cmdlet:
```powershell New-Alias -Name gas -Value Get-AuthenticodeSignature
New-Alias -Name gas -Value Get-AuthenticodeSignature
After you create the alias for the cmdlet name, you can use the alias instead of the cmdlet name. For example, to get the Authenticode signature for the
-SqlScript.ps1 file, type:
+`SqlScript.ps1` file, type:
```powershell Get-AuthenticodeSignature SqlScript.ps1
Or, type:
gas SqlScript.ps1 ```
-If you create "word" as the alias for Microsoft Office Word, you can type
+If you create `word` as the alias for Microsoft Office Word, you can type
"word" instead of the following: ```powershell "C:\Program Files\Microsoft Office\Office11\Winword.exe" ```
-## BUILT-IN ALIASES
+## Built in aliases
-PowerShell includes a set of built-in aliases, including "cd" and "chdir" for
-the Set-Location cmdlet, and "ls" and "dir" for the Get-ChildItem cmdlet.
+PowerShell includes a set of built-in aliases, including `cd` and `chdir` for
+the `Set-Location` cmdlet, and `ls` and `dir` for the `Get-ChildItem` cmdlet.
To get all the aliases on the computer, including the built-in aliases, type:
To get all the aliases on the computer, including the built-in aliases, type:
Get-Alias ```
-## ALIAS CMDLETS
+## Alias cmdlets
PowerShell includes the following cmdlets, which are designed for working with aliases:
For example, type:
Get-Help Export-Alias -Detailed ```
-## CREATING AN ALIAS
+## Creating an alias
-To create a new alias, use the New-Alias cmdlet. For example, to create the
-"gh" alias for Get-Help, type:
+To create a new alias, use the `New-Alias` cmdlet. For example, to create the
+`gh` alias for `Get-Help`, type:
```powershell New-Alias -Name gh -Value Get-Help
New-Alias -Name gh -Value Get-Help
You can use the alias in commands, just as you would use the full cmdlet name, and you can use the alias with parameters.
-For example, to get detailed Help for the Get-WmiObject cmdlet, type:
+For example, to get detailed Help for the `Get-CimInstance` cmdlet, type:
```powershell
-Get-Help Get-WmiObject -Detailed
+Get-Help Get-CimInstance -Detailed
``` Or, type: ```powershell
-gh Get-WmiObject -Detailed
+gh Get-CimInstance -Detailed
```
-## SAVING ALIASES
+## Saving aliases
The aliases that you create are saved only in the current session. To use the aliases in a different session, add the alias to your PowerShell profile. Or,
-use the Export-Alias cmdlet to save the aliases to a file.
+use the `Export-Alias` cmdlet to save the aliases to a file.
For more information, type:
For more information, type:
Get-Help about_Profiles ```
-## GETTING ALIASES
+## Getting aliases
To get all the aliases in the current session, including the built-in aliases, the aliases in your PowerShell profiles, and the aliases that you have created
in the current session, type:
Get-Alias ```
-To get particular aliases, use the Name parameter of the Get-Alias cmdlet. For
+To get particular aliases, use the Name parameter of the `Get-Alias` cmdlet. For
example, to get aliases that begin with "p", type: ```powershell
Get-Alias -Name p*
``` To get the aliases for a particular item, use the Definition parameter. For
-example, to get the aliases for the Get-ChildItem cmdlet type:
+example, to get the aliases for the `Get-ChildItem` cmdlet type:
```powershell Get-Alias -Definition Get-ChildItem ```
-### GET-ALIAS OUTPUT
+### Get-Alias output
-Get-Alias returns only one type of object, an AliasInfo object
-(System.Management.Automation.AliasInfo). The name of aliases that don't
-include a hyphen, such as "cd" are displayed in the following format:
+`Get-Alias` returns only one type of object, an **AliasInfo** object
+(**System.Management.Automation.AliasInfo**). The name of aliases that don't
+include a hyphen, such as `cd` are displayed in the following format:
```powershell Get-Alias ac
hyphen. These are likely to be preferred substitute names for cmdlets and
functions, instead of typical abbreviations or nicknames, and the author might not want them to be as evident.
-## ALTERNATE NAMES FOR COMMANDS WITH PARAMETERS
+## Alternate names for commands with parameters
You can assign an alias to a cmdlet, script, function, or executable file. You cannot assign an alias to a command and its parameters. For example, you can
For more information about functions, type:
Get-Help about_Functions ```
-## ALIAS OBJECTS
+## Alias objects
PowerShell aliases are represented by objects that are instances of the System.Management.Automation.AliasInfo class. For more information about this type of object, see [AliasInfo Class][aliasinfo] in the PowerShell SDK. To view the properties and methods of the alias objects, get the aliases.
-Then, pipe them to the Get-Member cmdlet. For example:
+Then, pipe them to the `Get-Member` cmdlet. For example:
```powershell Get-Alias | Get-Member ``` To view the values of the properties of a specific alias, such as the `dir`
-alias, get the alias. Then, pipe it to the Format-List cmdlet. For example,
-the following command gets the "dir" alias. Next, the command pipes the alias
-to the Format-List cmdlet. Then, the command uses the Property parameter of
-Format-List with a wildcard character (\*) to display all the properties of
+alias, get the alias. Then, pipe it to the `Format-List` cmdlet. For example,
+the following command gets the `dir` alias. Next, the command pipes the alias
+to the `Format-List` cmdlet. Then, the command uses the Property parameter of
+`Format-List` with a wildcard character (`*`) to display all the properties of
the `dir` alias. The following command performs these tasks: ```powershell Get-Alias -Name dir | Format-List -Property * ```
-## PowerShell ALIAS PROVIDER
+## PowerShell Alias provider
PowerShell includes the Alias provider. The Alias provider lets you view the aliases in PowerShell as though they were on a file system drive.
For more information about the PowerShell Alias provider, type:
Get-Help Alias ```
-## SEE ALSO
+## See also
- [New-Alias](xref:Microsoft.PowerShell.Utility.New-Alias) - [Get-Alias](xref:Microsoft.PowerShell.Utility.Get-Alias)
Microsoft.PowerShell.Core About Arithmetic Operators (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Core/About/about_Arithmetic_Operators.md
---
-description: Describes the operators that perform arithmetic in PowerShell.
-keywords: powershell,cmdlet
+description: Describes the operators that perform arithmetic in PowerShell.
Locale: en-US Last updated 10/08/2020 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_arithmetic_operators?view=powershell-7.1&WT.mc_id=ps-gethelp
Title: about Arithmetic Operators
--- # about_Arithmetic_Operators
-## SHORT DESCRIPTION
+## Short description
Describes the operators that perform arithmetic in PowerShell.
-## LONG DESCRIPTION
+## Long description
Arithmetic operators calculate numeric values. You can use one or more arithmetic operators to add, subtract, multiply, and divide values, and to
PowerShell supports the following arithmetic operators:
The bitwise operators only work on integer types.
-## OPERATOR PRECEDENCE
+## Operator precedence
PowerShell processes arithmetic operators in the following order:
$a = $a + 1
$b[$a] = $tmp ```
-## DIVISION AND ROUNDING
+## Division and rounding
When the quotient of a division operation is an integer, PowerShell rounds the value to the nearest integer. When the value is `.5`, it rounds to the
You can use the `[Math]` class to get different rounding behavior.
For more information, see the [Math.Round](/dotnet/api/system.math.round) method.
-## ADDING AND MULTIPLYING NON-NUMERIC TYPES
+## Adding and multiplying non numeric types
You can add numbers, strings, arrays, and hash tables. And, you can multiply numbers, strings, and arrays. However, you cannot multiply hash
B
C ```
-You can also perform arithmetic operations on objects of different types.
-The operation that PowerShell performs is determined by the Microsoft .NET
-Framework type of the leftmost object in the operation. PowerShell tries to
-convert all the objects in the operation to the .NET Framework type of the
-first object. If it succeeds in converting the objects, it performs the
-operation appropriate to the .NET Framework type of the first object. If it
-fails to convert any of the objects, the operation fails.
+You can also perform arithmetic operations on objects of different types. The
+operation that PowerShell performs is determined by the Microsoft .NET type of
+the leftmost object in the operation. PowerShell tries to convert all the
+objects in the operation to the .NET type of the first object. If it succeeds
+in converting the objects, it performs the operation appropriate to the .NET
+type of the first object. If it fails to convert any of the objects, the
+operation fails.
The following examples demonstrate the use of the addition and multiplication operators; in operations that include different object
$array
2 ```
-## TYPE CONVERSION TO ACCOMMODATE RESULT
+## Type conversion to accommodate result
-PowerShell automatically selects the .NET Framework numeric type that best
-expresses the result without losing precision. For example:
+PowerShell automatically selects the .NET numeric type that best expresses the
+result without losing precision. For example:
```powershell 2 + 3.1
System.Int32
System.Double ```
-If the result of an operation is too large for the type, the type of the
-result is widened to accommodate the result, as in the following example:
+If the result of an operation is too large for the type, the type of the result
+is widened to accommodate the result, as in the following example:
```powershell (512MB).GetType().FullName
System.Int32
System.Double ```
-The type of the result will not necessarily be the same as one of the
-operands. In the following example, the negative value cannot be cast to an
-unsigned integer, and the unsigned integer is too large to be cast to
-`Int32`:
+The type of the result will not necessarily be the same as one of the operands.
+In the following example, the negative value cannot be cast to an unsigned
+integer, and the unsigned integer is too large to be cast to `Int32`:
```powershell ([int32]::minvalue + [uint32]::maxvalue).gettype().fullname
System.Int64
In this example, `Int64` can accommodate both types.
-The `System.Decimal` type is an exception. If either operand has the
-Decimal type, the result will be of the Decimal type. If the result is too
-large for the Decimal type, it will not be cast to Double. Instead, an
-error results.
+The `System.Decimal` type is an exception. If either operand has the **Decimal**
+type, the result will be of the Decimal type. If the result is too large for
+the **Decimal** type, it will not be cast to **Double**. Instead, an error results.
|Expression |Result | |-------------------------|-----------------------------------------------|
error results.
|`[Decimal]::maxvalue + 1`|`Value was either too large or too small for a`| | |`Decimal.` |
-## ARITHMETIC OPERATORS AND VARIABLES
+## Arithmetic operators and variables
-You can also use arithmetic operators with variables. The operators act on
-the values of the variables. The following examples demonstrate the use of
+You can also use arithmetic operators with variables. The operators act on the
+values of the variables. The following examples demonstrate the use of
arithmetic operators with variables: | Expression |Result |
arithmetic operators with variables:
|`$intA = 6`<br/>`$intB = 4`<br/>`$intA + $intB`|`10` | |`$a = "Power"`<br/>`$b = "Shell"`<br/>`$a + $b`|`PowerShell`|
-## ARITHMETIC OPERATORS AND COMMANDS
+## Arithmetic operators and commands
Typically, you use the arithmetic operators in expressions with numbers,
-strings, and arrays. However, you can also use arithmetic operators with
-the objects that commands return and with the properties of those objects.
+strings, and arrays. However, you can also use arithmetic operators with the
+objects that commands return and with the properties of those objects.
-The following examples show how to use the arithmetic operators in
-expressions with PowerShell commands:
+The following examples show how to use the arithmetic operators in expressions
+with PowerShell commands:
```powershell (get-date) + (new-timespan -day 1) ```
-The parenthesis operator forces the evaluation of the `get-date` cmdlet and
-the evaluation of the `new-timespan -day 1` cmdlet expression, in that
-order. Both results are then added using the `+` operator.
+The parenthesis operator forces the evaluation of the `Get-Date` cmdlet and the
+evaluation of the `New-TimeSpan -Day 1` cmdlet expression, in that order. Both
+results are then added using the `+` operator.
```powershell Get-Process | Where-Object { ($_.ws * 2) -gt 50mb }
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
967 30 58804 59496 416 930.97 2508 WINWORD ```
-In the above expression, each process working space (`$_.ws`) is multiplied
-by `2`; and, the result, compared against `50mb` to see if it is greater
-than that.
+In the above expression, each process working space (`$_.ws`) is multiplied by
+`2`; and, the result, compared against `50mb` to see if it is greater than
+that.
-## Bitwise Operators
+## Bitwise operators
PowerShell supports the standard bitwise operators, including bitwise-AND (`-bAnd`), the inclusive and exclusive bitwise-OR operators (`-bOr` and `-bXor`), and bitwise-NOT (`-bNot`).
-Beginning in PowerShell 2.0, all bitwise operators work with 64-bit
-integers.
+Beginning in PowerShell 2.0, all bitwise operators work with 64-bit integers.
Beginning in PowerShell 3.0, the `-shr` (shift-right) and `-shl` (shift-left) are introduced to support bitwise arithmetic in PowerShell.
structure for the number 10 is 00001010 (based on 1 byte), and the bit
structure for the number 3 is 00000011. When you use a bitwise operator to compare 10 to 3, the individual bits in each byte are compared.
-In a bitwise AND operation, the resulting bit is set to 1 only when both
-input bits are 1.
+In a bitwise AND operation, the resulting bit is set to 1 only when both input
+bits are 1.
``` 1010 (10)
input bits are 1.
``` In a bitwise OR (inclusive) operation, the resulting bit is set to 1 when
-either or both input bits are 1. The resulting bit is set to 0 only when
-both input bits are set to 0.
+either or both input bits are 1. The resulting bit is set to 0 only when both
+input bits are set to 0.
``` 1010 (10)
right operand determine how many bits of the left operand are shifted.
|`[int]::MinValue -shr 1`| -1073741824| | 0xC0000000 | |`-1 -shr 1` | -1 | | 0xFFFFFFFF |
-## SEE ALSO
+## See also
- [about_arrays](about_Arrays.md) - [about_assignment_operators](about_Assignment_Operators.md)
Microsoft.PowerShell.Core About Arrays (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Core/About/about_Arrays.md
description: Describes arrays, which are data structures designed to store collections of items. Locale: en-US Last updated 08/26/2020
+no-loc: [Count, Length, LongLength, Rank, ForEach, Clear, Default, First, Last, SkipUntil, Until, Split, Tuple]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_arrays?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Arrays
and 4000), type:
As a result, the `$ia` array can contain only integers.
-You can create arrays that are cast to any supported type in the Microsoft
-.NET Framework. For example, the objects that `Get-Process` retrieves to
-represent processes are of the **System.Diagnostics.Process** type. To create a
-strongly typed array of process objects, enter the following command:
+You can create arrays that are cast to any supported type in the .NET. For
+example, the objects that `Get-Process` retrieves to represent processes are of
+the **System.Diagnostics.Process** type. To create a strongly typed array of
+process objects, enter the following command:
```powershell [Diagnostics.Process[]]$zz = Get-Process
$a[+0..2+4..6+8]
### Iterations over array elements
-You can also use looping constructs, such as ForEach, For, and While loops, to
-refer to the elements in an array. For example, to use a ForEach loop to
-display the elements in the `$a` array, type:
+You can also use looping constructs, such as `ForEach`, `For`, and `While`
+loops, to refer to the elements in an array. For example, to use a `ForEach`
+loop to display the elements in the `$a` array, type:
```powershell $a = 0..9
foreach ($element in $a) {
9 ```
-The Foreach loop iterates through the array and returns each value in the
+The `Foreach` loop iterates through the array and returns each value in the
array until reaching the end of the array.
-The For loop is useful when you are incrementing counters while examining the
-elements in an array. For example, to use a For loop to return every other
+The `For` loop is useful when you are incrementing counters while examining the
+elements in an array. For example, to use a `For` loop to return every other
value in an array, type: ```powershell
for ($i = 0; $i -le ($a.length - 1); $i += 2) {
8 ```
-You can use a While loop to display the elements in an array until a defined
+You can use a `While` loop to display the elements in an array until a defined
condition is no longer true. For example, to display the elements in the `$a` array while the array index is less than 4, type:
while($i -lt 4) {
### Count or Length or LongLength
-To determine how many items are in an array, use the `Length` property or its
-`Count` alias. `Longlength` is useful if the array contains more than
+To determine how many items are in an array, use the **Length** property or its
+**Count** alias. **Longlength** is useful if the array contains more than
2,147,483,647 elements. ```powershell
True
### Clear Sets all element values to the _default value_ of the array's element type.
-The Clear() method does not reset the size of the array.
+The `Clear()` method does not reset the size of the array.
In the following example `$a` is an array of objects.
$intA
Allows to iterate over all elements in the array and perform a given operation for each element of the array.
-The ForEach method has several overloads that perform different operations.
+The `ForEach` method has several overloads that perform different operations.
``` ForEach(scriptblock expression)
This method was added in PowerShell v4.
> the scriptblock is the only parameter. Also, there must not be a space > between the method and the opening parenthesis or brace.
-The following example shows how use the foreach method. In this case the
+The following example shows how use the `ForEach` method. In this case the
intent is to generate the square value of the elements in the array. ```powershell
TWO
THREE ```
-Just like the `-ArgumentList` parameter of `ForEach-Object`, the `arguments`
-parameter allows the passing of an array of arguments to a script block
-configured to accept them.
+Just like the `-ArgumentList` parameter of `ForEach-Object`, the `Arguments`
+parameter allows the passing of an array of values to a script block configured
+to accept them.
> [!NOTE] > Starting in Windows PowerShell 3.0 retrieving properties and executing > methods for each item in a collection can also be accomplished using "Methods
-> of scalar objects and collections" You can read more about that here
+> of scalar objects and collections". You can read more about that here
> [about_methods](about_methods.md). ### Where
For more information, see [System.Tuple](/dotnet/api/system.tuple).
- [about_For](about_For.md) - [about_Foreach](about_Foreach.md) - [about_While](about_While.md)-
Microsoft.PowerShell.Core About Assignment Operators (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Core/About/about_Assignment_Operators.md
$d
7 ```
-## Microsoft .NET Framework types
+## Microsoft .NET types
By default, when a variable has only one value, the value that is assigned to the variable determines the data type of the variable. For example, the
type:
$a = 6 ```
-To find the .NET Framework type of a variable, use the **GetType** method and
-its **FullName** property, as follows. Be sure to include the parentheses after
-the **GetType** method name, even though the method call has no arguments:
+To find the .NET type of a variable, use the **GetType** method and its
+**FullName** property, as follows. Be sure to include the parentheses after the
+**GetType** method name, even though the method call has no arguments:
```powershell $a = 6
$a
9 ```
-You can cast a new scalar variable as any .NET Framework type by placing the
-type name in brackets that precede either the variable name or the first
-assignment value. When you cast a variable, you can determine the types of data
-that can be stored in the variable. And, you can determine how the variable
-behaves when you manipulate it.
+You can cast a new scalar variable as any .NET type by placing the type name in
+brackets that precede either the variable name or the first assignment value.
+When you cast a variable, you can determine the types of data that can be
+stored in the variable. And, you can determine how the variable behaves when
+you manipulate it.
For example, the following command casts the variable as a string type:
example, the following command casts the variable as a `string []` array type:
[string []] $a = "one", "two", "three" ```
-PowerShell variables can be any .NET Framework data type. In addition, you can
-assign any fully qualified .NET Framework data type that is available in the
-current process. For example, the following command specifies a
-`System.DateTime` data type:
+PowerShell variables can be any .NET data type. In addition, you can assign any
+fully qualified .NET data type that is available in the current process. For
+example, the following command specifies a `System.DateTime` data type:
```powershell [System.DateTime]$a = "5/31/2005"
Microsoft.PowerShell.Core About Automatic Variables (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md
description: Describes variables that store state information for PowerShell. These variables are created and maintained by PowerShell. Locale: en-US Last updated 05/13/2021
+no-loc: [Reset, Current]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Automatic Variables
is particularly useful for finding the name of the current script.
Beginning in PowerShell 3.0, `MyInvocation` has the following new properties.
-| Property | Description |
-| ------------- | --------------------------------------------------- |
-| **PSScriptRoot** | Contains the full path to the script that invoked |
-| | the current command. The value of this property is |
-| | populated only when the caller is a script. |
-| **PSCommandPath** | Contains the full path and file name of the script |
-| | that invoked the current command. The value of this |
-| | property is populated only when the caller is a |
-| | script. |
+- **PSScriptRoot** - Contains the full path to the script that invoked the
+ current command. The value of this property is populated only when the caller
+ is a script.
+- **PSCommandPath** - Contains the full path and file name of the script that
+ invoked the current command. The value of this property is populated only
+ when the caller is a script.
Unlike the `$PSScriptRoot` and `$PSCommandPath` automatic variables, the **PSScriptRoot** and **PSCommandPath** properties of the `$MyInvocation`
-automatic variable contain information about the invoker or calling script,
-not the current script.
+automatic variable contain information about the invoker or calling script, not
+the current script.
### $NestedPromptLevel
Contains a read-only hash table that displays details about the version of
PowerShell that is running in the current session. The table includes the following items:
-| Property | Description |
-| ------------------------- | --------------------------------------------- |
-| **PSVersion** | The PowerShell version number |
-| **PSEdition** | This property has the value of 'Desktop' for |
-| | PowerShell 4 and below as well as PowerShell |
-| | 5.1 on full-featured Windows editions. |
-| | This property has the value of 'Core' for |
-| | PowerShell 6 and above as well as PowerShell |
-| | PowerShell 5.1 on reduced-footprint editions |
-| | like Windows Nano Server or Windows IoT. |
-| **GitCommitId** | The commit Id of the source files, in GitHub, |
-| **OS** | Description of the operating system that |
-| | PowerShell is running on. |
-| **Platform** | Platform that the operating system is running |
-| | on. The value on Linux and macOS is **Unix**. |
-| | See `$IsMacOs` and `$IsLinux`. |
-| **PSCompatibleVersions** | Versions of PowerShell that are compatible |
-| | with the current version |
-| **PSRemotingProtocolVersion** | The version of the PowerShell remote |
-| | management protocol. |
-| **SerializationVersion** | The version of the serialization method |
-| **WSManStackVersion** | The version number of the WS-Management stack |
+- **PSVersion** - The PowerShell version number
+- **PSEdition** This property has the value of 'Desktop' for PowerShell 4 and
+ below as well as PowerShell 5.1 on full-featured Windows editions. This
+ property has the value of `Core` for PowerShell 6 and above as well as
+ PowerShell PowerShell 5.1 on reduced-footprint editions like Windows Nano
+ Server or Windows IoT.
+- **GitCommitId** - The commit Id of the source files, in GitHub,
+- **OS** - Description of the operating system that PowerShell is running on.
+- **Platform** - Platform that the operating system is running on. The value on
+ Linux and macOS is **Unix**. See `$IsMacOs` and `$IsLinux`.
+- **PSCompatibleVersions** - Versions of PowerShell that are compatible with
+ the current version
+- **PSRemotingProtocolVersion** - The version of the PowerShell remote
+ management protocol.
+- **SerializationVersion** - The version of the serialization method
+- **WSManStackVersion** - The version number of the WS-Management stack
### $PWD
An enumerator contains properties and methods you can use to advance or reset
iteration, or retrieve iteration values. Directly manipulating enumerators isn't considered best practice. -- Within loops, flow control keywords [break](about_Break.md) and [continue](about_Continue.md)
- should be preferred.
+- Within loops, flow control keywords [break](about_Break.md) and
+ [continue](about_Continue.md) should be preferred.
- Within functions that accept pipeline input, it's best practice to use
- Parameters with the **ValueFromPipeline** or
+ parameters with the **ValueFromPipeline** or
**ValueFromPipelineByPropertyName** attributes.
- For more information, see [about_Functions_Advanced_Parameters](about_Functions_Advanced_Parameters.md).
+ For more information, see
+ [about_Functions_Advanced_Parameters](about_Functions_Advanced_Parameters.md).
### MoveNext The [MoveNext](/dotnet/api/system.collections.ienumerator.movenext) method advances the enumerator to the next element of the collection. **MoveNext**
-returns **True** if the enumerator was successfully advanced, **False** if
-the enumerator has passed the end of the collection.
+returns `True` if the enumerator was successfully advanced, `False` if the
+enumerator has passed the end of the collection.
> [!NOTE] > The **Boolean** value returned my **MoveNext** is sent to the output stream.
Num has not changed: two
``` Using the **Reset** method resets the current element in the collection. The
-following example loops through the first two elements **twice** because the
+following example loops through the first two elements _twice_ because the
**Reset** method is called. After the first two loops, the `if` statement fails and the loop iterates through all three elements normally.
Default (Current): End
[about_Splatting](about_Splatting.md) [about_Variables](about_Variables.md)-
Microsoft.PowerShell.Core About Break (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Core/About/about_Break.md
---
-description: Describes a statement you can use to immediately exit `foreach`, `for`, `while`, `do`, `switch`, or `trap` statements.
-keywords: powershell,cmdlet
+description: Describes a statement you can use to immediately exit `foreach`, `for`, `while`, `do`, `switch`, or `trap` statements.
Locale: en-US Last updated 06/04/2020 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_break?view=powershell-7.1&WT.mc_id=ps-gethelp
Execution continues at the next statement after the control block. The
statement supports labels. A label is a name you assign to a statement in a script.
-## Using break in loops
+## Using `break` in loops
When a `break` statement appears in a loop, such as a `foreach`, `for`, `do`, or `while` loop, PowerShell immediately exits the loop.
variable `$i` is incremented by 1. The third time the loop is run, `$i` equals
2, and the `$val` variable equals 30. At this point, the `break` statement runs, and the `foreach` loop exits.
-### Using a labeled break in a loop
+### Using a labeled `break` in a loop
A `break` statement can include a label. If you use the `break` keyword with a label, PowerShell exits the labeled loop instead of exiting the current loop.
loop. No label is needed.
PowerShell does not limit how far labels can resume execution. The label can even pass control across script and function call boundaries.
-## Using break in a switch statement
+## Using `break` in a `switch` statement
In a `switch`construct, `break` causes PowerShell to exit the `switch` code block.
exits. If the four `break` statements are removed from the example, all four
conditions are met. This example uses the `break` statement to display results when the most specific condition is met.
-## Using break in a trap statement
+## Using `break` in a `trap` statement
If the final statement executed in the body of a `trap` statement is `break`, the error object is suppressed and the exception is re-thrown.
Line |
| Attempted to divide by zero. ```
-## Do not use break outside of a loop, switch, or trap
+## Do not use `break` outside of a loop, `switch`, or `trap`
When `break` is used outside of a construct that directly supports it (loops, `switch`, `trap`), PowerShell looks _up the call stack_ for an
Microsoft.PowerShell.Core About Execution Policies (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Core/About/about_Execution_Policies.md
---
-description: Describes the PowerShell execution policies and explains how to manage them.
-keywords: powershell,cmdlet
+description: Describes the PowerShell execution policies and explains how to manage them.
Locale: en-US Last updated 08/10/2020
+no-loc: [Bypass, Default, Restricted, Undefined, Process, Scope]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Execution Policies
If no execution policy is set in any scope, the effective execution policy is
### Set a different policy for one session
-You can use the **ExecutionPolicy** parameter of **pwsh.exe** to set an
-execution policy for a new PowerShell session. The policy affects only the
-current session and child sessions.
+You can use the **ExecutionPolicy** parameter of `pwsh.exe` to set an execution
+policy for a new PowerShell session. The policy affects only the current
+session and child sessions.
To set the execution policy for a new session, start PowerShell at the command
-line, such as **cmd.exe** or from PowerShell, and then use the
-**ExecutionPolicy** parameter of **pwsh.exe** to set the execution policy.
+line, such as `cmd.exe` or from PowerShell, and then use the
+**ExecutionPolicy** parameter of `pwsh.exe` to set the execution policy.
For example:
Configuration nodes in Group Policy Editor in the following paths.
For Windows XP and Windows Server 2003:
-Administrative Templates\Windows Components\Windows PowerShell
+`Administrative Templates\Windows Components\Windows PowerShell`
For Windows Vista and later versions of Windows:
-Administrative Templates\Classic Administrative Templates\
-Windows Components\Windows PowerShell
+`Administrative Templates\Classic Administrative Templates\Windows Components\Windows PowerShell`
Policies set in the Computer Configuration node take precedence over policies set in the User Configuration node.
For more information, see [about_Group_Policy_Settings](about_Group_Policy_Setti
When determining the effective execution policy for a session, PowerShell evaluates the execution policies in the following precedence order: -- Group Policy: MachinePolicy-- Group Policy: UserPolicy-- Execution Policy: Process (or `pwsh.exe -ExecutionPolicy`)-- Execution Policy: CurrentUser-- Execution Policy: LocalMachine
+```
+Group Policy: MachinePolicy
+Group Policy: UserPolicy
+Execution Policy: Process (or pwsh.exe -ExecutionPolicy)
+Execution Policy: CurrentUser
+Execution Policy: LocalMachine
+```
## Manage signed and unsigned scripts
Beginning in PowerShell 3.0, you can use the **Stream** parameter of the
from the internet. Use the `Unblock-File` cmdlet to unblock the scripts so that you can run them in PowerShell.
-For more information, see [about_Signing](about_Signing.md), [Get-Item](xref:Microsoft.PowerShell.Management.Get-Item),
-and [Unblock-File](xref:Microsoft.PowerShell.Utility.Unblock-File).
+For more information, see [about_Signing](about_Signing.md),
+[Get-Item](xref:Microsoft.PowerShell.Management.Get-Item), and
+[Unblock-File](xref:Microsoft.PowerShell.Utility.Unblock-File).
> [!NOTE] > Other methods of downloading files may not mark the files as coming from the
Zone check which avoids the problem.
[Get-Item](xref:Microsoft.PowerShell.Management.Get-Item)
-[Pwsh Console Help](about_pwsh.md)
+[about_Pwsh](about_pwsh.md)
[Set-ExecutionPolicy](xref:Microsoft.PowerShell.Security.Set-ExecutionPolicy) [Unblock-File](xref:Microsoft.PowerShell.Utility.Unblock-File)-
Microsoft.PowerShell.Management Get Itemproperty (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Management/Get-ItemProperty.md
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
keywords: powershell,cmdlet Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 5/14/2019 Last updated : 05/25/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/get-itemproperty?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Get-ItemProperty
Get-ItemProperty -LiteralPath <String[]> [[-Name] <String[]>] [-Filter <String>]
## DESCRIPTION
-The `Get-ItemProperty` cmdlet gets the properties of the specified items.
-For example, you can use this cmdlet to get the value of the LastAccessTime property of a file
-object. You can also use this cmdlet to view registry entries and their values.
+The `Get-ItemProperty` cmdlet gets the properties of the specified items. For example, you can use
+this cmdlet to get the value of the LastAccessTime property of a file object. You can also use this
+cmdlet to view registry entries and their values.
## EXAMPLES
Get-ItemProperty C:\Windows
### Example 2: Get the properties of a specific file
-This command gets the properties of the `C:\Test\Weather.xls` file.
-The result is piped to the `Format-List` cmdlet to display the output as a list.
+This command gets the properties of the `C:\Test\Weather.xls` file. The result is piped to the
+`Format-List` cmdlet to display the output as a list.
```powershell Get-ItemProperty C:\Test\Weather.xls | Format-List ```
-### Example 3: Display the value name and data of registry entries in a registry subkey
+### Example 3: Get the value name and data of a registry entry in a registry subkey
-This command displays the value name and data of each of the registry entries contained in the
-"CurrentVersion" registry subkey.
+This command gets the value name and data of the `ProgramFilesDir` registry entry in the
+`CurrentVersion` registry subkey. The **Path** specifies the subkey and the **Name** parameter
+specifies the value name of the entry.
```powershell
-Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion
+Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion -Name "ProgramFilesDir"
``` > [!NOTE] > This command requires that there is a PowerShell drive named `HKLM:` that is mapped to the
-> "HKEY_LOCAL_MACHINE" hive of the registry.
+> `HKEY_LOCAL_MACHINE` hive of the registry.
>
-> A drive with that name and mapping is available in PowerShell by default.
-> Alternatively, the path to this registry subkey can be specified by using the following alternative
-> path that begins with the provider name followed by two colons:
+> A drive with that name and mapping is available in PowerShell by default. Alternatively, the path
+> to this registry subkey can be specified by using the following alternative path that begins with
+> the provider name followed by two colons:
> > `Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion`.
-### Example 4: Get the value name and data of a registry entry in a registry subkey
-
-This command gets the value name and data of the "ProgramFilesDir" registry entry in the
-"CurrentVersion" registry subkey.
-The **Path** specifies the subkey and the **Name** parameter specifies the
-value name of the entry.
-
-```powershell
-Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion -Name "ProgramFilesDir"
-```
-
-### Example 5: Get the value names and data of registry entries in a registry key
+### Example 4: Get the value names and data of registry entries in a registry key
-This command gets the value names and data of the registry entries in the "PowerShellEngine"
+This command gets the value names and data of the registry entries in the `PowerShellEngine`
registry key. The results are shown in the following sample output. ```powershell
PSCompatibleVersion : 1.0,2.0
### -Credential > [!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](../Microsoft.PowerShell.Core/Invoke-Command.md).
+> 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](../Microsoft.PowerShell.Core/Invoke-Command.md).
```yaml Type: System.Management.Automation.PSCredential
Accept wildcard characters: False
### -Name
-Specifies the name of the property or properties to retrieve.
-Wildcard characters are permitted.
+Specifies the name of the property or properties to retrieve. Wildcard characters are permitted.
```yaml Type: System.String[]
Accept wildcard characters: True
### -Path
-Specifies the path to the item or items.
-Wildcard characters are permitted.
+Specifies the path to the item or items. Wildcard characters are permitted.
```yaml Type: System.String[]
providers available in your session, type `Get-PSProvider`. For more information
[Set-ItemProperty](Set-ItemProperty.md) [about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md)-
Microsoft.PowerShell.Management Get Itempropertyvalue (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Management/Get-ItemPropertyValue.md
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
keywords: powershell,cmdlet Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 5/14/2019 Last updated : 05/14/2019 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/get-itempropertyvalue?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Get-ItemPropertyValue
Get-ItemPropertyValue -LiteralPath <String[]> [-Name] <String[]> [-Filter <Strin
## DESCRIPTION The `Get-ItemPropertyValue` gets the current value for a property that you specify when you use the
-*Name* parameter, located in a path that you specify with either the *Path* or *LiteralPath*
+**Name** parameter, located in a path that you specify with either the **Path** or **LiteralPath**
parameters. ## EXAMPLES
Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name
### Example 2: Get the last write time of a file or folder This command gets the value of the **LastWriteTime** property, or the last time a file or folder was
-changed, from the "C:\Users\Test\Documents\ModuleToAssembly" folder, working in the FileSystem
+changed, from the `C:\Program Files\PowerShell` folder, working in the FileSystem
provider. ```powershell
-Get-ItemPropertyValue -Path C:\Users\Test\Documents\ModuleToAssembly -Name LastWriteTime
+Get-ItemPropertyValue -Path 'C:\Program Files\PowerShell' -Name LastWriteTime
``` ```output
This command gets the values of the **LastWriteTime**, **CreationTime**, and **R
a folder. The property values are returned in the order in which you specified the property names. ```powershell
-Get-ItemPropertyValue -Path C:\Users\Test\Documents\ModuleToAssembly -Name LastWriteTime,CreationTime,Root
+Get-ItemPropertyValue -Path 'C:\Program Files\PowerShell' -Name LastWriteTime,CreationTime,Root
``` ```output
-Wednesday, September 3, 2014 2:53:22 PM
-Wednesday, September 3, 2014 2:53:10 PM
-
-Name : C:\
-Parent :
-Exists : True
-Root : C:\
-FullName : C:\
-Extension :
-CreationTime : 9/1/2014 4:59:45 AM
-CreationTimeUtc : 9/1/2014 11:59:45 AM
-LastAccessTime : 9/27/2014 5:22:02 PM
-LastAccessTimeUtc : 9/28/2014 12:22:02 AM
-LastWriteTime : 9/27/2014 5:22:02 PM
-LastWriteTimeUtc : 9/28/2014 12:22:02 AM
-Attributes : Hidden, System, Directory
-BaseName : C:\
-Target :
-LinkType :
-Mode : d--hs-
+Tuesday, March 23, 2021 6:53:13 AM
+Monday, August 14, 2017 1:42:40 PM
+
+Parent :
+Root : C:\
+FullName : C:\
+Extension :
+Name : C:\
+Exists : True
+CreationTime : 10/30/2015 1:28:30 AM
+CreationTimeUtc : 10/30/2015 6:28:30 AM
+LastAccessTime : 5/26/2021 9:24:04 AM
+LastAccessTimeUtc : 5/26/2021 2:24:04 PM
+LastWriteTime : 5/25/2021 7:25:08 AM
+LastWriteTimeUtc : 5/25/2021 12:25:08 PM
+Attributes : Hidden, System, Directory
+Mode : d--hs
+ModeWithoutHardLink : d--hs
+BaseName : C:\
+Target :
+LinkType :
``` ## PARAMETERS
Microsoft.PowerShell.Management Get Psprovider (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Management/Get-PSProvider.md
--- external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
-keywords: powershell,cmdlet
Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 06/09/2017 Last updated : 05/26/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/get-psprovider?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Get-PSProvider
Get-PSProvider [[-PSProvider] <String[]>] [<CommonParameters>]
## DESCRIPTION
-The `Get-PSProvider` cmdlet gets the PowerShell providers in the current session.
-You can get a particular drive or all drives in the session.
+The `Get-PSProvider` cmdlet gets the PowerShell providers in the current session. You can get a
+particular drive or all drives in the session.
PowerShell providers let you access a variety of data stores as though they were file system drives.
-For information about PowerShell providers, see [about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md).
+For information about PowerShell providers, see
+[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md).
## EXAMPLES
This command displays a list of all available PowerShell providers.
Get-PSProvider f*, r* | Format-List ```
-This command displays a list of all PowerShell providers with names that begin with the letter f or
-r.
+This command displays a list of all PowerShell providers with names that begin with the letter `f`
+or `r`.
### Example 3: Find snap-ins or module that added providers to your session ```powershell
-Get-PSProvider | Format-Table name, module, pssnapin -auto
+Get-PSProvider | Format-Table Name, Module, PSSnapIn -AutoSize
``` ```Output
-Name Module PSSnapIn
-Test TestModule
-WSMan Microsoft.WSMan.Management
-Alias Microsoft.PowerShell.Core
-Environment Microsoft.PowerShell.Core
-FileSystem Microsoft.PowerShell.Core
-Function Microsoft.PowerShell.Core
-Registry Microsoft.PowerShell.Core
-Variable Microsoft.PowerShell.Core
-Certificate Microsoft.PowerShell.Security
+Name Module PSSnapIn
+---- ------ --------
+Registry Microsoft.PowerShell.Core
+Alias Microsoft.PowerShell.Core
+Environment Microsoft.PowerShell.Core
+FileSystem Microsoft.PowerShell.Core
+Function Microsoft.PowerShell.Core
+Variable Microsoft.PowerShell.Core
+Certificate Microsoft.PowerShell.Security
+WSMan Microsoft.WSMan.Management
``` ```powershell
-Get-PSProvider | Where {$_.pssnapin -eq "Microsoft.PowerShell.Security"}
+Get-PSProvider | Where {$_.ModuleName -eq "Microsoft.PowerShell.Security"}
``` ```Output
These commands find the PowerShell snap-ins or modules that added providers to y
All PowerShell elements, including providers, originate in a snap-in or in a module. These commands use the PSSnapin and Module properties of the **ProviderInfo** object that
-`Get-PSProvider` returns.
-The values of these properties contain the name of the snap-in or module that adds the provider.
+`Get-PSProvider` returns. The values of these properties contain the name of the snap-in or module
+that adds the provider.
The first command gets all of the providers in the session and formats them in a table with the values of their Name, Module, and PSSnapin properties.
C:\Users\User01
``` This example shows that the tilde symbol (~) represents the value of the **Home** property of the
-FileSystem provider.
-The **Home** property value is optional, but for the **FileSystem** provider, it is defined as
-`$env:homedrive\$env:homepath` or `$home`.
+FileSystem provider. The **Home** property value is optional, but for the **FileSystem** provider,
+it is defined as `$env:homedrive\$env:homepath` or `$home`.
## PARAMETERS
Accept wildcard characters: False
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).
+-WarningAction, and -WarningVariable. For more information, see
+[about_CommonParameters](../Microsoft.PowerShell.Core/About/about_CommonParameters.md).
## INPUTS
This cmdlet returns objects that represent the PowerShell providers in the sessi
## NOTES ## RELATED LINKS-
Microsoft.PowerShell.Core About Alias Provider (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Core/About/about_Alias_Provider.md
description: Alias Locale: en-US Last updated 10/18/2018
+no-loc: [Alias, Definition, AllScope, Option, None, Constant, Private]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_alias_provider?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Alias Provider
Title: about Alias Provider
# about_Alias_Provider ## Provider name+ Alias ## Drives
cmdlets.
## Types exposed by this provider Each alias is an instance of the
-[System.Management.Automation.AliasInfo](/dotnet/api/system.management.automation.aliasinfo) class.
+[System.Management.Automation.AliasInfo](/dotnet/api/system.management.automation.aliasinfo)
+class.
## Navigating the Alias drive
path.
> [!NOTE] > PowerShell uses aliases to allow you a familiar way to work with provider > paths. Commands such as `dir` and `ls` are now aliases for
-> [Get-ChildItem](xref:Microsoft.PowerShell.Management.Get-ChildItem),
-> `cd` is an alias for [Set-Location](xref:Microsoft.PowerShell.Management.Set-Location). and `pwd` is
-> an alias for [Get-Location](xref:Microsoft.PowerShell.Management.Get-Location).
+> [Get-ChildItem](xref:Microsoft.PowerShell.Management.Get-ChildItem), `cd` is
+> an alias for
+> [Set-Location](xref:Microsoft.PowerShell.Management.Set-Location). and `pwd`
+> is an alias for
+> [Get-Location](xref:Microsoft.PowerShell.Management.Get-Location).
### Displaying the Contents of the Alias: drive
$Alias:ls
### Get all aliases for a specific cmdlet This command gets a list of the aliases that are associated with the
-`Get-ChildItem` cmdlet. It uses the **Definition** property, which stores
-the cmdlet name.
+`Get-ChildItem` cmdlet. It uses the **Definition** property, which stores the
+cmdlet name.
```powershell Get-Item -Path Alias:* | Where-Object {$_.Definition -eq "Get-ChildItem"}
Get-Item -Path Alias:* | Where-Object {$_.Definition -eq "Get-ChildItem"}
### Create an alias from the Alias: drive This command creates the `serv` alias for the `Get-Service` cmdlet. Because the
-current location is in the `Alias:` drive, the `-Path` parameter is not
-needed.
+current location is in the `Alias:` drive, the `-Path` parameter is not needed.
This command also uses the `-Options` dynamic parameter to set the **AllScope**
-option on the alias. The `-Options` parameter is available in
-the `New-Item` cmdlet only when you are in the `Alias:` drive. The dot (`.`)
-indicates the current directory, which is the alias drive.
+option on the alias. The `-Options` parameter is available in the `New-Item`
+cmdlet only when you are in the `Alias:` drive. The dot (`.`) indicates the
+current directory, which is the alias drive.
``` PS Alias:\> New-Item -Path . -Name serv -Value Get-Service -Options "AllScope"
You can use this command in any PowerShell drive.
Remove-Item -Path Alias:serv ```
-This command deletes aliases that begin with "s".
-It does not delete read-only aliases.
+This command deletes aliases that begin with "s". It does not delete read-only
+aliases.
```powershell Clear-Item -Path Alias:s*
Clear-Item -Path Alias:s*
### Delete read-only aliases This command deletes all aliases from the current session, except those with a
-value of `Constant` for their **Options** property. The `-Force`
-parameter allows the command to delete aliases whose **Options** property has a
-value of `ReadOnly`.
+value of `Constant` for their **Options** property. The `-Force` parameter
+allows the command to delete aliases whose **Options** property has a value of
+`ReadOnly`.
```powershell Remove-Item Alias:* -Force
provider-enabled drive.
Determines the value of the **Options** property of an alias. - **None**: No options. This value is the default.-- **Constant**:The alias cannot be deleted and its properties cannot be changed.
- **Constant** is available only when you create an alias. You cannot change the
- option of an existing alias to **Constant**.
+- **Constant**:The alias cannot be deleted and its properties cannot be
+ changed. **Constant** is available only when you create an alias. You cannot
+ change the option of an existing alias to **Constant**.
- **Private**:The alias is visible only in the current scope, not in the child
- scopes.
-- **ReadOnly**:The properties of the alias cannot be changed except by using the
- `-Force` parameter. You can use `Remove-Item` to delete the alias.
+ scopes.
+- **ReadOnly**:The properties of the alias cannot be changed except by using
+ the `-Force` parameter. You can use `Remove-Item` to delete the alias.
- **AllScope**:The alias is copied to any new scopes that are created. #### Cmdlets supported
Beginning in Windows PowerShell 3.0, you can get customized help topics for
provider cmdlets that explain how those cmdlets behave in a file system drive. To get the help topics that are customized for the file system drive, run a
-[Get-Help](xref:Microsoft.PowerShell.Core.Get-Help) command in a file system drive or use the `-Path`
-parameter of [Get-Help](xref:Microsoft.PowerShell.Core.Get-Help) to specify a file system drive.
+[Get-Help](xref:Microsoft.PowerShell.Core.Get-Help) command in a file system
+drive or use the `-Path` parameter of
+[Get-Help](xref:Microsoft.PowerShell.Core.Get-Help) to specify a file system
+drive.
```powershell Get-Help Get-ChildItem
Get-Help Get-ChildItem -Path alias:
[about_Aliases](../About/about_Aliases.md) [about_Providers](../About/about_Providers.md)-
Microsoft.PowerShell.Core About Aliases (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Core/About/about_Aliases.md
description: Describes how to use alternate names for cmdlets and commands in PowerShell. Locale: en-US Last updated 11/27/2017
+no-loc: [Authenticode, Alias]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_aliases?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Aliases --- # about_Aliases
-## SHORT DESCRIPTION
-Describes how to use alternate names for cmdlets and commands in
-PowerShell.
+## Short description
+Describes how to use alternate names for cmdlets and commands in PowerShell.
-## LONG DESCRIPTION
+## Long description
An alias is an alternate name or nickname for a cmdlet or for a command element, such as a function, script, file, or executable file. You can use the alias instead of the command name in any PowerShell commands.
-To create an alias, use the New-Alias cmdlet. For example, the following
-command creates the "gas" alias for the `Get-AuthenticodeSignature` cmdlet:
+To create an alias, use the `New-Alias` cmdlet. For example, the following
+command creates the `gas` alias for the `Get-AuthenticodeSignature` cmdlet:
```powershell New-Alias -Name gas -Value Get-AuthenticodeSignature
New-Alias -Name gas -Value Get-AuthenticodeSignature
After you create the alias for the cmdlet name, you can use the alias instead of the cmdlet name. For example, to get the Authenticode signature for the
-SqlScript.ps1 file, type:
+`SqlScript.ps1` file, type:
```powershell Get-AuthenticodeSignature SqlScript.ps1
Or, type:
gas SqlScript.ps1 ```
-If you create "word" as the alias for Microsoft Office Word, you can type
+If you create `word` as the alias for Microsoft Office Word, you can type
"word" instead of the following: ```powershell "C:\Program Files\Microsoft Office\Office11\Winword.exe" ```
-## BUILT-IN ALIASES
+## Built in aliases
-PowerShell includes a set of built-in aliases, including "cd" and "chdir" for
-the Set-Location cmdlet, and "ls" and "dir" for the Get-ChildItem cmdlet.
+PowerShell includes a set of built-in aliases, including `cd` and `chdir` for
+the `Set-Location` cmdlet, and `ls` and `dir` for the `Get-ChildItem` cmdlet.
To get all the aliases on the computer, including the built-in aliases, type:
To get all the aliases on the computer, including the built-in aliases, type:
Get-Alias ```
-## ALIAS CMDLETS
+## Alias cmdlets
PowerShell includes the following cmdlets, which are designed for working with aliases:
For example, type:
Get-Help Export-Alias -Detailed ```
-## CREATING AN ALIAS
+## Creating an alias
-To create a new alias, use the New-Alias cmdlet. For example, to create the
-"gh" alias for Get-Help, type:
+To create a new alias, use the `New-Alias` cmdlet. For example, to create the
+`gh` alias for `Get-Help`, type:
```powershell New-Alias -Name gh -Value Get-Help
New-Alias -Name gh -Value Get-Help
You can use the alias in commands, just as you would use the full cmdlet name, and you can use the alias with parameters.
-For example, to get detailed Help for the Get-WmiObject cmdlet, type:
+For example, to get detailed Help for the `Get-CimInstance` cmdlet, type:
```powershell
-Get-Help Get-WmiObject -Detailed
+Get-Help Get-CimInstance -Detailed
``` Or, type: ```powershell
-gh Get-WmiObject -Detailed
+gh Get-CimInstance -Detailed
```
-## SAVING ALIASES
+## Saving aliases
The aliases that you create are saved only in the current session. To use the aliases in a different session, add the alias to your PowerShell profile. Or,
-use the Export-Alias cmdlet to save the aliases to a file.
+use the `Export-Alias` cmdlet to save the aliases to a file.
For more information, type:
For more information, type:
Get-Help about_Profiles ```
-## GETTING ALIASES
+## Getting aliases
To get all the aliases in the current session, including the built-in aliases, the aliases in your PowerShell profiles, and the aliases that you have created
in the current session, type:
Get-Alias ```
-To get particular aliases, use the Name parameter of the Get-Alias cmdlet. For
+To get particular aliases, use the Name parameter of the `Get-Alias` cmdlet. For
example, to get aliases that begin with "p", type: ```powershell
Get-Alias -Name p*
``` To get the aliases for a particular item, use the Definition parameter. For
-example, to get the aliases for the Get-ChildItem cmdlet type:
+example, to get the aliases for the `Get-ChildItem` cmdlet type:
```powershell Get-Alias -Definition Get-ChildItem ```
-### GET-ALIAS OUTPUT
+### Get-Alias output
-Get-Alias returns only one type of object, an AliasInfo object
-(System.Management.Automation.AliasInfo). The name of aliases that don't
-include a hyphen, such as "cd" are displayed in the following format:
+`Get-Alias` returns only one type of object, an **AliasInfo** object
+(**System.Management.Automation.AliasInfo**). The name of aliases that don't
+include a hyphen, such as `cd` are displayed in the following format:
```powershell Get-Alias ac
hyphen. These are likely to be preferred substitute names for cmdlets and
functions, instead of typical abbreviations or nicknames, and the author might not want them to be as evident.
-## ALTERNATE NAMES FOR COMMANDS WITH PARAMETERS
+## Alternate names for commands with parameters
You can assign an alias to a cmdlet, script, function, or executable file. You cannot assign an alias to a command and its parameters. For example, you can
For more information about functions, type:
Get-Help about_Functions ```
-## ALIAS OBJECTS
+## Alias objects
PowerShell aliases are represented by objects that are instances of the System.Management.Automation.AliasInfo class. For more information about this type of object, see [AliasInfo Class][aliasinfo] in the PowerShell SDK. To view the properties and methods of the alias objects, get the aliases.
-Then, pipe them to the Get-Member cmdlet. For example:
+Then, pipe them to the `Get-Member` cmdlet. For example:
```powershell Get-Alias | Get-Member ``` To view the values of the properties of a specific alias, such as the `dir`
-alias, get the alias. Then, pipe it to the Format-List cmdlet. For example,
-the following command gets the "dir" alias. Next, the command pipes the alias
-to the Format-List cmdlet. Then, the command uses the Property parameter of
-Format-List with a wildcard character (\*) to display all the properties of
+alias, get the alias. Then, pipe it to the `Format-List` cmdlet. For example,
+the following command gets the `dir` alias. Next, the command pipes the alias
+to the `Format-List` cmdlet. Then, the command uses the Property parameter of
+`Format-List` with a wildcard character (`*`) to display all the properties of
the `dir` alias. The following command performs these tasks: ```powershell Get-Alias -Name dir | Format-List -Property * ```
-## PowerShell ALIAS PROVIDER
+## PowerShell Alias provider
PowerShell includes the Alias provider. The Alias provider lets you view the aliases in PowerShell as though they were on a file system drive.
For more information about the PowerShell Alias provider, type:
Get-Help Alias ```
-## SEE ALSO
+## See also
- [New-Alias](xref:Microsoft.PowerShell.Utility.New-Alias) - [Get-Alias](xref:Microsoft.PowerShell.Utility.Get-Alias)
Microsoft.PowerShell.Core About Arithmetic Operators (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Core/About/about_Arithmetic_Operators.md
Title: about Arithmetic Operators
--- # about_Arithmetic_Operators
-## SHORT DESCRIPTION
+## Short description
Describes the operators that perform arithmetic in PowerShell.
-## LONG DESCRIPTION
+## Long description
Arithmetic operators calculate numeric values. You can use one or more arithmetic operators to add, subtract, multiply, and divide values, and to
PowerShell supports the following arithmetic operators:
The bitwise operators only work on integer types.
-## OPERATOR PRECEDENCE
+## Operator precedence
PowerShell processes arithmetic operators in the following order:
$a = $a + 1
$b[$a] = $tmp ```
-## DIVISION AND ROUNDING
+## Division and rounding
When the quotient of a division operation is an integer, PowerShell rounds the value to the nearest integer. When the value is `.5`, it rounds to the
You can use the `[Math]` class to get different rounding behavior.
For more information, see the [Math.Round](/dotnet/api/system.math.round) method.
-## ADDING AND MULTIPLYING NON-NUMERIC TYPES
+## Adding and multiplying non numeric types
You can add numbers, strings, arrays, and hash tables. And, you can multiply numbers, strings, and arrays. However, you cannot multiply hash
B
C ```
-You can also perform arithmetic operations on objects of different types.
-The operation that PowerShell performs is determined by the Microsoft .NET
-Framework type of the leftmost object in the operation. PowerShell tries to
-convert all the objects in the operation to the .NET Framework type of the
-first object. If it succeeds in converting the objects, it performs the
-operation appropriate to the .NET Framework type of the first object. If it
-fails to convert any of the objects, the operation fails.
+You can also perform arithmetic operations on objects of different types. The
+operation that PowerShell performs is determined by the Microsoft .NET type of
+the leftmost object in the operation. PowerShell tries to convert all the
+objects in the operation to the .NET type of the first object. If it succeeds
+in converting the objects, it performs the operation appropriate to the .NET
+type of the first object. If it fails to convert any of the objects, the
+operation fails.
The following examples demonstrate the use of the addition and multiplication operators; in operations that include different object
$array
2 ```
-## TYPE CONVERSION TO ACCOMMODATE RESULT
+## Type conversion to accommodate result
-PowerShell automatically selects the .NET Framework numeric type that best
-expresses the result without losing precision. For example:
+PowerShell automatically selects the .NET numeric type that best expresses the
+result without losing precision. For example:
```powershell 2 + 3.1
System.Int32
System.Double ```
-If the result of an operation is too large for the type, the type of the
-result is widened to accommodate the result, as in the following example:
+If the result of an operation is too large for the type, the type of the result
+is widened to accommodate the result, as in the following example:
```powershell (512MB).GetType().FullName
System.Int32
System.Double ```
-The type of the result will not necessarily be the same as one of the
-operands. In the following example, the negative value cannot be cast to an
-unsigned integer, and the unsigned integer is too large to be cast to
-`Int32`:
+The type of the result will not necessarily be the same as one of the operands.
+In the following example, the negative value cannot be cast to an unsigned
+integer, and the unsigned integer is too large to be cast to `Int32`:
```powershell ([int32]::minvalue + [uint32]::maxvalue).gettype().fullname
System.Int64
In this example, `Int64` can accommodate both types.
-The `System.Decimal` type is an exception. If either operand has the
-Decimal type, the result will be of the Decimal type. If the result is too
-large for the Decimal type, it will not be cast to Double. Instead, an
-error results.
+The `System.Decimal` type is an exception. If either operand has the **Decimal**
+type, the result will be of the Decimal type. If the result is too large for
+the **Decimal** type, it will not be cast to **Double**. Instead, an error results.
|Expression |Result | |-------------------------|-----------------------------------------------|
error results.
|`[Decimal]::maxvalue + 1`|`Value was either too large or too small for a`| | |`Decimal.` |
-## ARITHMETIC OPERATORS AND VARIABLES
+## Arithmetic operators and variables
-You can also use arithmetic operators with variables. The operators act on
-the values of the variables. The following examples demonstrate the use of
+You can also use arithmetic operators with variables. The operators act on the
+values of the variables. The following examples demonstrate the use of
arithmetic operators with variables: | Expression |Result |
arithmetic operators with variables:
|`$intA = 6`<br/>`$intB = 4`<br/>`$intA + $intB`|`10` | |`$a = "Power"`<br/>`$b = "Shell"`<br/>`$a + $b`|`PowerShell`|
-## ARITHMETIC OPERATORS AND COMMANDS
+## Arithmetic operators and commands
Typically, you use the arithmetic operators in expressions with numbers,
-strings, and arrays. However, you can also use arithmetic operators with
-the objects that commands return and with the properties of those objects.
+strings, and arrays. However, you can also use arithmetic operators with the
+objects that commands return and with the properties of those objects.
-The following examples show how to use the arithmetic operators in
-expressions with PowerShell commands:
+The following examples show how to use the arithmetic operators in expressions
+with PowerShell commands:
```powershell (get-date) + (new-timespan -day 1) ```
-The parenthesis operator forces the evaluation of the `get-date` cmdlet and
-the evaluation of the `new-timespan -day 1` cmdlet expression, in that
-order. Both results are then added using the `+` operator.
+The parenthesis operator forces the evaluation of the `Get-Date` cmdlet and the
+evaluation of the `New-TimeSpan -Day 1` cmdlet expression, in that order. Both
+results are then added using the `+` operator.
```powershell Get-Process | Where-Object { ($_.ws * 2) -gt 50mb }
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
967 30 58804 59496 416 930.97 2508 WINWORD ```
-In the above expression, each process working space (`$_.ws`) is multiplied
-by `2`; and, the result, compared against `50mb` to see if it is greater
-than that.
+In the above expression, each process working space (`$_.ws`) is multiplied by
+`2`; and, the result, compared against `50mb` to see if it is greater than
+that.
-## Bitwise Operators
+## Bitwise operators
PowerShell supports the standard bitwise operators, including bitwise-AND (`-bAnd`), the inclusive and exclusive bitwise-OR operators (`-bOr` and `-bXor`), and bitwise-NOT (`-bNot`).
-Beginning in PowerShell 2.0, all bitwise operators work with 64-bit
-integers.
+Beginning in PowerShell 2.0, all bitwise operators work with 64-bit integers.
Beginning in PowerShell 3.0, the `-shr` (shift-right) and `-shl` (shift-left) are introduced to support bitwise arithmetic in PowerShell.
structure for the number 10 is 00001010 (based on 1 byte), and the bit
structure for the number 3 is 00000011. When you use a bitwise operator to compare 10 to 3, the individual bits in each byte are compared.
-In a bitwise AND operation, the resulting bit is set to 1 only when both
-input bits are 1.
+In a bitwise AND operation, the resulting bit is set to 1 only when both input
+bits are 1.
``` 1010 (10)
input bits are 1.
``` In a bitwise OR (inclusive) operation, the resulting bit is set to 1 when
-either or both input bits are 1. The resulting bit is set to 0 only when
-both input bits are set to 0.
+either or both input bits are 1. The resulting bit is set to 0 only when both
+input bits are set to 0.
``` 1010 (10)
right operand determine how many bits of the left operand are shifted.
|`[int]::MinValue -shr 1`| -1073741824| | 0xC0000000 | |`-1 -shr 1` | -1 | | 0xFFFFFFFF |
-## SEE ALSO
+## See also
- [about_arrays](about_Arrays.md) - [about_assignment_operators](about_Assignment_Operators.md)
Microsoft.PowerShell.Core About Arrays (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Core/About/about_Arrays.md
description: Describes arrays, which are data structures designed to store collections of items. Locale: en-US Last updated 08/26/2020
+no-loc: [Count, Length, LongLength, Rank, ForEach, Clear, Default, First, Last, SkipUntil, Until, Split, Tuple]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_arrays?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Arrays
and 4000), type:
As a result, the `$ia` array can contain only integers.
-You can create arrays that are cast to any supported type in the Microsoft
-.NET Framework. For example, the objects that `Get-Process` retrieves to
-represent processes are of the **System.Diagnostics.Process** type. To create a
-strongly typed array of process objects, enter the following command:
+You can create arrays that are cast to any supported type in the .NET. For
+example, the objects that `Get-Process` retrieves to represent processes are of
+the **System.Diagnostics.Process** type. To create a strongly typed array of
+process objects, enter the following command:
```powershell [Diagnostics.Process[]]$zz = Get-Process
$a[+0..2+4..6+8]
### Iterations over array elements
-You can also use looping constructs, such as ForEach, For, and While loops, to
-refer to the elements in an array. For example, to use a ForEach loop to
-display the elements in the `$a` array, type:
+You can also use looping constructs, such as `ForEach`, `For`, and `While`
+loops, to refer to the elements in an array. For example, to use a `ForEach`
+loop to display the elements in the `$a` array, type:
```powershell $a = 0..9
foreach ($element in $a) {
9 ```
-The Foreach loop iterates through the array and returns each value in the
+The `Foreach` loop iterates through the array and returns each value in the
array until reaching the end of the array.
-The For loop is useful when you are incrementing counters while examining the
-elements in an array. For example, to use a For loop to return every other
+The `For` loop is useful when you are incrementing counters while examining the
+elements in an array. For example, to use a `For` loop to return every other
value in an array, type: ```powershell
for ($i = 0; $i -le ($a.length - 1); $i += 2) {
8 ```
-You can use a While loop to display the elements in an array until a defined
+You can use a `While` loop to display the elements in an array until a defined
condition is no longer true. For example, to display the elements in the `$a` array while the array index is less than 4, type:
while($i -lt 4) {
### Count or Length or LongLength
-To determine how many items are in an array, use the `Length` property or its
-`Count` alias. `Longlength` is useful if the array contains more than
+To determine how many items are in an array, use the **Length** property or its
+**Count** alias. **Longlength** is useful if the array contains more than
2,147,483,647 elements. ```powershell
True
### Clear Sets all element values to the _default value_ of the array's element type.
-The Clear() method does not reset the size of the array.
+The `Clear()` method does not reset the size of the array.
In the following example `$a` is an array of objects.
$intA
Allows to iterate over all elements in the array and perform a given operation for each element of the array.
-The ForEach method has several overloads that perform different operations.
+The `ForEach` method has several overloads that perform different operations.
``` ForEach(scriptblock expression)
This method was added in PowerShell v4.
> the scriptblock is the only parameter. Also, there must not be a space > between the method and the opening parenthesis or brace.
-The following example shows how use the foreach method. In this case the
+The following example shows how use the `ForEach` method. In this case the
intent is to generate the square value of the elements in the array. ```powershell
TWO
THREE ```
-Just like the `-ArgumentList` parameter of `ForEach-Object`, the `arguments`
-parameter allows the passing of an array of arguments to a script block
-configured to accept them.
+Just like the `-ArgumentList` parameter of `ForEach-Object`, the `Arguments`
+parameter allows the passing of an array of values to a script block configured
+to accept them.
> [!NOTE] > Starting in Windows PowerShell 3.0 retrieving properties and executing > methods for each item in a collection can also be accomplished using "Methods
-> of scalar objects and collections" You can read more about that here
+> of scalar objects and collections". You can read more about that here
> [about_methods](about_methods.md). ### Where
For more information, see [System.Tuple](/dotnet/api/system.tuple).
- [about_For](about_For.md) - [about_Foreach](about_Foreach.md) - [about_While](about_While.md)-
Microsoft.PowerShell.Core About Assignment Operators (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Core/About/about_Assignment_Operators.md
$d
7 ```
-## Microsoft .NET Framework types
+## Microsoft .NET types
By default, when a variable has only one value, the value that is assigned to the variable determines the data type of the variable. For example, the
type:
$a = 6 ```
-To find the .NET Framework type of a variable, use the **GetType** method and
-its **FullName** property, as follows. Be sure to include the parentheses after
-the **GetType** method name, even though the method call has no arguments:
+To find the .NET type of a variable, use the **GetType** method and its
+**FullName** property, as follows. Be sure to include the parentheses after the
+**GetType** method name, even though the method call has no arguments:
```powershell $a = 6
$a
9 ```
-You can cast a new scalar variable as any .NET Framework type by placing the
-type name in brackets that precede either the variable name or the first
-assignment value. When you cast a variable, you can determine the types of data
-that can be stored in the variable. And, you can determine how the variable
-behaves when you manipulate it.
+You can cast a new scalar variable as any .NET type by placing the type name in
+brackets that precede either the variable name or the first assignment value.
+When you cast a variable, you can determine the types of data that can be
+stored in the variable. And, you can determine how the variable behaves when
+you manipulate it.
For example, the following command casts the variable as a string type:
example, the following command casts the variable as a `string []` array type:
[string []] $a = "one", "two", "three" ```
-PowerShell variables can be any .NET Framework data type. In addition, you can
-assign any fully qualified .NET Framework data type that is available in the
-current process. For example, the following command specifies a
-`System.DateTime` data type:
+PowerShell variables can be any .NET data type. In addition, you can assign any
+fully qualified .NET data type that is available in the current process. For
+example, the following command specifies a `System.DateTime` data type:
```powershell [System.DateTime]$a = "5/31/2005"
Microsoft.PowerShell.Core About Automatic Variables (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md
description: Describes variables that store state information for PowerShell. These variables are created and maintained by PowerShell. Locale: en-US Last updated 05/13/2021
+no-loc: [Reset, Current, Background, Blink, Bold, Foreground, Formatting, Hidden, Italic, Reset, Reverse, Underline]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Automatic Variables
blocks (which are unnamed functions).
> End block in the same function or script block. Since `$input` is an enumerator, accessing any of it's properties causes
-`$input` to no longer be available. You can store `$input` in another variable
-to reuse the `$input` properties.
+`$input` to no longer be available. You can store `$input` in another variable to
+reuse the `$input` properties.
Enumerators contain properties and methods you can use to retrieve loop values and change the current loop iteration. For more information, see
when you use regular expressions with the `-match` operator.
For more information about the `-match` operator, see [about_Comparison_Operators](about_comparison_operators.md). For more
-information on regular expressions, see [about_Regular_Expressions](about_Regular_Expressions.md).
+information on regular expressions, see
+[about_Regular_Expressions](about_Regular_Expressions.md).
The `$Matches` variable also works in a `switch` statement with the `-Regex`
-parameter. It's populated the same way as the `-match` and `-notmatch` operators.
-For more information about the `switch` statement, see [about_Switch](about_Switch.md).
+parameter. It's populated the same way as the `-match` and `-notmatch`
+operators. For more information about the `switch` statement, see
+[about_Switch](about_Switch.md).
### $MyInvocation
properties.
Unlike the `$PSScriptRoot` and `$PSCommandPath` automatic variables, the **PSScriptRoot** and **PSCommandPath** properties of the `$MyInvocation`
-automatic variable contain information about the invoker or calling script,
-not the current script.
+automatic variable contain information about the invoker or calling script, not
+the current script.
### $NestedPromptLevel
PowerShell that is running in the current session. The table includes the
following items: - **PSVersion** - The PowerShell version number-- **PSEdition** - This property has the value of 'Desktop' for PowerShell 4 and
+- **PSEdition** This property has the value of 'Desktop' for PowerShell 4 and
below as well as PowerShell 5.1 on full-featured Windows editions. This
- property has the value of 'Core' for PowerShell 6 and above as well as
+ property has the value of `Core` for PowerShell 6 and above as well as
PowerShell PowerShell 5.1 on reduced-footprint editions like Windows Nano Server or Windows IoT. - **GitCommitId** - The commit Id of the source files, in GitHub,
An enumerator contains properties and methods you can use to advance or reset
iteration, or retrieve iteration values. Directly manipulating enumerators isn't considered best practice. -- Within loops, flow control keywords [break](about_Break.md) and [continue](about_Continue.md)
- should be preferred.
+- Within loops, flow control keywords [break](about_Break.md) and
+ [continue](about_Continue.md) should be preferred.
- Within functions that accept pipeline input, it's best practice to use
- Parameters with the **ValueFromPipeline** or
+ parameters with the **ValueFromPipeline** or
**ValueFromPipelineByPropertyName** attributes.
- For more information, see [about_Functions_Advanced_Parameters](about_Functions_Advanced_Parameters.md).
+ For more information, see
+ [about_Functions_Advanced_Parameters](about_Functions_Advanced_Parameters.md).
### MoveNext The [MoveNext](/dotnet/api/system.collections.ienumerator.movenext) method advances the enumerator to the next element of the collection. **MoveNext**
-returns **True** if the enumerator was successfully advanced, **False** if
-the enumerator has passed the end of the collection.
+returns `True` if the enumerator was successfully advanced, `False` if the
+enumerator has passed the end of the collection.
> [!NOTE] > The **Boolean** value returned my **MoveNext** is sent to the output stream.
Num has not changed: two
``` Using the **Reset** method resets the current element in the collection. The
-following example loops through the first two elements **twice** because the
+following example loops through the first two elements _twice_ because the
**Reset** method is called. After the first two loops, the `if` statement fails and the loop iterates through all three elements normally.
Default (Current): End
[about_Splatting](about_Splatting.md) [about_Variables](about_Variables.md)-
Microsoft.PowerShell.Core About Break (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Core/About/about_Break.md
Execution continues at the next statement after the control block. The
statement supports labels. A label is a name you assign to a statement in a script.
-## Using break in loops
+## Using `break` in loops
When a `break` statement appears in a loop, such as a `foreach`, `for`, `do`, or `while` loop, PowerShell immediately exits the loop.
variable `$i` is incremented by 1. The third time the loop is run, `$i` equals
2, and the `$val` variable equals 30. At this point, the `break` statement runs, and the `foreach` loop exits.
-### Using a labeled break in a loop
+### Using a labeled `break` in a loop
A `break` statement can include a label. If you use the `break` keyword with a label, PowerShell exits the labeled loop instead of exiting the current loop.
loop. No label is needed.
PowerShell does not limit how far labels can resume execution. The label can even pass control across script and function call boundaries.
-## Using break in a switch statement
+## Using `break` in a `switch` statement
In a `switch`construct, `break` causes PowerShell to exit the `switch` code block.
exits. If the four `break` statements are removed from the example, all four
conditions are met. This example uses the `break` statement to display results when the most specific condition is met.
-## Using break in a trap statement
+## Using `break` in a `trap` statement
If the final statement executed in the body of a `trap` statement is `break`, the error object is suppressed and the exception is re-thrown.
Line |
| Attempted to divide by zero. ```
-## Do not use break outside of a loop, switch, or trap
+## Do not use `break` outside of a loop, `switch`, or `trap`
When `break` is used outside of a construct that directly supports it (loops, `switch`, `trap`), PowerShell looks _up the call stack_ for an
Microsoft.PowerShell.Core About Execution Policies (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Core/About/about_Execution_Policies.md
description: Describes the PowerShell execution policies and explains how to manage them. Locale: en-US Last updated 08/10/2020
+no-loc: [Bypass, Default, Restricted, Undefined, Process, Scope]
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: about Execution Policies
If no execution policy is set in any scope, the effective execution policy is
### Set a different policy for one session
-You can use the **ExecutionPolicy** parameter of **pwsh.exe** to set an
-execution policy for a new PowerShell session. The policy affects only the
-current session and child sessions.
+You can use the **ExecutionPolicy** parameter of `pwsh.exe` to set an execution
+policy for a new PowerShell session. The policy affects only the current
+session and child sessions.
To set the execution policy for a new session, start PowerShell at the command
-line, such as **cmd.exe** or from PowerShell, and then use the
-**ExecutionPolicy** parameter of **pwsh.exe** to set the execution policy.
+line, such as `cmd.exe` or from PowerShell, and then use the
+**ExecutionPolicy** parameter of `pwsh.exe` to set the execution policy.
For example:
Configuration nodes in Group Policy Editor in the following paths.
For Windows XP and Windows Server 2003:
-Administrative Templates\Windows Components\Windows PowerShell
+`Administrative Templates\Windows Components\Windows PowerShell`
For Windows Vista and later versions of Windows:
-Administrative Templates\Classic Administrative Templates\
-Windows Components\Windows PowerShell
+`Administrative Templates\Classic Administrative Templates\Windows Components\Windows PowerShell`
Policies set in the Computer Configuration node take precedence over policies set in the User Configuration node.
For more information, see [about_Group_Policy_Settings](about_Group_Policy_Setti
When determining the effective execution policy for a session, PowerShell evaluates the execution policies in the following precedence order: -- Group Policy: MachinePolicy-- Group Policy: UserPolicy-- Execution Policy: Process (or `pwsh.exe -ExecutionPolicy`)-- Execution Policy: CurrentUser-- Execution Policy: LocalMachine
+```
+Group Policy: MachinePolicy
+Group Policy: UserPolicy
+Execution Policy: Process (or pwsh.exe -ExecutionPolicy)
+Execution Policy: CurrentUser
+Execution Policy: LocalMachine
+```
## Manage signed and unsigned scripts
Beginning in PowerShell 3.0, you can use the **Stream** parameter of the
from the internet. Use the `Unblock-File` cmdlet to unblock the scripts so that you can run them in PowerShell.
-For more information, see [about_Signing](about_Signing.md), [Get-Item](xref:Microsoft.PowerShell.Management.Get-Item),
-and [Unblock-File](xref:Microsoft.PowerShell.Utility.Unblock-File).
+For more information, see [about_Signing](about_Signing.md),
+[Get-Item](xref:Microsoft.PowerShell.Management.Get-Item), and
+[Unblock-File](xref:Microsoft.PowerShell.Utility.Unblock-File).
> [!NOTE] > Other methods of downloading files may not mark the files as coming from the
Zone check which avoids the problem.
[Get-Item](xref:Microsoft.PowerShell.Management.Get-Item)
-[Pwsh Console Help](about_pwsh.md)
+[about_Pwsh](about_pwsh.md)
[Set-ExecutionPolicy](xref:Microsoft.PowerShell.Security.Set-ExecutionPolicy) [Unblock-File](xref:Microsoft.PowerShell.Utility.Unblock-File)-
Microsoft.PowerShell.Management Get Itemproperty (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Management/Get-ItemProperty.md
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 05/14/2019 Last updated : 05/25/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/get-itemproperty?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Get-ItemProperty
Get-ItemProperty -LiteralPath <String[]> [[-Name] <String[]>] [-Filter <String>]
## DESCRIPTION
-The `Get-ItemProperty` cmdlet gets the properties of the specified items.
-For example, you can use this cmdlet to get the value of the LastAccessTime property of a file
-object. You can also use this cmdlet to view registry entries and their values.
+The `Get-ItemProperty` cmdlet gets the properties of the specified items. For example, you can use
+this cmdlet to get the value of the LastAccessTime property of a file object. You can also use this
+cmdlet to view registry entries and their values.
## EXAMPLES
Get-ItemProperty C:\Windows
### Example 2: Get the properties of a specific file
-This command gets the properties of the `C:\Test\Weather.xls` file.
-The result is piped to the `Format-List` cmdlet to display the output as a list.
+This command gets the properties of the `C:\Test\Weather.xls` file. The result is piped to the
+`Format-List` cmdlet to display the output as a list.
```powershell Get-ItemProperty C:\Test\Weather.xls | Format-List ```
-### Example 3: Display the value name and data of registry entries in a registry subkey
+### Example 3: Get the value name and data of a registry entry in a registry subkey
-This command displays the value name and data of each of the registry entries contained in the
-"CurrentVersion" registry subkey.
+This command gets the value name and data of the `ProgramFilesDir` registry entry in the
+`CurrentVersion` registry subkey. The **Path** specifies the subkey and the **Name** parameter
+specifies the value name of the entry.
```powershell
-Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion
+Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion -Name "ProgramFilesDir"
``` > [!NOTE] > This command requires that there is a PowerShell drive named `HKLM:` that is mapped to the
-> "HKEY_LOCAL_MACHINE" hive of the registry.
+> `HKEY_LOCAL_MACHINE` hive of the registry.
>
-> A drive with that name and mapping is available in PowerShell by default.
-> Alternatively, the path to this registry subkey can be specified by using the following alternative
-> path that begins with the provider name followed by two colons:
+> A drive with that name and mapping is available in PowerShell by default. Alternatively, the path
+> to this registry subkey can be specified by using the following alternative path that begins with
+> the provider name followed by two colons:
> > `Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion`.
-### Example 4: Get the value name and data of a registry entry in a registry subkey
-
-This command gets the value name and data of the "ProgramFilesDir" registry entry in the
-"CurrentVersion" registry subkey.
-The **Path** specifies the subkey and the **Name** parameter specifies the
-value name of the entry.
-
-```powershell
-Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion -Name "ProgramFilesDir"
-```
-
-### Example 5: Get the value names and data of registry entries in a registry key
+### Example 4: Get the value names and data of registry entries in a registry key
-This command gets the value names and data of the registry entries in the "PowerShellEngine"
+This command gets the value names and data of the registry entries in the `PowerShellEngine`
registry key. The results are shown in the following sample output. ```powershell
PSCompatibleVersion : 1.0,2.0
### -Credential > [!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](../Microsoft.PowerShell.Core/Invoke-Command.md).
+> 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](../Microsoft.PowerShell.Core/Invoke-Command.md).
```yaml Type: System.Management.Automation.PSCredential
Accept wildcard characters: False
### -Name
-Specifies the name of the property or properties to retrieve.
-Wildcard characters are permitted.
+Specifies the name of the property or properties to retrieve. Wildcard characters are permitted.
```yaml Type: System.String[]
Accept wildcard characters: True
### -Path
-Specifies the path to the item or items.
-Wildcard characters are permitted.
+Specifies the path to the item or items. Wildcard characters are permitted.
```yaml Type: System.String[]
providers available in your session, type `Get-PSProvider`. For more information
[Set-ItemProperty](Set-ItemProperty.md) [about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md)-
Microsoft.PowerShell.Management Get Itempropertyvalue (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Management/Get-ItemPropertyValue.md
Get-ItemPropertyValue -LiteralPath <String[]> [-Name] <String[]> [-Filter <Strin
## DESCRIPTION The `Get-ItemPropertyValue` gets the current value for a property that you specify when you use the
-*Name* parameter, located in a path that you specify with either the *Path* or *LiteralPath*
+**Name** parameter, located in a path that you specify with either the **Path** or **LiteralPath**
parameters. ## EXAMPLES
Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name
### Example 2: Get the last write time of a file or folder This command gets the value of the **LastWriteTime** property, or the last time a file or folder was
-changed, from the "C:\Users\Test\Documents\ModuleToAssembly" folder, working in the FileSystem
+changed, from the `C:\Program Files\PowerShell` folder, working in the FileSystem
provider. ```powershell
-Get-ItemPropertyValue -Path C:\Users\Test\Documents\ModuleToAssembly -Name LastWriteTime
+Get-ItemPropertyValue -Path 'C:\Program Files\PowerShell' -Name LastWriteTime
``` ```output
This command gets the values of the **LastWriteTime**, **CreationTime**, and **R
a folder. The property values are returned in the order in which you specified the property names. ```powershell
-Get-ItemPropertyValue -Path C:\Users\Test\Documents\ModuleToAssembly -Name LastWriteTime,CreationTime,Root
+Get-ItemPropertyValue -Path 'C:\Program Files\PowerShell' -Name LastWriteTime,CreationTime,Root
``` ```output
-Wednesday, September 3, 2014 2:53:22 PM
-Wednesday, September 3, 2014 2:53:10 PM
-
-Name : C:\
-Parent :
-Exists : True
-Root : C:\
-FullName : C:\
-Extension :
-CreationTime : 9/1/2014 4:59:45 AM
-CreationTimeUtc : 9/1/2014 11:59:45 AM
-LastAccessTime : 9/27/2014 5:22:02 PM
-LastAccessTimeUtc : 9/28/2014 12:22:02 AM
-LastWriteTime : 9/27/2014 5:22:02 PM
-LastWriteTimeUtc : 9/28/2014 12:22:02 AM
-Attributes : Hidden, System, Directory
-BaseName : C:\
-Target :
-LinkType :
-Mode : d--hs-
+Tuesday, March 23, 2021 6:53:13 AM
+Monday, August 14, 2017 1:42:40 PM
+
+Parent :
+Root : C:\
+FullName : C:\
+Extension :
+Name : C:\
+Exists : True
+CreationTime : 10/30/2015 1:28:30 AM
+CreationTimeUtc : 10/30/2015 6:28:30 AM
+LastAccessTime : 5/26/2021 9:22:24 AM
+LastAccessTimeUtc : 5/26/2021 2:22:24 PM
+LastWriteTime : 5/25/2021 7:25:08 AM
+LastWriteTimeUtc : 5/25/2021 12:25:08 PM
+Attributes : Hidden, System, Directory
+Mode : d--hs
+ModeWithoutHardLink : d--hs
+BaseName : C:\
+Target :
+LinkType :
``` ## PARAMETERS
Microsoft.PowerShell.Management Get Psprovider (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Management/Get-PSProvider.md
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Management Previously updated : 06/09/2017 Last updated : 05/26/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/get-psprovider?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Get-PSProvider
Get-PSProvider [[-PSProvider] <String[]>] [<CommonParameters>]
## DESCRIPTION
-The `Get-PSProvider` cmdlet gets the PowerShell providers in the current session.
-You can get a particular drive or all drives in the session.
+The `Get-PSProvider` cmdlet gets the PowerShell providers in the current session. You can get a
+particular drive or all drives in the session.
PowerShell providers let you access a variety of data stores as though they were file system drives.
-For information about PowerShell providers, see [about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md).
+For information about PowerShell providers, see
+[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md).
## EXAMPLES
This command displays a list of all available PowerShell providers.
Get-PSProvider f*, r* | Format-List ```
-This command displays a list of all PowerShell providers with names that begin with the letter f or
-r.
+This command displays a list of all PowerShell providers with names that begin with the letter `f`
+or `r`.
### Example 3: Find snap-ins or module that added providers to your session ```powershell
-Get-PSProvider | Format-Table name, module, pssnapin -auto
+Get-PSProvider | Format-Table Name, Module, PSSnapIn -AutoSize
``` ```Output
-Name Module PSSnapIn
-Test TestModule
-WSMan Microsoft.WSMan.Management
-Alias Microsoft.PowerShell.Core
-Environment Microsoft.PowerShell.Core
-FileSystem Microsoft.PowerShell.Core
-Function Microsoft.PowerShell.Core
-Registry Microsoft.PowerShell.Core
-Variable Microsoft.PowerShell.Core
-Certificate Microsoft.PowerShell.Security
+Name Module PSSnapIn
+---- ------ --------
+Registry Microsoft.PowerShell.Core
+Alias Microsoft.PowerShell.Core
+Environment Microsoft.PowerShell.Core
+FileSystem Microsoft.PowerShell.Core
+Function Microsoft.PowerShell.Core
+Variable Microsoft.PowerShell.Core
+Certificate Microsoft.PowerShell.Security
+WSMan Microsoft.WSMan.Management
``` ```powershell
-Get-PSProvider | Where {$_.pssnapin -eq "Microsoft.PowerShell.Security"}
+Get-PSProvider | Where {$_.ModuleName -eq "Microsoft.PowerShell.Security"}
``` ```Output
These commands find the PowerShell snap-ins or modules that added providers to y
All PowerShell elements, including providers, originate in a snap-in or in a module. These commands use the PSSnapin and Module properties of the **ProviderInfo** object that
-`Get-PSProvider` returns.
-The values of these properties contain the name of the snap-in or module that adds the provider.
+`Get-PSProvider` returns. The values of these properties contain the name of the snap-in or module
+that adds the provider.
The first command gets all of the providers in the session and formats them in a table with the values of their Name, Module, and PSSnapin properties.
C:\Users\User01
``` This example shows that the tilde symbol (~) represents the value of the **Home** property of the
-FileSystem provider.
-The **Home** property value is optional, but for the **FileSystem** provider, it is defined as
-`$env:homedrive\$env:homepath` or `$home`.
+FileSystem provider. The **Home** property value is optional, but for the **FileSystem** provider,
+it is defined as `$env:homedrive\$env:homepath` or `$home`.
## PARAMETERS
Accept wildcard characters: False
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).
+-WarningAction, and -WarningVariable. For more information, see
+[about_CommonParameters](../Microsoft.PowerShell.Core/About/about_CommonParameters.md).
## INPUTS
This cmdlet returns objects that represent the PowerShell providers in the sessi
## NOTES ## RELATED LINKS-