I'm using a powershell script to execute a terraform command, and when I have it inline with my code, I get terraform info printed to the host, which is what I want.
Once I wrapped the command in a function, I'm not getting the terraform output (only get the error response if there is one).
Is there a way to get the output to return from the function in real time (so I'm not sitting around wondering what is happening)?
EX:
Terraform init
vs
Function Example
{
PARAM($dirPath)
cd $dirPath
terraform init
}
Example -dirPath "C:\Test\"
Additionally, is there a way to actually capture if there is an error in the terraform response and halt the script? I've already set erroractionpreference = 'Stop' but that doesn't seem to capture the terraform error.