We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider this Parent.ps1:
Parent.ps1
$script = Join-Path -Path $PSScriptRoot -ChildPath 'Child.ps1' & $script -arg 'somearg'
that invokes this Child.ps1:
Child.ps1
param([string] $arg) Write-Host("Child.ps1 called with '-arg $arg'")
Running Parent.ps1 (expectedly) yields:
Child.ps1 called with '-arg somearg'
but Measure-Script -Path Parent.ps1 fails:
Measure-Script -Path Parent.ps1
Measure-Script : Cannot bind argument to parameter 'Path' because it is an empty string. At line:1 char:1 + Measure-Script -path ../Parent.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Measure-Script], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Measure-Script
The text was updated successfully, but these errors were encountered:
Thanks for reporting this @sba923!
This is due to how we "rewrite" the AST in-memory, so by the time we execute it, it's no longer actually a script.
We might be able to inject meaningful $PSScriptRoot/$PSCommandPath vars, but $MyInvocation will still not reflect the original script (just FYI)
$PSScriptRoot/$PSCommandPath
$MyInvocation
Sorry, something went wrong.
This is fixed in #8
No branches or pull requests
Consider this
Parent.ps1
:that invokes this
Child.ps1
:Running
Parent.ps1
(expectedly) yields:but
Measure-Script -Path Parent.ps1
fails:The text was updated successfully, but these errors were encountered: