TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

PowerShell Set-Item

PowerShell Set-Item with What is PowerShell, History of PowerShell, Features of PowerShell, PowerShell vs CMD, PowerShell Scripting, PowerShell Versions, PowerShell Commands, PowerShell Looping, PowerShell Conditions, PowerShell Array, PowerShell Brackets etc.

<< Back to POWERSHELL

PowerShell Set-Item

The PowerShell Set-Item cmdlet changes the value of an item to the value specified in the command. It changes the value of a variable or registry key. The Windows PowerShell FileSystem provider does not support this cmdlet. In the registry drives, such as HKLM: and HKCU: it changes the data in the default value of the registry key.

Syntax

Set-Item
[-Path<String[]>]
[-Force] 
[-PassThru] 
[-Filter <String[]>]
[-Value<Object>] 
[-Exclude <String[]>]
[-Include <String[]>]
[-Credential <PSCredential>] 
[-WhatIf] 
[-Confirm]
[<CommonParameters>]

Set-Item
[[-Value] <Object>]
[-LiteralPath <string[]>]
[-Force] 
[-PassThru] 
[-Filter <string>] 
[-Include <string[]>]
[-Exclude <string[]>] 
[-Credential <pscredential>] 
[-WhatIf]
[-Confirm]
[-UseTransaction]
[<CommonParameters>]

Parameters

-Path

The -Path parameter is used to specify a path of the location of the items. Wildcard characters are accepted.

-LiteralPath

The -LiteralPath parameter is used to specify a path to one or more locations. The value of this parameter is used exactly as it is typed. If the path includes the escape characters, then enclosed it in quotation marks. No characters are interpreted as wildcards. Single quotation mark tells the Windows PowerShell that it should not interpret any characters as escape sequences.

-Force

The -Force parameter allows the cmdlet to set items that cannot be changed, such as variables or read-only alias. Even using the -Force parameter, the Set-Item cmdlet cannot override the security permission.

-PassThru

The -PassThru parameter is used to pass an object which represents the item to the pipeline. By default, set-item cmdlet doesn't generate any output.

-Filter

The -Filter parameter specifies a filter to qualify the -Path parameter. The FileSystem provider is the only PowerShell provider that supports the uses of filters. This parameter is more efficient as the provider applies the filters when the cmdlet gets the object, rather than having Powershell filters the object after they are accessed.

-Value

The -Value parameter is used to specify a new value for an item.

-Exclude

The items that this cmdlet excludes in operation are specified as a string array. The value of -Exclude parameter qualifies the -Path parameter. Enter a pattern or a path element, such as *.txt. The characters of wildcard are accepted. The -Exclude parameter is effective only when the cmdlet includes the contents of an item, such as C:\*, the wildcard character '*' is used to specify the contents of the C: directory.

-Include

The items that this cmdlet includes in the operation are specified as a string array. The value of -Include parameter qualifies the -Path parameter. Enter a pattern or a path element, such as *.txt. The characters of wildcard are permitted. It is effective only when the cmdlet includes the contents of an item, such as C:\*, the wildcard character '*' is used to specify the contents of the C: directory.

-WhatIf

The -WhatIf parameter is used to display what would happen if the cmdlet executes. The cmdlet is not run.

-Confirm

The -Confirm parameter prompts a confirmation before running the cmdlet.

<Commonparameters>

This cmdlet supports the following common parameters, and their aliases are listed in parenthesis:

  • Debug (db)
  • Verbose (vb)
  • PipelineVariable (pv)
  • ErrorAction (ea)
  • ErrorVariable (ev)
  • OutVariable (ov)
  • OutBuffer (ob)
  • WarningAction (wa)
  • WarningVariable (wv)

Examples

Example 1: To create an alias

PowerShell Set-Item

The cmdlet in this example is used to create an alias for Notepad.

Example 2: To modify the prompt function

PowerShell Set-Item

The cmdlet in this example is used to change the prompt function so that it shows the time before the path.






Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf