PowerShell: Fix a path variable’s trailing slash January 29, 2016 6:47 pm \ by John Perry You can use this syntax to remove any trailing slash ‘\’ to a path and add it back in if it’s a string. # Remove slash $OutPath = $Path.TrimEnd('\') # Remove if exists and add back in $OutPath = $Path.TrimEnd('\') + '\' Posted in: PowerShell