Tag Archives: Get-ExtensionAttribute

New article on PowerShell Magazine: Use Shell.Application to display extended file attributes

My latest article on PowerShell Magazine is on how to use Shell.Application Com object to display extended file attributes in PowerShell. Because this is heavily dependent on the Windows version and localization this does present some challenges. The full article containing tips on how to use this class is available on PowerShell Magazine : Use Shell.Application to display extended file attributes

The following example will list the first three attributes using the Shell.Application object:

$com = (New-Object -ComObject Shell.Application).NameSpace('C:\')
$com.Items() | ForEach-Object {
 New-Object -TypeName PSCustomObject -Property @{
 Name = $com.GetDetailsOf($_,0)
 Size = $com.GetDetailsOf($_,1)
 ItemType = $com.GetDetailsOf($_,2)
 }
}

For more articles like this, have a look at the External Articles section of my blog, it contains all the articles I have posted on external sources such as PowerShell Magazine. The article posted on PowerShell magazine contains a link to my Get-ExtensionAttribute script in the TechNet Script Gallery.

Links in this Article
PSTip: Use Shell.Application to display extended file attributes
PowerShell Magazine
External Articles
Get-ExtensionAttribute
My entries in TechNet Script Gallery
Share

Get-ExtensionAttribute – Script in TechNet Script Gallery

Previously I blogged about listing extended file and folder attributes using the Shell.Application object in PowerShell in my List length and bitrate for mp3 files using Shell.Application article. As a result of that post I decided to write a function, Get-ExtensionAttribute, to properly and consistently be able to list extension attributes even when the locale or version of windows is different.

For this purpose I have created a dynamic parameter -ExtensionAttribute which retrieves all extension attributes available on the system it is run which can be selected and displayed. The function takes path names from either pipeline or as a single path or collection of paths.

.EXAMPLE
Get-ExtensionAttribute -FullName C:\Music -ExtensionAttribute Size,Length,Bitrate

Description
-----------
Retrieves the Size,Length,Bitrate and FullName of the contents of the C:\Music folder, non recursively

.EXAMPLE
Get-ExtensionAttribute -FullName C:\Music\Song2.mp3,C:\Music\Song.mp3 -ExtensionAttribute Size,Length,Bitrate

Description
-----------
Retrieves the Size,Length,Bitrate and FullName of Song.mp3 and Song2.mp3 in the C:\Music folder

.EXAMPLE
Get-ChildItem -Recurse C:\Video | Get-ExtensionAttribute -ExtensionAttribute Size,Length,Bitrate,Totalbitrate

Description
-----------
Uses the Get-ChildItem cmdlet to provide input to the Get-ExtensionAttribute function and retrieves selected attributes for the C:\Videos folder recursively

.EXAMPLE
Get-ChildItem -Recurse C:\Music | Select-Object FullName,Length,@{Name = 'Bitrate' ; Expression = { Get-ExtensionAttribute -FullName $_.FullName -ExtensionAttribute Bitrate | Select-Object -ExpandProperty Bitrate } }

Description
-----------
Combines the output from Get-ChildItem with the Get-ExtensionAttribute function, selecting the FullName and Length properties from Get-ChildItem with the ExtensionAttribute Bitrate

The complete function is available in the TechNet Script Library. To view this script or to participate in the discussions about this script either comment here or in the TechNet Script Library.

TechNet Script Library
My entries in TechNet Script Gallery
Get-ExtensionAttribute
Share