Set-ItemProperty

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.

   -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.

   -Type registry_data_type
       A dynamic parameter that is only available in registry drives.
       Values:
          String        A null-terminated string. Equivalent to REG_SZ.

          ExpandString  A null-terminated string that contains unexpanded references to environment variables that
                        are expanded when the value is retrieved. Equivalent to REG_EXPAND_SZ.
          Binary        Binary data in any form. Equivalent to REG_BINARY.

          DWord         A 32-bit binary number. Equivalent to REG_DWORD.

          MultiString   An array of null-terminated strings terminated by two null characters. Equivalent to REG_MULTI_SZ.

          Qword         A 64-bit binary number. Equivalent to REG_QWORD.

          Unknown       An unsupported registry data type, such as REG_RESOURCE_LIST.

   -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.

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 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.doc file to true:

PS C:\> 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

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

“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.
How to pipe multiple Registry Values into Set-ItemProperty - powershell.one


 
Copyright © 1999-2024 SS64.com
Some rights reserved