How can I use Powershell to remove dupliation within a file?

I am currently working with this script.

I need to convert this script to a Powershell script.
It looks within a file for duplication, and if there is duplication it deletes the duplication.


REM Defile file location
set File1=c:\Programs\New.txt
set Workfile=c:\Programs\Temp\_workfile_.txt

REM Error if file does not exist
if not exist "%File1%" (
  goto :next_Script

REM Remove duplicate lines from the file
  copy NUL "%Workfile%" >NUL
  for /f "tokens=* usebackq" %%B in ("%File1%") do (
    findstr /b /e /c:"%%B" /i "%Workfile%">NUL || echo.%%B>>"%Workfile%"
  copy /y "%Workfile%" "%File1%" >NUL
  if exist "%Workfile%" del "%Workfile%"
Who is Participating?
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.

easy one liner
gc .\current-file.txt | sort -unique | out-file newfile.txt

Open in new window

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
Are you doing this for more than one file ?
100questionsAuthor Commented:
Actually, I am amalgamating files together, combining that is.. copy *.txt newfile.txt and then I need to remove any duplication within the file itself.  
It needs to check any duplication line by line, comparing lines to lines etc..
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

100questionsAuthor Commented:
The script does not work as expected, it's reorganizing all the data into alpha order.  Perhaps I should have made this clearer.  
It need to look at every line and remove any lines which are duplicates, respecting the order of the data which currently exists.
100questionsAuthor Commented:
I have posted another question which is much clearer.
100questionsAuthor Commented:
This removes duplication of lines, however in the context of what I am looking for it needs to keep one set of data, between a start marker and an end marker as it were.  This does not respect that structure.  I have opened another question which is much more detailed and cleared.
Great, I will look out for it.

I should be able to make a minor modification and get you to do exactly what you need without changing the sorting of the data.
100questionsAuthor Commented:
Thanks for your help.
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.