Powershell远程:具有嵌套功能的功能

问题描述 投票:0回答:1

我是Powershell的新手,并且有一个关于远程的问题。

我有一个脚本。ps1

我的脚本可以这样显示:

function Begin{

#Step 1 : 
StartTodoSometing

#Step2 :
KeepDooingSomething

}

function StartTodoSometing{}

function KeepDoingSomething{}

此脚本可以在本地服务器或多个远程服务器上运行。

嵌套函数StartTodoSometing和KeepDoingSomething是公共的,因此我不能将其放在“ Begin”函数中。

我的问题是,如何在远程计算机上运行“开始”功能???

感谢您的帮助!!! :)

powershell powershell-remoting
1个回答
0
投票

我不知道您对public的意思,但是如果它是文件共享或任何其他内容,则您应该可以使用以下内容:

function Begin{
. .\POWERSHELLSCRIPT\LOCATION\StartTodoSometing.ps1
. .\POWERSHELLSCRIPT\LOCATION\KeepDoingSomething.ps1

#Step 1 : 
StartTodoSometing

#Step2 :
KeepDooingSomething   
}
© www.soinside.com 2019 - 2024. All rights reserved.