【发布时间】:2019-08-01 14:06:04
【问题描述】:
我正在尝试做类似的事情。 第一个功能 第二个函数调用第一个函数并触发 Start-Job
示例:
Function CreateDeleteDirs {
Param(
[Parameter(
Mandatory = $True,
HelpMessage = 'Remote Path to create dirs on. Provide full path.')
]
[ValidateNotNullOrEmpty()]
[string]$RootPath
)
***do some stuffs***
}
Function CreateDeleteDirBack {
Param(
[Parameter(
Mandatory = $True,
HelpMessage = 'Remote Path to create dirs on. Provide full path.')
]
[ValidateNotNullOrEmpty()]
[string]$RootPath
)
$scriptBlock = {
param ($RootPath)
CreateDeleteDirs -RootPath $RootPath
}
Start-Job -ScriptBlock $scriptBlock -ArgumentList @($RootPath)
}
}
所以它总是从第二个函数调用 CreateDeleteDirs 失败.. 我该怎么做呢
确切的错误sn-p
PS C:\Program Files\WindowsPowerShell\Modules> CreateDeleteDirsBackground -RootPath Y:
Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
21 Job21 BackgroundJob Running True localhost ...
PS C:\Program Files\WindowsPowerShell\Modules> Receive-Job Job21
The term 'CreateDeleteDirs' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
+ CategoryInfo : ObjectNotFound: (CreateDeleteDirs:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName : localhost
PS C:\Program Files\WindowsPowerShell\Modules>
【问题讨论】:
-
我想在后台运行上面的函数 CreateDeleteDirs (直到外部杀死)。在独立中调用函数 CreateDeleteDirs 工作正常
-
CreateDeleteDirs与CreateDeleteDir;) -
对不起,我在这里输入错误,名称相同“CreateDeleteDirs”
标签: powershell