Powershell List all file with Archive and Offline attributes set

I am trying to run a powershell script to list the name and path of all files with the archive and offline attributes set. The problem is a number of our directory paths are very long and causing the script to skip those directories. Any suggestions on the best way to address this?
LVL 21
compdigit44Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michael B. SmithManaging ConsultantCommented:
You can create a share (or subst) in lower levels of the directory tree which can then be processed.
0
compdigit44Author Commented:
I have to search a very drive that has thousand of sub folders so this would turn into a very manual process. Any other idea even outside of Powershell
0
Michael B. SmithManaging ConsultantCommented:
Yes, you can do it with robocopy. Robocopy allows you to search for files based on specific attributes and has a mode where it just outputs the file names instead of copying files. It also has no filename limitations.

Take a look at https://learn-powershell.net/2013/04/01/list-all-files-regardless-of-260-character-path-restriction-using-powershell-and-robocopy/ and use the /IA argument for specifying the "Include Attribute" to search for. "robocopy /?" for help.
0
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

compdigit44Author Commented:
I have not tried to us Robocopy to list / report on files only with a specific attribute and do not want to mess this up and delete files. What syntax would you suggest.
0
Michael B. SmithManaging ConsultantCommented:
I ran the command below and it did what I expected. If it's not exactly what you want, it's pretty darn close.

That is:
  • it started at C: root
  • it didn't copy anything
  • it included files with only A and O set
  • it listed the files
  • it didn't search empty subdirectories
  • it didn't give me a report I didn't want
  • it listed file sizes in bytes
  • etc.etc.

I ran this in PowerShell, and it must be an elevated PowerShell to recurse EVERYWHERE, but the results (list of files) are stored in $allfiles.

$allFiles = robocopy c:\ NULL /IA:AO /L /S /NJH /BYTES /FP /NC /NDL /TS /XJ /R:0 /W:0

Open in new window

0
compdigit44Author Commented:
Just to confirm.. the follow switch logs all files only that have the attribute archive & offline set correct..... /IA:AO

Also when I run the script you post it seem to list all files and not just the offline archive ones
0
Michael B. SmithManaging ConsultantCommented:
So I went back and tested this on Server 2012 (instead of my Windows 10 desktop) and got some different results, as you indicate. But this worked:

$allFiles = robocopy c:\ NULL /L /A /IA:O /FP /NS /NC /NDL /NP /XJ /NJH /NJS /R:0 /W:0 /TS /BYTES

Open in new window

You'll note that the only real difference is that "/IA:AO" becomes "/A /IA:O". Seems like a bug to me.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
compdigit44Author Commented:
This is great and we are really close. The exact attributes listed for the files I am looking for is APLO yet when I type this in for the attributes, it does not like it. When I search for AO only, it list some files but not all of them and includes some files that should not be listed.
0
Michael B. SmithManaging ConsultantCommented:
I'm sorry, I'm out of ideas. :(
0
compdigit44Author Commented:
You have been a huge help!!!
0
compdigit44Author Commented:
I found that Junction64.exe is able to list junction / reparse files which seems to list all of file with the re-parse attribute set.

Thanks Again...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.