My name is Josh Einstein and I am a software engineer living in a Philadelphia suburb in southern New Jersey. I have spent the last 15 years developing applications on the Microsoft development stack. Most of my work experience has been in the telecommunications industry, but I also spent a good five years or so as a self-employed independent software vendor (ISV) and consultant. I developed applications for Tablet PC, enterprise VoIP, and SharePoint just to name a few of my favorite.
I’ll be posting various thoughts, rants, code, questions, etc here so feel free to check back from time to time.

Posts
Hello Josh,
I found your ConvertTo-Dictionary function, found it very smart, it works perfectly.
I can think of a thousand useful ways to use it.
That is why I wanted to put the function in a module of very useful functions.
But then….(after importing the module) the function doesn’t work anymore…
What a pity.
If the function is ‘declared’ in the same session, or if it is part of the same script as where it is used, everything is nice; but if it lives in the module definition it cannot be ‘called’ intact so it seems. The ‘$_’ does not keep its contents or so it seems.
1. Do you understand why?
2. Is there anything we can do?
I would hate it if I would have to dot-source it every time, or copy it into every script, isn’t that what modules are about (among other reasons).
In the meantime: Thanks for you interesting blogs.
Jacques Willemen, Breda, Netherlands
2010-02-24 @ 5:07 pm
Yes I know exactly what you are talking about. Modules have different scoping rules than global functions. I do have a workaround that I use in my LINQ.psm1 module for all of my “selectors” and “predicates”. I will try to post it tonight. It unfortunately involves reflection but it’s wrapped up in a nice cmdlet that can inject variables into the scope of any scriptblock.
2010-02-25 @ 5:58 pm
Okay Jacques, check out the LINQ.psm1 module in my SkyDrive at the following URL:
http://cid-89e05724af67a39e.skydrive.live.com/browse.aspx/PowerShell/Modules/LINQ?uc=2
There’s lots of useful stuff in there but pay particular attention to the Invoke-ScriptBlock function. Notice how it captures the current “underbar” variable, sets a new one, invokes the scriptblock, then restores the old underbar.
Invoke-ScriptBlock is used by practically every other function in that module and they all use the $_ (dollar underbar) syntax to refer to the current item.
I’d be thrilled if this winds up helping you because I literally scanned through thousands of lines of code in Reflector when PowerShell was in CTP just to figure out how to do this! It was extremely frustrating.
2010-02-25 @ 11:46 pm
Hi Josh,
First & short reaction (because it is very late already):
You solved my problem, if I use Linq-ToDictionary instead of ConvertTo-Dictionary the results are perfect (as far as I tested until now). I will write you more tomorrow.
2010-02-26 @ 8:19 pm
Hi Josh, me again,
I was a bit overwhelmed by your massive response to my seemingly simple question. Although of course I understand you did not create that Linq module just because of me. Interesting to find that one of the Powershell Big Guys is struggling with same obstacles as an amateur like me. Difference is, you are the one to find the most elegant kinds of solutions; and I am the one that has to try to understand what can be achieved with them.
I get the impression that Linq (never heard of…) is something I will find of interest (raised mathematician/logician, earning a living as a Windows SysAdmin).
Let’s google for linq.
I see that incidentally you published your LINQ module today, I hope I did not rush you.
Again, thanks a lot, and success further on….
2010-02-27 @ 5:29 pm
Hello Josh,
Josh, are you the same Josh Einstein that was a Tablet PC MVP back in 2007 ????
Could you comment on the following. If you don’t have the time, do you know who
might be able to comment on this?
http://www.tabletpcquestions.com/showthread.php?189984-portrait-screen-calibration-180-degrees-off-%28Gateway-M280E%29
Thanks much
2010-05-04 @ 10:40 pm