Created
April 27, 2017 09:12
-
-
Save Sarafian/24177f31e729ea8d64a887e8d34d7ea5 to your computer and use it in GitHub Desktop.
Check if powershell code is executed as part of a Pester test
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 Test-PesterInvocation { | |
$commandStack=Get-PSCallStack | Select-Object -ExpandProperty Command | |
#region Render | |
<# | |
for($i=$commandStack.Count-1;$i -ge 0;$i--) | |
{ | |
$prefix="+".PadRight($commandStack.Count-1-$i,'-') | |
Write-Host ($prefix+$commandStack[$i]) | |
} | |
#> | |
#endregion | |
($commandStack -contains "Invoke-Pester") -or ($commandStack -contains "Describe") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you would enable the render section for troubleshooting it would look like this