Set the value of a property.
Syntax Set-ItemProperty { [-path] string[] | [-literalPath] string[] } [-name] string [-value] Object [-include string[]] [-exclude string[]] [-filter string] [-force] [-passThru] [-credential PSCredential] [-whatIf] [-confirm] [-UseTransaction] [CommonParameters] Set-ItemProperty { [-path] string[] | [-literalPath] string[] } -inputObject psobject [-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. -Value Object The value of the property. -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. -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. CommonParameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer -OutVariable.
Standard Aliases for Set-AliasProperty: sp
Examples
Set a value of abc123 into the (default) key of HKCU:\Software\SS64
PS HKCU:\> set-itemproperty -path HKCU:\Software\SS64 -name '(Default)' -value 'abc123'
Disable the outdated SMB1 protocol, this is only needed for filesharing with Windowx XP and older machines and it is strongly recommended that you disable it for improved security and performance. Setting the value back to 1 would re-enable it. This setting can also be found in Programs & Features > Windows features > SMB 1.0/CIFS File Sharing Support.
C:\PS> Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" SMB1 -Type DWORD -Value 0 –Force
Set the value of the IsReadOnly property of the bonus.doc file to true:
C:\PS> set-itemproperty -path c:\demo\bonus.doc -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
“Whenever there is a conflict between human rights and property rights, human rights must prevail” ~ Abraham Lincoln
Related PowerShell Cmdlets:
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.