Last active
January 23, 2016 14:00
-
-
Save jhochwald/528d824f15673545655f to your computer and use it in GitHub Desktop.
$MyInvocation vs. Sapien PowerShell Studio
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
<# | |
$MyInvocation vs. Sapien PowerShell Studio | |
Sorry, $MyInvocation is empty if you compile the Script! | |
This is a Workaround, that checks $host.Name and use | |
the Sapien Variant $HostInvocation instead. | |
#> | |
if ($host.Name -eq 'PrimalScriptHostImplementation') { | |
$Global:MyRunPath = (Split-Path -Parent $HostInvocation.MyCommand.Path) | |
$Global:MyScriptName = ($HostInvocation.mycommand.name) | |
$Global:MyRunName = (([io.fileinfo]$HostInvocation.MyCommand.Definition).BaseName) | |
} else { | |
$Global:MyRunPath = (Split-Path -Parent $MyInvocation.MyCommand.Path) | |
$Global:MyScriptName = ($MyInvocation.mycommand.name) | |
$Global:MyRunName = (([io.fileinfo]$MyInvocation.MyCommand.Definition).BaseName) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment