Powershell appending files

Hi all i have a script that i will be running several times and combining into a single file.
Is there a way to append only new entries into the file as currently its adding all entries which essentially become duplictaes

LVL 15
Who is Participating?

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

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.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
No. A file is no database, and so you do not have anything generic allowing to only append "new" rows. You'll have to filter the newly generated text pre appending, or apply a "sort unique" on the result file after appending data, or doing similar things needing some specific treatment and effort.

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
It depends on what type of data/objects you are dealing with.  Normally, I would say to bring the keys of your target collection into a hash table and then check to see whether new item keys already exist in the hash table before adding/appending.
cwstad2Author Commented:
Hi Aikimark, how would that be possible

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

1. You create a hash-table (dictionary) variable with @{}
$d = @{}

Open in new window

2. You iterate your objects, adding new key:value pairs to the $d variable.
3. When considering new objects for inclusion/addition, you check to see if that new object's key is already in $d
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
As said, that requires that you can isolate an unique key element to determine if each entry is new or not. You need to have knowledge about the meaning and layout of the output. E.g. if you want to have a scan over PCs for reachability, and only need to know whether they have been reachable at least once out of n tests, that would make up a list (PC, reachable, last fail or first success time stamp), where you change existing records (or not) and add non-exisiting ones.
cwstad2Author Commented:
Thought it was worth a try

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

From novice to tech pro — start learning today.