function Test-FileEOL { <# .SYNOPSIS Returns false if EOL isn't CRLF .DESCRIPTION Tests given file against valid EOL. Returns true if CRLF is used. .PARAMETER Path Relative or full path to an existing file. .INPUTS [None] .OUTPUTS [bool] .EXAMPLE Test-FileEOL -Path './TestFile.txt' .NOTES #> [CmdletBinding()] [OutputType([bool])] param ( [Parameter(Mandatory = $true)] [ValidateScript( { Test-Path -Path $_ } )] [string]$Path ) begin { } process { $content = Get-Content -Path $Path -Raw -Encoding 'utf8' $CRLFCount = ([regex]::Matches($content, "`r`n$")).Count $LFCount = ([regex]::Matches($content, "`n$")).Count if ($CRLFCount -eq $LFCount) { Write-Debug -Message 'EOL: CRLFCount = LFCount -> true' Write-Output $true } elseif ($CRLFCount -gt $LFCount) { Write-Debug -Message 'EOL: CRLFCount > LFCount -> false' Write-Output $false } elseif ($LFCount -gt $CRLFCount) { Write-Debug -Message 'EOL: CRLFCount < LFCount -> false' Write-Output $false } } end { } }