Change the value of an item.

      Set-Item { [-path] string[] | [-literalPath] string[] }  
          [[-value] Object] [-include string[]] [-exclude string[]]
             [-filter string] [-force] [-passThru] [-credential PSCredential]
                [-whatIf] [-confirm] [-UseTransaction] [CommonParameters]
   -Path string
       The path(s) to the items. Wildcards are permitted.
       Use a dot (.) to specify the current location. 
       Use the wildcard (*) to specify all items in the current location.

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

   -Value Object
       A new value for the item.

   -include string
       Include only the specified items from the Path. e.g. "May*"
       this only works when the path includes a wildcard character.
   -Exclude string
       Omit the specified items from the Path.
       Enter a path element or pattern, such as "*.txt". Wildcards are permitted.
   -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.

   -Option ScopedItemOptions
       Possible values include None,ReadOnly,Constant,AllScope and Private.
       (only valid when used with the Alias or Function provider)

       Override restrictions that prevent the command from succeeding, apart
       from security settings. e.g. Force will create file path directories 
       or override a files read-only attribute, but will not change file permissions.

       Pass an object representing the item to the pipeline.

   -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.
       This parameter is not supported by any PowerShell core cmdlets or providers.
       Include the command in the active transaction.

       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
       -OutBuffer -OutVariable.

Standard Aliases for Set-Item: si


Set the AllScope and ReadOnly options for the "prompt" function:

PS C:\> set-item -path function:prompt -options "AllScope,ReadOnly"

Create an alias of "np" for Notepad:

PS C:\> set-item -path alias:np -value c:\windows\notepad.exe

Change the value of the "UserRole" environment variable to "Administrator":

PS C:\> set-item -path env:UserRole -value Administrator

"More people are killed every year by pigs than by sharks, which shows just how good we are at evaluating risks" ~ Bruce Schneier


Set-Content - Set content in an item (specific location)
Clear-item - Remove content from a variable or an alias
Get-item - Return an object that represents an item in a namespace
Invoke-item - Invoke an executable or open a file (START)
Move-item - Move an item from one location to another
New-item - Create a new item in a namespace
Remove-item - Remove an item
Rename-item - Change the name of an existing item
Equivalent bash command: builtin - Run a shell builtin

Copyright © 1999-2017
Some rights reserved