More Extended Attributes with PowerShell
I hope you had an opportunity to try out the code samples from the last article. Today, I want to continue exploring extended attributes and how to display them with PowerShell. I think of the extended attributes as metadata, although certainly some items such as the file size are exposed as normal properties. But using the extended attributes opens up new scripting possibilities.
In the last article we retrieved extended attributes from a general file. Where this gets interesting is with other file types. Using the demo code from last week, here’s a look at an image file.
$file = $shellFolder.Items() | where { $_.name -eq 'ps33.jpg' }
$out = @{}
foreach ($item in $AttributeHash.GetEnumerator()) {
$exValue = $shellFolder.GetDetailsOf($file, $item.Value)
If ($exValue) {
$out.add($item.key, $exValue)
}
}
[PSCustomObject]$out
I’m using the extended attribute dictionary. This provides some interesting properties.
Want to read the full issue?