There's a question on this already (here). But I'm hoping that because I'm using PowerShell 2, and SQL Server 2008, that I might get different answers if I ask again.
Basically, I have a SQL Server Agent job, which runs a cmd script like so:
powershell "&D:\SQL\Job\JobDir\Upload.ps1 (various arguments including log file name)"
When it runs start-transcript, the file is created, but nothing except a header is written to the file. However, when I run on the command line, everything is logged properly.
I've already got lots of logic to manage old log files in the powershell script, and don't want to just use the default logging that SQL Server Agent provides.
To write out info, I use invoke-sqlcmd with the verbose flag, and also write-message and write-error.
Thanks for any pointers! Sylvia