Reputation: 3162
When I filter some folders and output to a html file, the path in the result is always empty. I can't find why it only works on files but folders?
Get-ChildItem -Recurse $source -Filter *PML_*_ECR* | where { $_.psiscontainer } | Where{$_.LastWriteTime -gt (Get-Date).AddDays(-6)} | sort LastWriteTime -descending | select name,LastWriteTime,Directory | convertto-html -head $a -body "<H2>Folder LIST FOR PAST 7 DAYS </H2>" | out-file $output\results.htm
Upvotes: 0
Views: 93
Reputation: 200293
Folders are represented as DirectoryInfo
objects, which don't have a Directory
property. The full path of the folder object itself is provided via the FullName
property:
... | select Name, LastWriteTime, FullName | ...
The path of the parent folder can be obtained via the Parent
property:
... | select Name, LastWriteTime, @{n='Directory';e={$_.Parent.FullName}} | ...
Upvotes: 2
Reputation: 36297
Because Directory
is not a property of that object. Try doing:
Get-ChildItem -Recurse $source -Filter *PML_*_ECR* | where { $_.psiscontainer } ||GM
Then look at the available properties. I think FullName may better suite your needs.
Upvotes: 0