Call PowerShell script PS1 from another PS1 script inside Powershell ISE

后端 未结 11 1077
伪装坚强ぢ
伪装坚强ぢ 2020-12-12 15:27

I want call execution for a myScript1.ps1 script inside a second myScript2.ps1 script inside Powershell ISE.

The following code inside MyScript2.ps1, works fine from

11条回答
  •  北海茫月
    2020-12-12 16:08

    I had a problem with this. I didn't use any clever $MyInvocation stuff to fix it though. If you open the ISE by right clicking a script file and selecting edit then open the second script from within the ISE you can invoke one from the other by just using the normal .\script.ps1 syntax. My guess is that the ISE has the notion of a current folder and opening it like this sets the current folder to the folder containing the scripts. When I invoke one script from another in normal use I just use .\script.ps1, IMO it's wrong to modify the script just to make it work in the ISE properly...

提交回复
热议问题