Skip to content

Instantly share code, notes, and snippets.

@safizn
Created October 9, 2019 13:17
Show Gist options
  • Save safizn/167319cb33c25e96194d12554349a031 to your computer and use it in GitHub Desktop.
Save safizn/167319cb33c25e96194d12554349a031 to your computer and use it in GitHub Desktop.
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