Most of this produced a wonderful cry when it passed right above my head ... ಠ_ಠ
I'm with Dan. PS Logging is a complete mess and it seems that it will be more than twice the size of the code I write ...
Honestly, I would be happy if I could just grab the console output directly into the logs, warts and all ...
The Try / Catch block is so ... so ... crappy, I smell it, and it made my eyes catch fire.
$? very interesting, but you guys really know what you are doing, where I am at the point where I realized that I didn’t know anything (last week I thought I knew at least something, but noooooo).
Why does% $ # @% $ not have something like 2> in cli ...
So here is what I am trying to do (you have read this far, so why not?):
Function MyFunc($Param1, $Param2){ Do{ $Var = Get-Something | Select Name, MachineName, Status $NotherVar = Read-Host -Prompt "Do you want to Stop or Start or check the $Var (1 to Start, 2 to stop, 3 to check, 4 to continue)?" If ($SetState -eq 1) { Do Stuff } ElseIf ($Var -eq 2) { Do Stuff } ElseIf ($Var -eq 3) { Do Stuff } } Until ($Var -eq 4) Do other stuff }
Did it work? Yes, great ... Write it down and continue. Not? Then catch the error, write it down and continue the script ...
I am tempted to simply ask to enter the user, add content and continue ...
By the way, I found the PSLogging module, which seems like it will be pretty cool, but I'm not sure how to make it work ... The documentation is a bit spartan. It seems that people make him work without any problems, so I seem to feel that I am a corner sitting in a narrow hat, a man ...