I need to extract file name and extension from e.g. my.file.xlsx. I don\'t know the name of file or extension and there may be more dots in the name, so I need to search the
Use Split-Path
$filePath = "C:\PS\Test.Documents\myTestFile.txt"; $fileName = (Split-Path -Path $filePath -Leaf).Split(".")[0]; $extension = (Split-Path -Path $filePath -Leaf).Split(".")[1];