Using powershell to search for files with date and owner criteria

I recently had a requirement to search some file servers for files that were modified between 2 date ranges and then filter that output by owner.

After some googleing I came up with the following script with a commented out line that would allow a copy of those files after indexing.


$path = Read-Host “Please enter the top-level path (eg: C:\Temp)”

$user = Read-Host “Please enter the user to be searched for (eg: DOMAIN\User)”
$dst = Read-Host “Please enter the copy destination:”

$files = Get-childitem $path -recurse |
where {$ -gt
[datetime]::parse(“01/01/2010”) -and
$ -lt

foreach ($file in $files){
$owner = Get-Acl $file.FullName
if ($owner.Owner -eq $user){Write-output $file.FullName >> output}
#if ($owner.Owner -eq $user){copy-item -path $file.FullName -dest $dst -force}
else {}

You can follow any responses to this entry through the RSS 2.0 feed.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This blog is kept spam free by WP-SpamFree.