You are currently viewing PowerShell Set-ItemProperty Cmdlet

PowerShell Set-ItemProperty Cmdlet

PowerShell Set-ItemProperty Cmdlet

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed Get-ItemProperty cmdlet in PowerShell.

https://cloudaffaire.com/powershell-get-itemproperty-cmdlet/

In this blog post, we will discuss Set-ItemProperty cmdlet in PowerShell. You can use Set-ItemProperty cmdlet to set a property of an item in a specific location defined in the path parameter. Set-ItemProperty cmdlet is mainly used to modify properties of the file, directory, and registry key. For example, you can use Set-ItemProperty cmdlet to make a file read-only.

Set-ItemProperty Cmdlet Syntax:

Set-ItemProperty Cmdlet Argument List:

  • Confirm: Prompts you for confirmation before running the cmdlet.
  • Credential: To impersonate another user or elevate your credentials.
  • Exclude: Specifies those items upon which the cmdlet does not act, and includes all others. The value of this parameter qualifies the Path parameter.
  • Filter: Specifies a filter in the format or language of the provider. The value of this parameter qualifies the Path parameter.
  • Force: Forces the cmdlet to set a property on items that cannot otherwise be accessed by the user.
  • Include: Specifies only those items upon which the cmdlet acts, which excludes all others. The value of this parameter qualifies the Path parameter.
  • InputObject: Specifies the object that has the properties that this cmdlet changes. Enter a variable that contains the object or a command that gets the object.
  • LiteralPath: Specifies a path of the item property. Unlike the Path parameter, the value of LiteralPath is used exactly as it is typed.
  • Name: Specifies the name of the property.
  • PassThru: Returns an object that represents the item property. By default, this cmdlet does not generate any output.
  • Path: Specifies the path of the items with the property to modify.
  • Type: Type is a dynamic parameter that the Registry provider adds to the Set-ItemProperty cmdlet. This parameter only works in the registry drives. The acceptable values for this parameter are:
    • String: Specifies a null-terminated string. Equivalent to REG_SZ.
    • ExpandString: Specifies 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: Specifies binary data in any form. Equivalent to REG_BINARY.
    • DWord: Specifies a 32-bit binary number. Equivalent to REG_DWORD.
    • MultiString: Specifies an array of null-terminated strings terminated by two null characters. Equivalent to REG_MULTI_SZ.
    • Qword: Specifies a 64-bit binary number. Equivalent to REG_QWORD.
    • Unknown: Indicates an unsupported registry data type, such as REG_RESOURCE_LIST.
  • UseTransaction: Includes the command in the active transaction. This parameter is valid only when a transaction is in progress.
  • Value: Specifies the value of the property.
  • WhatIf: Shows what would happen if the cmdlet runs. The cmdlet is not run.

PowerShell Set-ItemProperty Cmdlet:

Change Properties Of A Directory In PowerShell:

Change Properties Of A File In PowerShell:

Change Properties Of A Registry Key In PowerShell:

Hope you have enjoyed this article. In the next blog post, we will discuss Get-ChildItem cmdlet in PowerShell.

To Set more details on PowerShell, kindly follow below official documentation

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about?view=powershell-5.1

 

Leave a Reply