Backslash is an escape character in regex.
Heres's how I did it:
$backslashCount = $FilePath | Select-String -Pattern "\\" -AllMatches
$backslashCount.Matches.Length
Select-String documentation:
Select-String (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn