Skip to content

Instantly share code, notes, and snippets.

@rleap-m
Last active October 24, 2024 21:15
Show Gist options
  • Save rleap-m/131921faac560a6bf84703e168788240 to your computer and use it in GitHub Desktop.
Save rleap-m/131921faac560a6bf84703e168788240 to your computer and use it in GitHub Desktop.
Seeing how this $MyInvocation PowerShell thing works.
Write-Host "`$MyInvocationInvocationName value is [$($MyInvocation.InvocationName)]"
Write-Host "`$MyInvocation.Line value is [$($MyInvocation.Line)]"
Write-Host "`$MyInvocation.Line is null? [$($null -eq $MyInvocation.Line)]"
Write-Host "`$MyInvocation.Line is empty string? [$('' -eq $MyInvocation.Line)]"
Write-Host
if (-Not ($MyInvocation.InvocationName -eq '.' -or $MyInvocation.Line -eq '')) {
Write-Host "I'm gonna run the installer!"
}
else {
Write-Host "Not going to run the installer. :-("
}
Write-Host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment