I have a problem with using a functions from file in a scriptblock.
Function file name: functions.ps1
.
I'm prefering using functions in a file and normally it's works. But in a scriptblock which I'm using for jobs I have errors. Can you help me with using functions in a scriptblock?
. .\functions.ps1
$ip = "10.0.0.24"
$scriptblock = { get-ostype -ip $args[0] }
Start-Job -name "name" -ScriptBlock $scriptblock -ArgumentList $ip
Error from a job:
The term 'get-ostype' 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: (get-ostype:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException + PSComputerName : localhost