Get ItemPropertyValue - PowerShell
Overview
Get-ItemPropertyValue retrieves the value of a specified property for a file, folder, or other item on the file system. It allows you to access metadata and other information about files and folders, which can be useful for managing and organizing them.
Syntax
Get-ItemPropertyValue [-Path] <string[]> [-Name] <string> [-ErrorAction] <string> [-Force] [-Verbose] [-Wait] [-ErrorVariable] <string> [-OutVariable] <string> [-OutBuffer] <int> [-ThrottleLimit] <int>
Options/Flags
- -Path: Specifies the path to the item whose property value you want to retrieve. The path can be a fully qualified path, a relative path, or a wildcard path.
- -Name: Specifies the name of the property whose value you want to retrieve. The name can be any valid property name for the item, such as “CreationTime” or “Length”.
- -ErrorAction: Specifies what action to take if an error occurs. The default value is “Stop”.
- -Force: Specifies that the command should continue even if an error occurs.
- -Verbose: Specifies that the command should display verbose output.
- -Wait: Specifies that the command should wait for the operation to complete before returning.
- -ErrorVariable: Specifies the name of a variable in which to store error information.
- -OutVariable: Specifies the name of a variable in which to store the output from the command.
- -OutBuffer: Specifies the maximum number of objects to store in the output buffer. The default value is 100.
- -ThrottleLimit: Specifies the maximum number of concurrent operations that can be performed by the command. The default value is unlimited.
Examples
Example 1: Get the CreationTime property of a file
Get-ItemPropertyValue -Path "C:\Users\Public\Documents\test.txt" -Name CreationTime
Example 2: Get the Length property of a folder
Get-ItemPropertyValue -Path "C:\Users\Public\Documents" -Name Length
Example 3: Get multiple property values from a file
Get-ItemPropertyValue -Path "C:\Users\Public\Documents\test.txt" -Name CreationTime,Length
Common Issues
One common issue that users may encounter when using Get-ItemPropertyValue is that the property they are trying to retrieve does not exist for the specified item. This can happen if the item is not a file or folder, or if the property name is not valid for the item.
Integration
Get-ItemPropertyValue can be combined with other PowerShell commands to perform complex tasks. For example, you can use the output of Get-ItemPropertyValue to filter or sort files and folders.