I'm new to PowerShell but I'm trying to work through a folder of multiple files. I have files that will randomly be UTF-8, UTF-8 BOM, LE, BE, anything. I need all of them to be UTF-8 to be ingested by my ETL software our company uses. I tried numerous methods and the one below is the only one I got consistently working for any encoding.
This works almost instantly for one record, but when applying the foreach it takes roughly a minute and half for three items. I'm going to run this daily across thousands so this is unreasonable.
Any help would be appreciated.
'''
# Primary Variables
$Path = ".\Test\"
$Filename = "DriveThru_FileList.txt"
$Files = Get-ChildItem $Path\*.txt -Exclude ($Filename)
Foreach ($File in $Files){
$Content = Get-Content $File
$Content | Out-File -FilePath $File -Encoding "Default"
}
'''