Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Powershell - compare commandline path to current executed script path
# Must be executed from the root path of the git repository.
$commandlineCurrentPath = pwd # Get-Location equivalent
$currentExecutedScriptPath = $PSScriptRoot
$parentOfCurrentExecutedScriptPath = Split-Path -Path $currentExecutedScriptPath -Parent
if(-Not ($parentOfCurrentExecutedScriptPath -eq $commandlineCurrentPath) ){
$message = "Error ! This script must be executed from the root path of the git repository, as it needs to verify path of WSL scripst executed from it."
Write-Host $message -ForegroundColor Red -BackgroundColor Black
pause
break
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.