0
votes

The term 'AutomatedTest' is not recognized is a name of cmdlet......

but I don't know why.

But Powershell ISE works,

Function as below

if($DefaultPool.GetMachines().Name -eq $TestMachineOne)
 {
   MultiMachineTest
 }else{
   AutomatedTest
 }

function AutomatedTest()
{
   Write-host "test"
}
1
Move your function definition before your call. It works in ISE because you've already run your script, so the functions in memory from the previous run.JohnLBevan

1 Answers

1
votes

Add your function at the top of your script so that it's loaded before executing it.

function AutomatedTest()
{
   Write-host "test"
}

if($DefaultPool.GetMachines().Name -eq $TestMachineOne)
    {
       MultiMachineTest
    }else{
        AutomatedTest
    }