1

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"
}
mellifluous
  • 2,345
  • 2
  • 29
  • 45
  • `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: https://stackoverflow.com/questions/7834656/create-log-file-in-powershell – Riley Carney Jun 18 '20 at 03:05

0 Answers0