Answer the question
In order to leave comments, you need to log in
Can I call my function from a script in Invoke-Command?
Those. there is a ps1 script, it has a TestFunc function and a call to this function
Invoke-Command -ComputerName 192.168.0.1 -ScriptBlock {(TestFunc "test")}
Answer the question
In order to leave comments, you need to log in
here, it seems, in detail:
duffney.io/RunLocalFunctionsRemotely
function MyFunction ()
{
Write-Host 'Hello, World!'
}
Invoke-Command -ComputerName DC1 -ScriptBlock ${Function:MyFunction}
Or here
The FilePath parameter specifies a script that is located on the local computer. The script runs on the remote computer and the results are returned to the local computer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question