@Anonymous @Andreas Baumgarten @Chris
DONE. The code of mr. @Anonymous had a small problem on Split. Instead of Split(",. ") I change it to Split(" ") Works beautiful now.
I hope that also the code of @Andreas Baumgarten to be updates, so as to work as well.
$file = "C:\Folder1\file.txt"
$newfile = "C:\Folder1\newfile.txt"
$content = (Get-Content -Path $file -Encoding UTF8) -join ''
[System.Collections.ArrayList]$words = $content.Trim(",. ").Split(" ")
$counter = $words.count
$newwords = @()
for($i=0; $i -lt $counter; $i++){
$randomword = Get-Random -InputObject $words
$newwords += $randomword
$words.Remove($randomword)
}
$newwords -join ' ' | Out-File -FilePath $newfile