There is no obvious solution.
Quote:
my powershell script uses a lot of processor time.
i see peaks of 100% each minute, the script runs each minute.
Looks pretty normal to me. PowerShell do what you say as quick as possible.
What you want is an
optimisation, it is almost a job by itself, it is about being clever and avoiding brute-force.
To optimize, apart from most obvious cases, one need
context. The context is about how many files, files size, what you want to do ...
The tool of choice is a
profiler (when available).
For your problem, one practically need to be in front of your computer to see where is the problem.
Your previous question was fitting in the most trivial cases, not this time.
[Update]
Quote:
There is one part that could be smarter i think, but i dont know how.
Bad idea !
Smarter code doesn't matter if it is not where you spend time.
To reduce runtime, you need to know where you spend time, this is the job of a
profiler
to tell you that. If you don't have a profiler, you can log the time it takes to execute each part. the place where you spend time is the one you need to optimise.