Write PowerShell Output To Text File

Here is an example of how I use the Write-Output command to log every update my PowerShell script made.

$items = $list.Items

$output = foreach ($item in $items)
Write-Host "Updating" $item["FileLeafRef"]
Write-Output "Updating" $item["FileLeafRef"]

$item["Status"] = "Active"
$output | Out-File E:\SharePoint\PSUpdateStatus.txt

The $output variable needs to wrap the collection of items being updated (the foreach statement) if you want to combine all outputs into the same file. Then use the Write-Output function to state what needs to logged.