May 2010 Entries

Powershell variables to string

I'm new to powershell. I'm trying to write an error handler to wrap around my script. Part of the error handler is dumping out some variable settings. I spent a while trying to do this and couldn't google a complete solution so I thought I'd post something. I want to display the $myinvocation variable. In powershell you can do this PS C:\> $myInvocation for my purpose I want to create a stringbuilder object and append the $myinvocation info. I tried this $sbOut = new-object System.Text.Stringbuilder ......