@Thangavel Daniel Tamilarasan In order to invoke script1.ps1
from mainscript.ps1
, you would have to source it first.
This would need you to make some modifications to your mainscript.ps1
script as follows:
Invoke-Expression ". $env:System_DefaultWorkingDirectory\script1.ps1"
$result = Invoke-Expression "getkey -param1 'Value1' -param2 'Value2'"
Write-Host "$result"
script1.ps1
:
function getkey ($param1, $param2)
{
# Compute $result
return $result
}
You will also notice that I've used the predefined system variable System.DefaultWorkingDirectory to reference the local path on the agent where your source code files are downloaded.
Then, you could use the built-in PowerShell task if you want to invoke mainscript.ps1 from your Azure DevOps pipeline.