If the file comes off the disk and, as others have claimed, use the BaseName and Extension properties:
PS C:\> dir *.xlsx | select BaseName,Extension BaseName Extension -------- --------- StackOverflow.com Test Config .xlsx
If you were given the file name as part of a line (say, from a text file), I would use the static methods GetFileNameWithoutExtension and GetExtension from the System.IO.Path class:
PS C:\> [System.IO.Path]::GetFileNameWithoutExtension("Test Config.xlsx") Test Config PS H:\> [System.IO.Path]::GetExtension("Test Config.xlsx") .xlsx
Goyuix Mar 20 2018-12-12T00: 00Z
source share