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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 61 additions & 64 deletions reference/5.1/Microsoft.PowerShell.Management/Set-ItemProperty.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Management
ms.date: 10/18/2018
ms.date: 10/28/2021
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/set-itemproperty?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Set-ItemProperty
Expand Down Expand Up @@ -77,41 +77,24 @@ Set-ItemProperty -Path C:\GroupFiles\final.doc -Name IsReadOnly -Value $true

This example shows how to use `Set-ItemProperty` to create a new registry entry and to assign a
value to the entry. It creates the "NoOfEmployees" entry in the "ContosoCompany" key in
"HKLM\Software" key and sets its value to 823.
`HKLM\Software` key and sets its value to 823.

Because registry entries are considered to be properties of the registry keys, which are items, you
use `Set-ItemProperty` to create registry entries, and to establish and change their values.

The first command creates the registry entry.
It uses **Path** to specify the path of the `HKLM:` drive and the "Software\MyCompany" key.
The command uses **Name** to specify the entry name and **Value** to specify a value.

The second command uses the `Get-ItemProperty` cmdlet to see the new registry entry. If you use the
`Get-Item` or `Get-ChildItem` cmdlets, the entries do not appear because they are properties of a
key, not items or child items.

The third command changes the value of the **NoOfEmployees** entry to 824.

You can also use the `New-ItemProperty` cmdlet to create the registry entry and its value and then
use `Set-ItemProperty` to change the value.

For more information about the `HKLM:` drive, type `Get-Help Get-PSDrive`.
For more information about how to use PowerShell to manage the registry, type `Get-Help Registry`.

```powershell
Set-ItemProperty -Path "HKLM:\Software\ContosoCompany" -Name "NoOfEmployees" -Value 823
Get-ItemProperty -Path "HKLM:\Software\ContosoCompany"
```

```output
```Output
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software\contosocompany
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software
PSChildName : contosocompany
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
NoOfLocations : 2
NoOfEmployees : 823

```

```powershell
Expand All @@ -129,18 +112,27 @@ NoOfLocations : 2
NoOfEmployees : 824
```

### Example 3: Modify an item by using the pipeline
The first command creates the registry entry.
It uses **Path** to specify the path of the `HKLM:` drive and the `Software\MyCompany` key.
The command uses **Name** to specify the entry name and **Value** to specify a value.

The second command uses the `Get-ItemProperty` cmdlet to see the new registry entry.
If you use the `Get-Item` or `Get-ChildItem` cmdlets, the entries do not appear because they are
properties of a key, not items or child items.

The third command changes the value of the **NoOfEmployees** entry to 824.

You can also use the `New-ItemProperty` cmdlet to create the registry entry and its value and then
use `Set-ItemProperty` to change the value.

These commands show how to use a pipeline operator (`|`) to send an item to `Set-ItemProperty`.
For more information about the `HKLM:` drive, type `Get-Help Get-PSDrive`.
For more information about how to use PowerShell to manage the registry, type `Get-Help Registry`.

The first part of the command uses `Get-ChildItem` to get an object that represents the "Weekly.txt"
file.
The command uses a pipeline operator to send the file object to `Set-ItemProperty`.
The `Set-ItemProperty` command uses the **Name** and **Value** parameters to specify the property
and its new value.
### Example 3: Modify an item by using the pipeline

This command is equivalent to using the **InputObject** parameter to specify the object that
`Get-ChildItem` gets.
Th example uses `Get-ChildItem` to get the `weekly.txt` file. The file object is piped to
`Set-ItemProperty`. The `Set-ItemProperty` command uses the **Name** and **Value** parameters to
specify the property and its new value.

```powershell
Get-ChildItem weekly.txt | Set-ItemProperty -Name IsReadOnly -Value $True
Expand All @@ -150,13 +142,6 @@ Get-ChildItem weekly.txt | Set-ItemProperty -Name IsReadOnly -Value $True

### -Credential

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.

> [!NOTE]
> This parameter is not supported by any providers installed with PowerShell.
> To impersonate another user, or elevate your credentials when running this cmdlet,
Expand All @@ -176,10 +161,11 @@ Accept wildcard characters: False

### -Exclude

Specifies those items upon which the cmdlet does not act, and includes all others.
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 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. The **Exclude** parameter is effective only when the
command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character
specifies the contents of the `C:\Windows` directory.

```yaml
Type: System.String[]
Expand All @@ -190,17 +176,18 @@ Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
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.

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

```yaml
Type: System.String
Expand Down Expand Up @@ -234,10 +221,11 @@ Accept wildcard characters: False

### -Include

Specifies only those items upon which the cmdlet acts, which excludes all others.
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. The **Include** parameter is effective only when the
command includes the contents of an item, such as `C:\Windows\*`, where the wildcard character
specifies the contents of the `C:\Windows` directory.

```yaml
Type: System.String[]
Expand All @@ -248,7 +236,7 @@ Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Accept wildcard characters: True
```

### -InputObject
Expand All @@ -270,11 +258,13 @@ Accept wildcard characters: False

### -LiteralPath

Specifies a path of the item 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 a path to one or more locations. 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.

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

```yaml
Type: System.String[]
Expand Down Expand Up @@ -324,6 +314,7 @@ Accept wildcard characters: False
### -Path

Specifies the path of the items with the property to modify.
Wildcard characters are permitted.

```yaml
Type: System.String[]
Expand All @@ -334,7 +325,7 @@ Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Accept wildcard characters: True
```

### -Type
Expand All @@ -357,7 +348,7 @@ The acceptable values for this parameter are:
- **Unknown**: Indicates an unsupported registry data type, such as **REG_RESOURCE_LIST**.

```yaml
Type: RegistryValueKind
Type: Microsoft.Win32.RegistryValueKind
Parameter Sets: (All)
Aliases:

Expand Down Expand Up @@ -391,7 +382,7 @@ Accept wildcard characters: False
Specifies the value of the property.

```yaml
Type: Object
Type: System.Object
Parameter Sets: propertyValuePathSet, propertyValueLiteralPathSet
Aliases:

Expand All @@ -407,7 +398,7 @@ Accept wildcard characters: False
Prompts you for confirmation before running the cmdlet.

```yaml
Type: SwitchParameter
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf

Expand All @@ -424,7 +415,7 @@ Shows what would happen if the cmdlet runs.
The cmdlet is not run.

```yaml
Type: SwitchParameter
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi

Expand All @@ -437,7 +428,10 @@ Accept wildcard characters: False

### CommonParameters

This cmdlet supports the common parameters: `-Debug`, `-ErrorAction`, `-ErrorVariable`, `-InformationAction`, `-InformationVariable`, `-OutVariable`, `-OutBuffer`, `-PipelineVariable`, `-Verbose`, `-WarningAction`, and `-WarningVariable`. For more information, see [about_CommonParameters](../Microsoft.PowerShell.Core/About/about_CommonParameters.md).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
-WarningAction, and -WarningVariable. For more information, see
[about_CommonParameters](../Microsoft.PowerShell.Core/About/about_CommonParameters.md).

## Inputs

Expand All @@ -456,7 +450,8 @@ generate any output.
## Notes

`Set-ItemProperty` 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](../Microsoft.PowerShell.Core/About/about_Providers.md).
available in your session, type `Get-PSProvider`. For more information, see
[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md).

## Related links

Expand All @@ -473,3 +468,5 @@ available in your session, type `Get-PSProvider`. For more information, see [abo
[Remove-ItemProperty](Remove-ItemProperty.md)

[Rename-ItemProperty](Rename-ItemProperty.md)

[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md)
48 changes: 23 additions & 25 deletions reference/7.0/Microsoft.PowerShell.Management/Set-ItemProperty.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Management
ms.date: 05/14/2019
ms.date: 10/28/2021
online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.management/set-itemproperty?view=powershell-7&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Set-ItemProperty
Expand Down Expand Up @@ -68,8 +68,8 @@ The file is a **System.IO.FileInfo** object and **IsReadOnly** is just one of it
To see all of the properties, type `Get-Item C:\GroupFiles\final.doc | Get-Member -MemberType
Property`.

The `$true` automatic variable represents a value of "TRUE".
For more information, see [about_Automatic_Variables](../Microsoft.PowerShell.Core/About/about_Automatic_Variables.md).
The `$true` automatic variable represents a value of "TRUE". For more information, see
[about_Automatic_Variables](../Microsoft.PowerShell.Core/About/about_Automatic_Variables.md).

```powershell
Set-ItemProperty -Path C:\GroupFiles\final.doc -Name IsReadOnly -Value $true
Expand Down Expand Up @@ -115,7 +115,7 @@ NoOfEmployees : 824
```

The first command creates the registry entry.
It uses **Path** to specify the path of the `HKLM:` drive and the "Software\MyCompany" key.
It uses **Path** to specify the path of the `HKLM:` drive and the `Software\MyCompany` key.
The command uses **Name** to specify the entry name and **Value** to specify a value.

The second command uses the `Get-ItemProperty` cmdlet to see the new registry entry.
Expand All @@ -132,15 +132,9 @@ For more information about how to use PowerShell to manage the registry, type `G

### Example 3: Modify an item by using the pipeline

These commands show how to use a pipeline operator (`|`) to send an item to `Set-ItemProperty`.

The first part of the command uses `Get-ChildItem` to get an object that represents the "Weekly.txt"
file. The command uses a pipeline operator to send the file object to `Set-ItemProperty`.
The `Set-ItemProperty` command uses the **Name** and **Value** parameters to specify the property
and its new value.

This command is equivalent to using the **InputObject** parameter to specify the object that
`Get-ChildItem` gets.
Th example uses `Get-ChildItem` to get the `weekly.txt` file. The file object is piped to
`Set-ItemProperty`. The `Set-ItemProperty` command uses the **Name** and **Value** parameters to
specify the property and its new value.

```powershell
Get-ChildItem weekly.txt | Set-ItemProperty -Name IsReadOnly -Value $True
Expand Down Expand Up @@ -189,11 +183,13 @@ Accept wildcard characters: True

### -Filter

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

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

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

```yaml
Type: System.String[]
Expand Down Expand Up @@ -415,9 +412,9 @@ 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
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
Expand All @@ -431,13 +428,14 @@ You can pipe objects to this cmdlet.
### None, System.Management.Automation.PSCustomObject

This cmdlet generates a **PSCustomObject** object that represents the item that was changed and its
new property value, if you specify the **PassThru** parameter.
Otherwise, this cmdlet does not generate any output.
new property value, if you specify the **PassThru** parameter. Otherwise, this cmdlet does not
generate any output.

## Notes

`Set-ItemProperty` 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](../Microsoft.PowerShell.Core/About/about_Providers.md).
available in your session, type `Get-PSProvider`. For more information, see
[about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md).

## Related links

Expand Down
Loading