EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 360+ Courses All in One Bundle
  • Login
Home Data Science Data Science Tutorials PowerShell Tutorial PowerShell Get-Item
Secondary Sidebar
PowerShell Tutorial
  • cmdlet
    • PowerShell Wait
    • PowerShell Match
    • cmdlets in PowerShell
    • Start PowerShell from cmd
    • Add-Content in PowerShell
    • Get Help in PowerShell
    • PowerShell Copy-Item
    • PowerShell Remove-Item
    • PowerShell Move-Item
    • Get Command in PowerShell
    • PowerShell Run Command
    • Windows PowerShell ISE
    • Windows Powershell Commands
    • WinRM PowerShell
    • PowerShell Date
    • Powershell Write-Host
    • PowerShell Get-ChildItem
    • PowerShell Sort-Object
    • PowerShell Where Object
    • PowerShell Set-Content
    • PowerShell Set-Location
    • PowerShell Invoke-Command
    • PowerShell Invoke-Webrequest
    • PowerShell Get-Location
    • PowerShell Get-Date
    • PowerShell Get-Service
    • PowerShell Test-Path
    • Powershell Module Path
    • PowerShell Out-File
    • PowerShell if File Exists
    • Powershell Copy File
    • PowerShell Delete File
    • PowerShell New-Item
    • PowerShell Rename-Item
    • PowerShell ComputerName
    • PowerShell Get-Content
    • PowerShell Get-Item
    • PowerShell Get-ADUser
    • PowerShell Grep
    • PowerShell Concatenate String
    • PowerShell Get-Process
    • PowerShell Count
    • PowerShell pause
  • Basics
    • PowerShell Restart Service
    • PowerShell comment
    • PowerShell Map Network Drive
    • PowerShell Append to File
    • PowerShell print
    • What is PowerShell
    • Uses Of Powershell
    • PowerShell Empire
    • PowerShell Parameter
    • PowerShell Stop Service
    • PowerShell Versions
    • How To Install PowerShell
    • PowerShell uninstall module
    • How to Use PowerShell?
    • PowerShell Logging
    • PowerShell Tools
    • PowerShell Commands
    • PowerShell Version Command
    • PowerShell Administrator
    • PowerShell Modules
    • PowerShell Registry
    • PowerShell block Comment
    • PowerShell Verbs
    • PowerShell list
    • PowerShell add user to group
    • PowerShell Write to Console
    • Variable in PowerShell
    • PowerShell New Line
    • PowerShell prompt for input
    • PowerShell File Extension
    • Powershell Remotesigned
    • PowerShell Write to File
    • PowerShell Ping
    • PowerShell wget
    • PowerShell Global variable
    • PowerShell Get-ADGroup
    • Array in PowerShell
    • PowerShell Multidimensional Array
    • PowerShell Array of Strings
    • PowerShell? join array
    • Useful PowerShell Scripts
    • String in PowerShell
    • PowerShell Switch Statement
    • PowerShell Function Parameters
    • PowerShell vs PowerShell ISE
    • PowerShell test-connection
    • PowerShell Test-NetConnection
    • PowerShell GUI
    • PowerShell Variable in String
    • PowerShell Active Directory
  • Variables
    • PowerShell Variables
    • PowerShell Environment Variables
    • PowerShell set environment variable
    • Hashtable in PowerShell
    • Set Variable in PowerShell
  • Operators
    • PowerShell Operators
    • Comparison Operators in PowerShell
    • Logical Operators in PowerShell
    • PowerShell Boolean
    • PowerShell Like Operator
  • Control Statements
    • If Statement in PowerShell
    • If Else in PowerShell
    • Else If in PowerShell
    • Loops in PowerShell
    • For loop in PowerShell
    • PowerShell While Loop
    • PowerShell do while
    • PowerShell Loop through Array
    • PowerShell add to array
    • PowerShell ForEach Loop
    • PowerShell Break
    • PowerShell Continue
    • Switch Case in PowerShell
    • PowerShell If-Not
    • Try-catch in PowerShell
  • Functions
    • PowerShell Functions
    • PowerShell String Functions
    • powershell nslookup
    • PowerShell here string
    • PowerShell Wildcards
    • Regex in PowerShell
    • PowerShell not like
    • PowerShell Filter
    • PowerShell Sleep
    • PowerShell where
    • PowerShell join string
    • PowerShell Exit
    • PowerShell null
    • PowerShell Dictionary
    • PowerShell Location
    • PowerShell Start-Service
    • PowerShell is not digitally signed
    • PowerShell Uptime
    • PowerShell Create Directory
    • PowerShell Trim
    • PowerShell Join-Path
    • PowerShell Execution Policy
    • PowerShell SubString
    • PowerShell Format Table
    • PowerShell Import Module
    • PowerShell ForEach Object
    • PowerShell Alias
    • PowerShell Scheduled Task
    • PowerShell Convert String to Date
    • PowerShell Split String
    • PowerShell Multiline String
    • PowerShell MultiLine Comment
    • PowerShell Rename Folder
    • PowerShell Delete Folder
    • PowerShell String Replace
    • PowerShell join
    • PowerShell xcopy
    • PowerShell Base64
    • PowerShell Tail
    • PowerShell User List
    • PowerShell remove User from group
    • PowerShell JSON Format
    • PowerShell Send Mail
    • PowerShell Convert to String
    • PowerShell Start-Process
    • PowerShell change directory
    • PowerShell Open File
    • PowerShell Batch File
    • PowerShell ZIP
    • PowerShell unzip
    • PowerShell XML
    • PowerShell XML Parsing
    • Remote PowerShell
    • PowerShell Escape Character
    • PowerShell scriptblock
    • PowerShell Executable Location
    • PowerShell Import-CSV?
    • PowerShell Export CSV
  • Interview Questions
    • PowerShell Interview Questions

Related Courses

Shell Scripting Course

All in One Data Science Courses

Data Visualization Courses

PowerShell Get-Item

By Priya PedamkarPriya Pedamkar

powershell get item

Introduction to PowerShell Get-Item

To get any item from any defined location we can use the command Get-Item. With this command we can not get the content of the item, I mean with this command we can not get content directly, but we can get content by using wildcard. To get the content from the item we need to use a wildcard for it, for example (*) to all the contents of the item. This command will be useful in case if you want to navigate through all the available data stores. The main purpose of this command it will allow us to know any available items of any folder or directories from any directories.

Syntax & Parameters in PowerShell Get-Item

Below are the syntax:

Syntax #1

Get-Item
[-Path] <String path for item location>
[-Filter <string filter condition for path>] [-Include <string name of path to include for getting item details>] [-Exclude <string name of path to exclude for getting item details>] [-Force<find the hidden or read only item>] [-Credential <PSCredential>] [-Stream <get the alternate stream of NTFS file>] [<CommonParameters>]

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

Syntax #2

Get-Item
-LiteralPath <String of exact path name>
[-Filter <string filter condition for path>] [-Include <string name of path to include for getting item details>] [-Exclude <string name of path to exclude for getting item details>] [-Force<find the hidden or read only item>] [-Credential <PSCredential>] [-Stream <get the alternate stream of NTFS file>] [<CommonParameters>]

Parameters

Below are the parameters in PowerShell Get-Item:

All in One Data Science Bundle(360+ Courses, 50+ projects)
Python TutorialMachine LearningAWSArtificial Intelligence
TableauR ProgrammingPowerBIDeep Learning
Price
View Courses
360+ Online Courses | 50+ projects | 1500+ Hours | Verifiable Certificates | Lifetime Access
4.7 (86,241 ratings)
1. Credential

This parameter used for the secure execution of the command. Even by using force command one can not break or skip it. But this parameter is not supported by any PowerShell installed providers. If we are really interested in using this command along with Invoke-Command. We have already discussed this command. To know more about Invoke-Command you can refer to the previous section. In this command, we can use an argument like User1, or we can use Domain1/user1.Once you run this command along with the user name it will display a prompt and it will ask for the password. This command introduced in PowerShell version 3.0.

2. Exclude

It defined an array of items that command will execute while running. This parameter will take the path as it’s the parameter value. We can enter path params or we can also specify the pattern for it. The path pattern can be like *.txt.Remember the include command will work better if we will use wildcard character with it for operation, for example, \ranjan\* here character used in wildcard represents contents of the path.

3. Filter

It defines the filtered path to locate the item. We are able to use filter param with PowerShell because it has installed provider FileSystem.We can learn more about FileSystem in about_Wildcard. Always filters are a better option than any other because the provider works when the command received objects instead of after receiving the objects.

4. Force

Many times we will face a situation where we will not be able to fetch items, because of read-only access or any items are hidden file. In such type of situation, we can use this command. How it’s implementation will be done is totally depend on the providers. If you wanted to learn more about the providers please read about_Provider. Force command can not skip the security restrictions. Security restriction means user credential and a valid login user.

5. Include

It defined a string array of items that command will execute while running. This parameter will take the path as it’s the parameter value. We can enter path params or we can specify the pattern also for it. The path pattern can be like *.txt.We can also use a wildcard for it. Remember the include command will work better if we will use wildcard character with it for operation, for example, \ranjan\* here character used in wildcard represents contents of the path.

6. LiteralPath

We have seen many ways to locate the path of items, this one of the ways to locate the path of items. The only thing in this way to locate the path is that we can not use a wildcard as pathname example we can not use “*”. So basically we have to pass the exact path which is as it is typed. The good thing about the literal path is, we can use escape characters. In case if we are using escape character in -LiteralPath we must use a single quotation to notify the Powershell about escape character.

7. Path

Path defines the location of an item. Which the help of this command we can get the item. In the previous params which is LiteralPath, we learned that we have to use an exact path to locate the item, here in case path we can also use a wildcard as path like (*). This is a required parameter. The name of the parameter path is not a required field that means optional.

8. Stream

With the help of this command, we get another or alternate stream of NTFS file from your system files. We just have to give a stream name in this case . Name of the stream can be wildcard also, for example, we can use (*) as the stream name. This command is mainly made for the file system so in case of folders it will not work. A provider called FileSystem which adds the stream to command Get-Item. These streams are dynamic in nature which add by provider FileSystem to command Get-item.

Examples to Implement PowerShell Get-Item

The following are examples to implement:

Example #1

In this example, we will see the current directories’ details.

Code:

Get-Item *

Output:

PowerShell Get-Item - 1

Example #2

In this example, we are fetching the directories by specifying the pathname. See the below example along with the screen of the experiment.

Code:

Get-Item ./ranjan1

Output:

specifying the pathname

Example #3

Till we have seen that by writing path names or current directories we were only able to fetch the folder path but as I said in starting that if we want to get the contents of the directories we need to use a wild card. See the example below where we are passing path names with a wildcard (*) and in output, we are getting all of the contents of the directories.

Code:

Get-Item ./ranjan*

Output:

PowerShell Get-Item - 3

Example #4

In the below example we want to see the last modified or open this directory. Their many properties we can see them in documentations. Please follow the example below along with screens.

Code:

(Get-Item ./ranjan).LastAccessTime

Output:

 last modified or open this directory

Example #5

We have discussed parameters like excluding and include, I am giving an example of excluding. In the below example we are fetching items in the current directory, it returns Desktop. Because we are excluding “W*” once we used “*d” it returns nothing as Desktop starts with D and we are excluding “d”.Please see the below example with the experiment screen.

Code:

Get-Item . -Exclude "w*"
Get-Item . -Exclude "d*"

Output:

PowerShell Get-Item - 5

Recommended Articles

This is a guide to PowerShell Get-Item. Here we discuss Syntax, parameters, examples to implement PowerShell Get-Item. You can also go through our other related articles to learn more –

  1. Power BI Tooltips
  2. PowerShell Tools
  3. PowerShell Sort-Object
  4. PowerShell Convert to String | Parameters
Popular Course in this category
PowerShell Training (2 Courses, 1 Project)
  2 Online Courses |  1 Hands-on Project |   4+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course

Related Courses

Shell Scripting Training (4 Courses, 1 Project)4.9
All in One Data Science Bundle (360+ Courses, 50+ projects)4.8
Data Visualization Training (15 Courses, 5+ Projects)4.7
0 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Data Science Course

SPSS, Data visualization with Python, Matplotlib Library, Seaborn Package

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more