TheDeveloperBlog.com

Home | Contact Us

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

PowerShell Get-Item

PowerShell Get-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 Get-Item

The Get-Item cmdlet gets the items at a particular location. This cmdlet does not get the content of item at the specified location unless we use a '*' wildcard character to request all the content of the item.

PowerShell providers use this command to navigate through a different type of data stores.

Syntax

Get-Item
[-Path] <String[]>]
[-Include <String[]>] 
[-Filter <String>]
[-Force]
[-Exclude <String[]>]
[-Stream <String[]>]
[-Credential <PSCredential>] 
[<CommonParameters>]

Parameters

-Path

The -Path parameter specifies the path to an item. The characters of wildcard are accepted. The -Path parameter is required, but the name '-Path' is optional.

You can use a '.' to specify a current location. To specify all the items in the current location, use a '*' asterisk.

-LiteralPath

The -LiteralPath parameter specifies a path to one or more location. Its value is used exactly as it is typed. Wildcards characters are not interpreted. If the path includes any escape character, then enclosed it in quotation marks. Single quotation mark tells the Windows PowerShell not to interpret any character as an escape sequence.

-Force

The -Force parameter indicate those items which cannot be accessed by a user such as hidden files. The implementation of this parameter is varied from provider to provider. Even using the -Force parameter, the cmdlet cannot override the security permissions.

-Include

The -Include parameter specifies as a string array, an item. It also specifies those items which this cmdlet includes in the operation. The value of -Include parameter qualifies the Path parameter. Enter a pattern or a path element, such as '*.txt'.

This parameter is effective only when a cmdlet includes the contents of an item, such as 'C:\Windows\*', where the wildcard character '*' specifies the contents of the C:\Windows directory.

-Filter

The -Filter parameter is used to specify a filter to qualify the -Path parameter. The file system provider is the only installed provider of PowerShell, which supports the use of filters. This parameter is more efficient than other parameters because a provider applies them when the cmdlet retrieves the object, rather than having PowerShell filters the object after they are retrieved.

-Exclude

The -Exclude parameter specifies as a string array, a property. It also specifies those items which this cmdlet excludes from the operation. The value of -Exclude parameter qualifies the Path parameter. Wildcards characters are accepted.

Enter a pattern or a path element, such as A* or *.txt. Wildcard characters are permitted.

-Stream

The -Stream parameter is used to get the particular alternate NTFS file stream from the file. Wildcard characters are supported. Use an asterisk '*' character to get all the streams. The -Stream parameter is not valid on folders.

It is a dynamic parameter and works only in the file system drives.

Examples

Example 1: To get the current location

PowerShell Get-Item

The cmdlet in this example is used to get the current working location. The dot '.' Operator represents the item at current directory but not it's content.

Example 2: To get all the items in the current location

PowerShell Get-Item

The cmdlet in this example is used to access all the items in the current working directory. The asterisk '*' character represents all the content of the current item.

Example 3: To get all the items in the specified directory or location

PowerShell Get-Item

The cmdlet in this example is used to get all the items of a directory given in the cmdlet. Use the asterisk '*' character to show the content of the container, not just the container.

Example 4: To get a property in the specified location

PowerShell Get-Item

The cmdlet in this example shows the LastAccessTime property of the directory, which is given in the cmdlet. LastAccessTime is a property of file system directories. Use this cmdlet (Get-Item \) | Get-Member to see all the properties of a given directory.

Example 5: To display the content of a registry key

PowerShell Get-Item

The cmdlet, in this example, displays the content of Microsoft.PowerShell registry key. We can use this cmdlet with the PowerShell registry provider to show the registry keys and subkeys, but we must use the Get-ItemProperty cmdlet to get the values and data of the registry.






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