Skip to content

Instantly share code, notes, and snippets.

@jahands
Created May 1, 2022 21:41
Show Gist options
  • Save jahands/fa51670acccce178059f4029742cfbae to your computer and use it in GitHub Desktop.
Save jahands/fa51670acccce178059f4029742cfbae to your computer and use it in GitHub Desktop.
A PowerShell function to convert a path to WSL format
Function ConvertTo-WslPath {
Param(
[Parameter(Mandatory = $true, ValueFromPipeline)]
[string]$Path
)
$p = Get-Item $Path
$wslPath = "/mnt/$($p.PSDrive.Name.ToLower())$($p.FullName.Substring($p.FullName.IndexOf(':')+1).Replace('\','/'))"
$wslPath
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment