I am trying to do something similar to this. First function Second function calls first function and trigger a Start-Job
example:
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)
}
}
So its always failing with calling CreateDeleteDirs from second function .. how can I do this
The exact error snippet
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>