I am hoping someone can give me the push I need to get this done, but I have had no luck with this exact situation online.
I need to use PowerShell (unfortunately I can't use Python or .NET to so this:( ) to parse though a list of files to determine if they contain a line termination of /r rather than /r/n. This script was previously in production and working, when single files were passed.
I am making adjustments so that multiple files can be accommodated.
I am getting the list of filenames and putting them into an array (which is working) but when I tey to loop the files through the if statement I get this error.
Here is my code:
param(
#[Parameter(Mandatory=$True)]
[String]$FileName = "C:\LineTermTest\*C*.txt"
)
$FileNameArray = Get-ChildItem -Path $FileName | where {!$_.psicontainter }| Select-Object fullname
for ($i=0; $i -le $FileNameArray.Length -1; $i++ )
{
$File = $FileNameArray[$i]
if (Get-Content -path $File -Delimiter "`0" | Select-String "[^`r]`n" )
{
$content = Get-Content $File
$content | Set-Content $File -Replace "`n", "'r'n" -Encoding ASCII
[gc]::collect()
[gc]::WaitForPendingFinalizers()
}
}
and here is the error I get
Get-Content : A parameter cannot be found that matches parameter name 'Delimiter'. At line:13 char:39 + if (Get-Content -path $File -Delimiter <<<< "
0" | Select-String "[^r]`n" )
+ CategoryInfo : InvalidArgument: (:) [Get-Content], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetContentCommandGet-Content : A parameter cannot be found that matches parameter name 'Delimiter'. At line:13 char:39 + if (Get-Content -path $File -Delimiter <<<< "
0" | Select-String "[^r]`n" )
+ CategoryInfo : InvalidArgument: (:) [Get-Content], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetContentCommandGet-Content : A parameter cannot be found that matches parameter name 'Delimiter'. At line:13 char:39 + if (Get-Content -path $File -Delimiter <<<< "
0" | Select-String "[^r]`n" )
+ CategoryInfo : InvalidArgument: (:) [Get-Content], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetContentCommand
dos2unix? - Bacon Bits