list files based on conditions

%3CLINGO-SUB%20id%3D%22lingo-sub-1884085%22%20slang%3D%22en-US%22%3Elist%20files%20based%20on%20conditions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1884085%22%20slang%3D%22en-US%22%3E%3CP%3ENeed%20to%20list%20files%26nbsp%3B%20from%20multiple%20paths%20with%20its%20full%20path%2C%20date%20%26amp%3B%20time%20info.%20The%20condition%20is%20it%20has%20to%20exclude%20files%20owned%20by%20a%20specific%20user%20and%20also%20exclude%20files%20from%20certain%20folders%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1884085%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWindows%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1885944%22%20slang%3D%22en-US%22%3ERe%3A%20list%20files%20based%20on%20conditions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1885944%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F867937%22%20target%3D%22_blank%22%3E%40sandeep1947%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETry%20this%20quick%20one%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%24Paths%3D%40('C%3A%5CAttendanceReport'%2C'C%3A%5CChocolatey')%0AGet-ChildItem%20%24Paths%20-Recurse%20%7C%20get-acl%20%7C%20where%20%7B(%24_.path%20-notlike%20%22*%5CdontInclude%5C*%22)%20-and%20(%24_.Owner%20-notlike%20%22*System*%22)%7D%20%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

Need to list files  from multiple paths with its full path, date & time info. The condition is it has to exclude files owned by a specific user and also exclude files from certain folders

1 Reply

@sandeep1947 

Try this quick one

 

$Paths=@('C:\AttendanceReport','C:\Chocolatey')
Get-ChildItem $Paths -Recurse | get-acl | where {($_.path -notlike "*\dontInclude\*") -and ($_.Owner -notlike "*System*")}