Created
April 2, 2020 00:21
-
-
Save chriskuech/a32f86ad2609719598b073293d09ca03 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Invoke-InDirectory { | |
Param( | |
[ValidateScript( { Test-Path $_ -PathType Container } )] | |
[string] $Path, | |
[ValidateNotNullOrEmpty()] | |
[scriptblock] $ScriptBlock | |
) | |
try { | |
Push-Location $Path | |
& $ScriptBlock | |
} | |
finally { | |
Pop-Location | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment