Set the value of a property.
Syntax Set-ItemProperty { [-path] string[] | [-literalPath] string[] } [-name] string [-value] Object [-Type registry_data_type] [-include string[]] [-exclude string[]] [-filter string] [-force] [-passThru] [-credential PSCredential] [-whatIf] [-confirm] [-UseTransaction] [CommonParameters] Set-ItemProperty { [-path] string[] | [-literalPath] string[] } -inputObject psobject [-Type registry_data_type] [-include string[]] [-exclude string[]] [-filter string] [-force] [-passThru] [-credential PSCredential] [-whatIf] [-confirm] [-UseTransaction] [CommonParameters] Key -Path string The path(s) to the items with the property to be set. Wildcards are permitted. -LiteralPath string Like Path above, only the value is used exactly as typed. No characters are interpreted as wildcards. If the path includes any escape characters then enclose the path in single quotation marks. -Name string The name(s) of the property. -Type registry_data_type A dynamic parameter that is only available in registry drives. Values: String A null-terminated string. A REG_SZ registry Data Type. ExpandString A null-terminated string that contains unexpanded references to environment variables that are expanded when the value is retrieved. A REG_EXPAND_SZ registry Data Type. Binary Binary data in any form. A REG_BINARY registry Data Type. DWord A 32-bit binary number. [Default]. A REG_DWORD registry Data Type. MultiString An array of null-terminated strings terminated by two null characters. A REG_MULTI_SZ registry Data Type. Qword A 64-bit binary number. A REG_QWORD registry Data Type. Unknown An unsupported registry Data Type, such as REG_RESOURCE_LIST. -inputObject psobject The object that has the properties to be changed. Enter a variable that contains the object or a command that gets the object. -Value Object The value to be set. -include string Specify only those items upon which the cmdlet will act, excluding all others. -Exclude string Specify items upon which the cmdlet is not to act, and include all others. -Filter string A filter in the provider’s format or language. The exact syntax of the filter (wildcard support etc) depends on the provider. Filters are more efficient than -include/-exclude, because the provider applies the filter when retrieving the objects, rather than having PowerShell filter the objects after they are retrieved. -Force Override restrictions that prevent the command from succeeding, but will not override security settings. -PassThru Return an object representing the item property. -Credential PSCredential Use a credential to validate access to the file. Credential represents a user-name, such as "User64" or "Domain64\User64", or a PSCredential object, such as the one retrieved by using the Get-Credential cmdlet. If you type a user name, you will be prompted for a password. -Confirm Prompt for confirmation before executing the command. -WhatIf Describe what would happen if you executed the command without actually executing it. -UseTransaction Include the command in the active transaction.
Set-ItemProperty includes all the options of the New-ItemProperty cmdlet but adds the option of copying values from another object with '-inputObject' (early versions of PowerShell did not allow setting the type with Set-Itemproperty).
Standard Aliases for Set-ItemProperty: sp
Set a value of abc123 into the (default) key of HKCU:\Software\windevcluster
PS C:\> Set-Location hkcu:
PS HKCU:\> New-Item HKCU:\Software\windevcluster
PS HKCU:\> Set-ItemProperty -path HKCU:\Software\windevcluster -name '(Default)' -value 'abc123'
Disable the SMB1 protocol, this is only needed for filesharing with Windows XP and older machines and it is strongly recommended that you disable it for improved security and performance:
PS C:\> Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" SMB1 -Type DWORD -Value 0 –Force
Setting the -value back to 1 will re-enable it.
This setting can also be found in Programs & Features > Windows features > SMB 1.0/CIFS File Sharing Support.
Set the value of the IsReadOnly property of the bonus.docx file to true:
PS C:\> Set-ItemProperty -path c:\demo\bonus.docx -name IsReadOnly -value $true
Set the value of the IsReadOnly property of the demo3.txt file to True (piping a file object):
PS C:\> Get-ChildItem demo3.txt | Set-ItemProperty -name IsReadOnly -value $true
Set the value of the NUMLOCK key to default ON at login for the current user:
(Other values are the default 0 = OFF at logon, or 1 = Disable Num Lock completely.)
PS C:\> Set-ItemProperty -Path "HKU:\.DEFAULT\Control Panel\Keyboard" -Name "InitialKeyboardIndicators" -Type DWord -Value 2
Set Windows File Explorer to expand the tree view to the current folder:
PS C:\> Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -Value 1
“Whenever there is a conflict between human rights and property rights, human rights must prevail” ~ Abraham Lincoln
Clear-ItemProperty - Delete the value of a property.
Copy-ItemProperty - Copy a property along with its value.
Get-ItemProperty - Retrieve the properties of an object.
Invoke-Expression - Run a PowerShell expression.
Move-ItemProperty - Move a property from one location to another.
New-ItemProperty - Set a new property of an item at a location.
Remove-ItemProperty - Delete the property and its value from an item.
Rename-ItemProperty - Rename a property of an item.
Set-Item - Set the value of a provider pathname.
How to pipe multiple Registry Values into Set-ItemProperty - powershell.one