Commands / Files

Join-Path

Build a path safely

beginner Files

Join-Path
 Join-Path -Path .\docs -ChildPath 'notes.txt'
Works on
WindowsLinuxmacOS
PowerShell
5.1 and later
Reference
Microsoft Learn: Join-Path

Joins path parts and gets the separators right. Prefer this over string concatenation.

Try this

Join-Path -Path $env:TEMP -ChildPath 'demo.log'

Related commands