powershell - Conditional loading of snapins in profile -
we have internal application utilizes powershell. in profile (microsoft.powershell_profile.ps1) have added references various snap-ins we've created:
# # profile joe blow # add-pssnapin companysnapin add-pssnapin powershelltesttools add-pssnapin sqlservercmdletsnaps -erroraction silentlycontinue
the problem i'm having when start internal application, above lines of code, throw errors.
my question is, there way (in profile script) can test or trying open profile , things accordingly ?
example might be:
if (!internalapplication) { add-pssnapin companysnapin add-pssnapin powershelltesttools add-pssnapin sqlservercmdletsnaps -erroraction silentlycontinue }
so snapins if launch powershell command line utility. otherwise, nothing "added".
thanks !
it depends on custom app/ host implementation, really. means there @ least few ways skin cat.
you can start checking if $host.name
differs. next - check if properties present/ set (like $host.ui.rawui.backgroundcolor
).
once know difference - need put code causes issues in if {} else {}
, should go.
Comments
Post a Comment