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
As of PowerShell 6.0, Split-Path has an -Extenstion parameter. This means you can do:
$path | Split-Path -Extension
or
Split-Path -Path $path -Extension
For $path = "test.txt" both versions will return .txt, inluding the full stop.
$path = "test.txt"
.txt