CmdID / PowerShell / Cmdlets / Set
Set-Item
Changes the value of an item to the value specified in the command. PowerShell reference
From the PowerShell reference
14 parameters
Alias si
What it does
Changes the value of an item to the value specified in the command. The Set-Item cmdlet changes the value of an item, such as a variable or registry key, to the value specified in the command.
Set-Item [-Path] <string[]> [[-Value] <Object>] [-Force] [-PassThru] [-Filter <string>] [-Include <string[]>] [-Exclude <string[]>] [-Credential <pscredential>] [-WhatIf] [-Confirm] [-UseTransaction] [<CommonParameters>]Set-Item [[-Value] <Object>] -LiteralPath <string[]> [-Force] [-PassThru] [-Filter <string>] [-Include <string[]>] [-Exclude <string[]>] [-Credential <pscredential>] [-WhatIf] [-Confirm] [-UseTransaction] [<CommonParameters>]Set-Item [-Path] <string[]> [[-Value] <Object>] [-Force] [-PassThru] [-Filter <string>] [-Include <string[]>] [-Exclude <string[]>] [-Credential <pscredential>] [-WhatIf] [-Confirm] [-UseTransaction] [-Options <ScopedItemOptions>] [<CommonParameters>]Set-Item [[-Value] <Object>] -LiteralPath <string[]> [-Force] [-PassThru] [-Filter <string>] [-Include <string[]>] [-Exclude <string[]>] [-Credential <pscredential>] [-WhatIf] [-Confirm] [-UseTransaction] [-Options <ScopedItemOptions>] [<CommonParameters>]Set-Item [-Path] <string[]> [[-Value] <Object>] [-Force] [-PassThru] [-Filter <string>] [-Include <string[]>] [-Exclude <string[]>] [-Credential <pscredential>] [-WhatIf] [-Confirm] [-UseTransaction] [-Type <RegistryValueKind>] [<CommonParameters>]Set-Item [[-Value] <Object>] -LiteralPath <string[]> [-Force] [-PassThru] [-Filter <string>] [-Include <string[]>] [-Exclude <string[]>] [-Credential <pscredential>] [-WhatIf] [-Confirm] [-UseTransaction] [-Type <RegistryValueKind>] [<CommonParameters>]
Create an alias
Set-Item -Path Alias:np -Value "C:\windows\notepad.exe"IdentifyChange the value of an environment variable
Set-Item -Path Env:UserRole -Value "Administrator"IdentifyModify your prompt function
Set-Item -Path Function:prompt -Value {
'PS '+ (Get-Date -Format t) + " " + (Get-Location) + '> '
}IdentifySet options for your prompt function
Set-Item -Path Function:prompt -Options "AllScope,ReadOnly"IdentifyIts page in the reference: Set-Item.
Parameters
-CredentialNOTE: This parameter is not supported by any providers installed with PowerShell. To impersonate another user, or elevate your credentials when running this cmdlet, use Invoke-Command.-ExcludeSpecifies, as a string array, an item or items that this cmdlet excludes in the operation. The value of this parameter qualifies the Path parameter. Enter a path element or pattern, such as *.txt. Wildcard characters are permitted. The Exclude parameter is effective only when the command includes the contents of an item, such as C:\Windows\*, where the wildcard character specifies the contents of the C:\Windows directory.-FilterSpecifies a filter to qualify the Path parameter. The FileSystem provider is the only installed PowerShell provider that supports the use of filters. You can find the syntax for the FileSystem filter language in about_Wildcards. Filters are more efficient than other parameters, because the provider applies them when the cmdlet gets the objects rather than having PowerShell filter the objects after they are retrieved.-ForceForces the cmdlet to set items that cannot otherwise be changed, such as read-only alias or variables. The cmdlet cannot change constant aliases or variables. Implementation varies from provider to provider. For more information, see about_Providers. Even using the Force parameter, the cmdlet cannot override security restrictions.-IncludeSpecifies, as a string array, an item or items that this cmdlet includes in the operation. The value of this parameter qualifies the Path parameter. Enter a path element or pattern, such as "*.txt". Wildcard characters are permitted. The Include parameter is effective only when the command includes the contents of an item, such as C:\Windows\*, where the wildcard character specifies the contents of the C:\Windows directory.-LiteralPathSpecifies a path to one or more locations. The value of LiteralPath is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.
For more information, see about_Quoting_Rules.-OptionsThis is a dynamic parameter made available by the Alias and Function providers. For more information, see about_Alias_Provider and about_Function_Provider.
Specifies the value of the Options property of an alias.
Valid values are:
- None: The alias has no constraints (default value)
- ReadOnly: The alias can be deleted but can't be changed without using the Force parameter
- Constant: The alias can't be deleted or changed
- Private: The alias is available only in the current scope
- AllScope: The alias is copied to any new scopes that are created
- Unspecified: The option isn't specified-PassThruPasses an object that represents the item to the pipeline. By default, this cmdlet does not generate any output.-PathSpecifies a path of the location of the items. Wildcard characters are permitted.-TypeThis is a dynamic parameter made available by the Registry provider. The Registry provider and this parameter are only available on Windows.
Specifies the type of property that this cmdlet adds. The acceptable values for this parameter are:
- String: Specifies a null-terminated string. Used for REG_SZ values.
- ExpandString: Specifies a null-terminated string that contains unexpanded references to
environment variables that are expanded when the value is retrieved. Used for REG_EXPAND_SZ
values.
- Binary: Specifies binary data in any form. Used for REG_BINARY values.
- DWord: Specifies a 32-bit binary number. Used for REG_DWORD values.
- MultiString: Specifies an array of null-terminated strings terminated by two null characters.
Used for REG_MULTI_SZ values.
- Qword: Specifies a 64-bit binary number. Used for REG_QWORD values.
- Unknown: Indicates an unsupported registry data type, such as REG_RESOURCE_LIST values.-UseTransactionIncludes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_Transactions.-ValueSpecifies a new value for the item.-ConfirmPrompts you for confirmation before running the cmdlet.-WhatIfShows what would happen if the cmdlet runs. The cmdlet is not run.