PowerShell Logo Small

Set-ItemProperty



This is the built-in help made by Microsoft for the command 'Set-ItemProperty', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Creates or changes the value of a property of an item.

SYNTAX


Set-ItemProperty [-Path] <String[]> [-Name] <String> [-Type] [<Microsoft.Win32.RegistryValueKind>] [-Value] <Object> [-Credential [<PSCredential>]] [-Exclude [<String[]>]]
[-Filter [<String>]] [-Force] [-Include [<String[]>]] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable
[<System.String>]] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction [<SwitchParameter>]] [<CommonParameters>]
Set-ItemProperty [-Credential [<PSCredential>]] [-Exclude [<String[]>]] [-Filter [<String>]] [-Force] [-Include [<String[]>]] [-InformationAction {SilentlyContinue | Stop |
Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String>]] [-PassThru] [-Type [<Microsoft.Win32.RegistryValueKind>]] -InputObject <PSObject>
-LiteralPath <String[]> [-Confirm] [-WhatIf] [-UseTransaction [<SwitchParameter>]] [<CommonParameters>]
Set-ItemProperty [-Path] <String[]> [-Credential [<PSCredential>]] [-Exclude [<String[]>]] [-Filter [<String>]] [-Force] [-Include [<String[]>]] [-InformationAction
{SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String>]] [-PassThru] [-Type [<Microsoft.Win32.RegistryValueKind>]]
-InputObject <PSObject> [-Confirm] [-WhatIf] [-UseTransaction [<SwitchParameter>]] [<CommonParameters>]
Set-ItemProperty [-Name] <String> [-Type] [<Microsoft.Win32.RegistryValueKind>] [-Value] <Object> [-Credential [<PSCredential>]] [-Exclude [<String[]>]] [-Filter [<String>]]
[-Force] [-Include [<String[]>]] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String>]] [-PassThru]
-LiteralPath <String[]> [-Confirm] [-WhatIf] [-UseTransaction [<SwitchParameter>]] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Set-ItemProperty cmdlet changes the value of the property of the specified item. You can use the cmdlet to establish or change the properties of items. For example, you
can use Set-ItemProperty to set the value of the IsReadOnly property of a file object to true.


You also use Set-ItemProperty to create and change registry values and data. For example, you can add a new registry entry to a key and establish or change its value.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=293911
Clear-ItemProperty
Copy-ItemProperty
Get-ItemProperty
Move-ItemProperty
New-ItemProperty
Remove-ItemProperty
Rename-ItemProperty
about_Providers

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

PS C:\>set-itemproperty -path c:\GroupFiles\final.doc -name IsReadOnly -value $true



This command sets the value of the IsReadOnly property of the final.doc file to true.

The command uses the Set-ItemProperty cmdlet to change the value of the property of the final.doc file. It uses the Path parameter to specify the file. It uses the Name
parameter to specify the name of the property and the Value parameter to specify the new value.

The $true automatic variable represents a value of TRUE. For more information, see about_Automatic_Variables.

The file is a System.IO.FileInfo object and IsReadOnly is just one of its properties. To see all of the properties and methods of a FileInfo object, pipe the file to the
Get-Member cmdlet. For example, "final.doc | get-member".










-------------------------- EXAMPLE 2 --------------------------

PS C:\>set-itemproperty -path HKLM:\Software\MyCompany -name NoOfEmployees -value 823
PS C:\>get-itemproperty -path HKLM:\Software\MyCompany

PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software\mycompany
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software
PSChildName : mycompany
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
NoOfLocations : 2
NoOfEmployees : 823
PS C:\>set-itemproperty -path HKLM:\Software\MyCompany -name NoOfEmployees -value 824
PS C:\>get-itemproperty -path HKLM:\Software\MyCompany
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software\mycompany
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\software
PSChildName : mycompany
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
NoOfLocations : 2
NoOfEmployees : 824



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 MyCompany key in
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 uses the Set-ItemProperty cmdlet to create the registry entry. It uses the Path parameter to specify the path to the HKLM: drive and the Software\MyCompany
key. It uses the Name parameter to specify the entry name and the Value parameter 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 using Windows PowerShell to manage the registry, type "get-help registry".










-------------------------- EXAMPLE 3 --------------------------

PS C:\>get-childitem weekly.txt | set-itemproperty -name IsReadOnly -value $true



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

The first part of the command uses the Get-ChildItem cmdlet 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.