Powershell

How to Use Get-Item (Microsoft.PowerShell.Management) Cmdlet in PowerShell?

The “Get-Item” cmdlet is utilized to retrieve the items at the provided location in PowerShell. These items include a registry key, directory, or file. It does not get the content of an item. However, to get all the contents of an item use the “*” asterisk (Wildcard Character).

In this article, the cmdlet “Get-Item” of PowerShell will be illustrated in detail.

How to Use Get-Item (Microsoft.PowerShell.Management) Cmdlet in PowerShell?

To get the items at a specified location, use the “Get-Item” cmdlet and then provide the item, such as a directory, registry key, or file. Examples demonstrating the stated cmdlet are specified under.

Example 1: Use the “Get-Item” Cmdlet to Retrieve the Current Working Directory
Execute the “Get-Item” cmdlet along with the “.” to get the current directory:

Get-Item .

Example 2: Use the “Get-Item” Cmdlet to Get the Current Directories Detail
Use the “Get-Item” cmdlet along with the “*” wildcard character to get the details of the current directory:

Get-Item *

Example 3: Use the “Get-Item” Cmdlet to Get the Items in the Specified Directory
To retrieve the items of the specified directory, use the “Get-Item” cmdlet along with the directory address and a wild “*” character:

Get-Item C:\*

Example 4: Use the “Get-Item” Cmdlet to Get the Last Access Time of a Property in the Specified Location
Concatenate the “LastAccessTime” with the “Get-Item” cmdlet and the directory address to retrieve its last access time:

(Get-Item C:\).LastAccessTime

That’s all! We have illustrated the “Get-Item” cmdlet in detail.

Conclusion

PowerShell’s “Get-Item” cmdlet is used to retrieve the items at a specified location. These items include a file, directory, or a registry. However, it does not get the content of an item. In this post, the “Get-Item” cmdlet has been demonstrated with the assistance of several examples.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.