I am passing a powershell script through userdata to terraform ec2 windows instance, should I use Write-Host or Write-Output, so that the output from the script gets written to the execution log file.
if (!(Test-Path -Path $outputFile)) {
  Write-Warning "$outputFile does not exist`r`n"
}
else {
  Write-Host "$outputFile exists`r`n"
}
so that the output from the script gets written to the execution log file.is a loaded question. Are you looking for something similar to:https://www.powershellgallery.com/packages/ScriptLogger/1.1.1/Content/Functions%5CWrite-Log.ps1? If you want a less complicated version: stackoverflow.com/questions/7834656/…