I have a powershell script that runs a custom cmdlet. It is run by Task Scheduler and I want to log what it does.
This is my current crude version:
Add-PsSnapIn MyCmdlets Write-EventLog -LogName "Windows Powershell" -Source "Powershell" -Message "Starting Update-ClubNumbers" -EventId 0 Get-ClubMembers -HasTemporaryNumber -show all | Update-ClubNumbers -Verbose Write-EventLog -LogName "Windows Powershell" -Source "Powershell" -Message "Finished Update-ClubNumbers" -EventId 0
What I would like to do is log the output of my custom cmdlet. Ideally I'd like to create different types of event log entries based on whether it was a warning or a verbose message.
Update: I don't want to log the return value of the commandlet. The Update-ClubMembers cmdlet does not return an object. I want to log any verbose messages written by WriteVerbose and I want to log errors created by ThrowTerminatingError.