Include script not working when the powershell script is invoked from C# -


i have power shell script has include script in below.

. "$psscriptroot\checkpermissions.ps1" 

when script invoked c#, getting error

{the term '\checkpermissions.ps1' not recognized name of cmdlet, function, script file, or operable program. check spelling of name, or if path included, verify path correct , try again.}

the script works fine when run ps window.

is not $psscriptroot variable available when script run c#?

you try using following script directory:

$scriptdir = split-path $script:myinvocation.mycommand.path 

note folder path returned end backslash (\).


Comments