Set-BoxstarterConfig seems to redirect PowerShell output

Sep 8, 2014 at 9:00 PM
So we've been running into some errors lately with our scripts, specifically (and at very random times) an exception is thrown because the BoxStarter.log file (in C:\Users[InstalledUnderUsername]\AppData\Local\Boxstarter) is locked due to multiple threads trying to write to it at the same time. At first seemed extremely odd because folks were running PowerShell scripts that had absolutely nothing to do with BoxStarter. After a fair amount of digging I was able to determine that the following call was causing BoxStarter to echo all PowerShell output to the file:
Set-BoxstarterConfig -LocalRepo "[\\OurInternal\boxStarterRepo"]
If I make sure none of our scripts call this then the issue never occurs.

Question 1: What is causing the redirect to happen (unless I'm missing something I can't find anything in the BoxStarter f() that would cause that behavior)?

Question 2: Does this function need to be called more than once (i.e. after BoxStarter is installed, after a machine has rebooted, in new sessions, etc.)?

Question 3: If yes to question 2, how do I prevent BoxStarter from opening and writing everything to the log file anytime Set-BoxStarterConfig is called?

Thanks in advance!

Sep 9, 2014 at 3:20 PM
I do think this is a bug with the logging and related to the way boxstarter "hijacks" write-host. It does not propperly stop. I'll look closer but it seems odd to me that changing the LocalRepo is related. This does seem like an important bug and I'll get a fix out this week.

Thanks for reporting!
Sep 9, 2014 at 3:20 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Sep 9, 2014 at 5:38 PM
Seemed odd to me as well, esp. after looking at the code in that script, but running it is the only thing (outside of my non-Boxstarter related code) causing the hijacking to begin again. Very odd.

In terms of my second question, is that script one that only needs to be called once on a machine or should it be used anytime BoxStarter is used in a new session against our internal package store?
Sep 9, 2014 at 8:06 PM
It only needs to be run once on a machine. One reason why it may be the "perceived" culprit is if it is the first boxstarter command issued it is then triggering powershell's module auto logging and then initiating the write-host hooks.
Sep 12, 2014 at 3:36 PM
Just released what I believe is a fix. Let me know if this fixes for you or not.
Oct 2, 2014 at 5:33 PM
Is there a straight forward way to turn BoxStarter logging off and on?
Oct 3, 2014 at 2:35 AM
Yes. There is a boolean $boxstarter.SuppressLogging setting but that will just turn off logging to the console. I'm assuming you want to turn it off to the lo file. If you set $boxstarter.log to $null that should effectively turn off file logging.