Skip to content

Instantly share code, notes, and snippets.

@altrive
Last active December 24, 2015 00:59
Show Gist options
  • Select an option

  • Save altrive/6720735 to your computer and use it in GitHub Desktop.

Select an option

Save altrive/6720735 to your computer and use it in GitHub Desktop.
Get relative file path.
$basePath = [Environment]::GetFolderPath([Environment+SpecialFolder]::MyDocuments)
$targetPath = [Environment]::GetFolderPath([Environment+SpecialFolder]::AdminTools)
Write-Host ("Get relative path")
Write-Host ("From : {0}" -f $basePath)
Write-Host ("To : {0}" -f $targetPath )
Write-Host ("Result: {0}" -f $ExecutionContext.SessionState.Path.NormalizeRelativePath($targetPath, $basePath))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment