Set-Item
Changes the value of an item to the value specified in the command.
구문
Path (Default) - All providers
Set-Item
[-Path] <String[]>
[[-Value] <Object>]
[-Force]
[-PassThru]
[-Filter <String>]
[-Include <String[]>]
[-Exclude <String[]>]
[-Credential <PSCredential>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
LiteralPath - All providers
Set-Item
[[-Value] <Object>]
-LiteralPath <String[]>
[-Force]
[-PassThru]
[-Filter <String>]
[-Include <String[]>]
[-Exclude <String[]>]
[-Credential <PSCredential>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Path (Default) - Alias and Function providers
Set-Item
[-Path] <string[]>
[[-Value] <Object>]
[-Force]
[-PassThru]
[-Filter <string>]
[-Include <string[]>]
[-Exclude <string[]>]
[-Credential <pscredential>]
[-WhatIf]
[-Confirm]
[-Options <ScopedItemOptions>]
[<CommonParameters>]
LiteralPath - Alias and Function providers
Set-Item
[[-Value] <Object>]
-LiteralPath <string[]>
[-Force]
[-PassThru]
[-Filter <string>]
[-Include <string[]>]
[-Exclude <string[]>]
[-Credential <pscredential>]
[-WhatIf]
[-Confirm]
[-Options <ScopedItemOptions>]
[<CommonParameters>]
Path (Default) - Registry provider
Set-Item
[-Path] <string[]>
[[-Value] <Object>]
[-Force]
[-PassThru]
[-Filter <string>]
[-Include <string[]>]
[-Exclude <string[]>]
[-Credential <pscredential>]
[-WhatIf]
[-Confirm]
[-Type <RegistryValueKind>]
[<CommonParameters>]
LiteralPath - Registry provider
Set-Item
[[-Value] <Object>]
-LiteralPath <string[]>
[-Force]
[-PassThru]
[-Filter <string>]
[-Include <string[]>]
[-Exclude <string[]>]
[-Credential <pscredential>]
[-WhatIf]
[-Confirm]
[-Type <RegistryValueKind>]
[<CommonParameters>]
Description
The Set-Item
cmdlet changes the value of an item, such as a variable or registry key, to the value
specified in the command.
예제
Example 1: Create an alias
This command creates an alias of np for Notepad.
Set-Item -Path Alias:np -Value "C:\windows\notepad.exe"
Example 2: Change the value of an environment variable
This command changes the value of the UserRole environment variable to Administrator.
Set-Item -Path Env:UserRole -Value "Administrator"
Example 3: Modify your prompt function
This command changes the prompt function so that it displays the time before the path.
Set-Item -Path Function:prompt -Value {
'PS '+ (Get-Date -Format t) + " " + (Get-Location) + '> '
}
Example 4: Set options for your prompt function
This command sets the AllScope and ReadOnly options for the prompt function.
This command uses the Options dynamic parameter of Set-Item
.
The Options parameter is available in Set-Item
only when you use it with the Alias or
Function provider.
Set-Item -Path Function:prompt -Options "AllScope,ReadOnly"
매개 변수
-Confirm
Prompts you for confirmation before running the cmdlet.
매개 변수 속성
형식: | SwitchParameter |
Default value: | False |
와일드카드 지원: | False |
DontShow: | False |
별칭: | cf |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-Credential
Note
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.
매개 변수 속성
형식: | PSCredential |
Default value: | Current user |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | True |
나머지 인수의 값: | False |
-Exclude
Specifies, 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.
매개 변수 속성
형식: | String[] |
Default value: | None |
와일드카드 지원: | True |
DontShow: | False |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-Filter
Specifies 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.
매개 변수 속성
형식: | String |
Default value: | None |
와일드카드 지원: | True |
DontShow: | False |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-Force
Forces 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.
매개 변수 속성
형식: | SwitchParameter |
Default value: | False |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-Include
Specifies, 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.
매개 변수 속성
형식: | String[] |
Default value: | None |
와일드카드 지원: | True |
DontShow: | False |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-LiteralPath
Specifies 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.
매개 변수 속성
형식: | String[] |
Default value: | None |
와일드카드 지원: | False |
DontShow: | False |
별칭: | PSPath, LP |
매개 변수 집합
LiteralPath
Position: | Named |
필수: | True |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | True |
나머지 인수의 값: | False |
-Options
This 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 parameterConstant
: The alias can't be deleted or changedPrivate
: The alias is available only in the current scopeAllScope
: The alias is copied to any new scopes that are createdUnspecified
: The option isn't specified
매개 변수 속성
형식: | ScopedItemOptions |
Default value: | None |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-PassThru
Passes an object that represents the item to the pipeline. By default, this cmdlet does not generate any output.
매개 변수 속성
형식: | SwitchParameter |
Default value: | False |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
-Path
Specifies a path of the ___location of the items. Wildcard characters are permitted.
매개 변수 속성
형식: | String[] |
Default value: | None |
와일드카드 지원: | True |
DontShow: | False |
매개 변수 집합
Path
Position: | 0 |
필수: | True |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | True |
나머지 인수의 값: | False |
-Type
This 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.
매개 변수 속성
형식: | RegistryValueKind |
Default value: | None |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | True |
나머지 인수의 값: | False |
-Value
Specifies a new value for the item.
매개 변수 속성
형식: | Object |
Default value: | None |
와일드카드 지원: | False |
DontShow: | False |
매개 변수 집합
(All)
Position: | 1 |
필수: | False |
파이프라인의 값: | True |
속성 이름별 파이프라인의 값: | True |
나머지 인수의 값: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
매개 변수 속성
형식: | SwitchParameter |
Default value: | False |
와일드카드 지원: | False |
DontShow: | False |
별칭: | wi |
매개 변수 집합
(All)
Position: | Named |
필수: | False |
파이프라인의 값: | False |
속성 이름별 파이프라인의 값: | False |
나머지 인수의 값: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
입력
Object
You can pipe an object that represents the new value of the item to this cmdlet.
출력
None
By default, this cmdlet returns no output.
Object
When you use the PassThru parameter, this cmdlet returns an object representing the item.
참고
PowerShell includes the following aliases for Set-Item
:
All platforms:
si
Set-Item
is not supported by the PowerShell FileSystem provider. To change the values of items in the file system, use theSet-Content
cmdlet.In the Registry drives,
HKLM:
andHKCU:
,Set-Item
changes the data in the (Default) value of a registry key.- To create and change the names of registry keys, use the
New-Item
andRename-Item
cmdlet. - To change the names and data in registry values, use the
New-ItemProperty
,Set-ItemProperty
, andRename-ItemProperty
cmdlets.
- To create and change the names of registry keys, use the
Set-Item
is designed to work with the data exposed by any provider. To list the providers available in your session, typeGet-PSProvider
. For more information, see about_Providers.