Call PowerShell script PS1 from another PS1 script inside Powershell ISE

后端 未结 11 1085
伪装坚强ぢ
伪装坚强ぢ 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:03

    To execute easily a script file in the same folder (or subfolder of) as the caller you can use this:

    # Get full path to the script:
    $ScriptRoute = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, "Scriptname.ps1"))
    
    # Execute script at location:
    &"$ScriptRoute"
    

提交回复
热议问题