<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Creating arbitrary delegates from scriptblocks in PowerShell...</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx</link><description>People have been asking about creating arbitrary delegates out of scriptblocks. As Jeffrey has mentioned, this isn't directly supported in V1.0 of PowerShell. It is, however, possible to do it using dynamic methods and the CreateDelegate call. Here's</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Interesting Finds: July 25, 2007</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx#678536</link><pubDate>Wed, 26 Jul 2006 06:10:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:678536</guid><dc:creator>Jason Haley</dc:creator><description /></item><item><title>re: Creating arbitrary delegates from scriptblocks in PowerShell...</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx#678705</link><pubDate>Wed, 26 Jul 2006 10:09:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:678705</guid><dc:creator>Scott Yost</dc:creator><description>The example worked great for me, but when I tried to make my own System.Net.Security.RemoteCertificateValidationCallback , it gets created okay but fails with &amp;quot;Invalid class token&amp;quot; whenever the delegate is invoked. </description></item><item><title>re: Creating arbitrary delegates from scriptblocks in PowerShell...</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx#679452</link><pubDate>Thu, 27 Jul 2006 00:00:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:679452</guid><dc:creator>PowerShellTeam</dc:creator><description>I missed the type argument to the box instruction which was causing this problem. The script has been updated. I tried it with your example and it seems to work properly now.&lt;br&gt;&lt;br&gt;-bruce&lt;br&gt;&lt;br&gt;Bruce Payette [MSFT]&lt;br&gt;PowerShell Tech Lead</description></item><item><title>re: Creating arbitrary delegates from scriptblocks in PowerShell...</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx#679828</link><pubDate>Thu, 27 Jul 2006 07:40:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:679828</guid><dc:creator>Scott Yost</dc:creator><description>Thank you - works great now!</description></item><item><title>re: Creating arbitrary delegates from scriptblocks in PowerShell...</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx#684394</link><pubDate>Mon, 31 Jul 2006 22:21:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:684394</guid><dc:creator>Johnl</dc:creator><description>Sorry if this is slightly off-topic, but I was wondering where we could submit requests for articles?&lt;br&gt;&lt;br&gt;I'd very much like to see an article about creating dynamic types (I belive this involves the add-noteproperty function?).&lt;br&gt;&lt;br&gt;Thanks, and keep up the good work</description></item><item><title>re: Creating arbitrary delegates from scriptblocks in PowerShell...</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx#684486</link><pubDate>Tue, 01 Aug 2006 00:03:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:684486</guid><dc:creator>Jeffrey Snover</dc:creator><description>&amp;gt; I was wondering where we could submit requests for articles? &lt;br&gt;&lt;br&gt;We read all the comments so feel free to post a request here.&lt;br&gt;&lt;br&gt;Jeffrey Snover [MSFT]&lt;br&gt;Windows PowerShell/Aspen Architect&lt;br&gt;Visit the Windows PowerShell Team blog at: &amp;nbsp; &amp;nbsp;&lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/PowerShell"&gt;http://blogs.msdn.com/PowerShell&lt;/a&gt;&lt;br&gt;Visit the Windows PowerShell ScriptCenter at: &amp;nbsp;&lt;a rel="nofollow" target="_new" href="http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx"&gt;http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx&lt;/a&gt;</description></item><item><title>A templating engine using PowerShell expressions</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx#1387174</link><pubDate>Sun, 31 Dec 2006 04:40:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1387174</guid><dc:creator>Serge van den Oever [Macaw]</dc:creator><description>&lt;p&gt;While working on our Software Factory for SharePoint 2007 solutions I needed to do some simple template&lt;/p&gt;
</description></item><item><title>re: Creating arbitrary delegates from scriptblocks in PowerShell...</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx#1387208</link><pubDate>Sun, 31 Dec 2006 04:57:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1387208</guid><dc:creator>svdoever</dc:creator><description>&lt;p&gt;Thanks for your great code, you saved my day! I used it to create a simple template engine with PowerShell expression expansion. Have a look at &lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/powershell/archive/2006/07/25/678259.aspx"&gt;http://blogs.msdn.com/powershell/archive/2006/07/25/678259.aspx&lt;/a&gt;&lt;/p&gt;</description></item><item><title>re: Creating arbitrary delegates from scriptblocks in PowerShell...</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx#2628388</link><pubDate>Mon, 14 May 2007 19:26:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2628388</guid><dc:creator>Stefan Koell</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;can someone explain how this works exactly. I need to create a SSLStream and must provide a callback method in the constructor and I really cannot find out how to use your example to do that. Can you provide some detailed instructions?&lt;/p&gt;
&lt;p&gt;cheers&lt;/p&gt;</description></item><item><title>re: Creating arbitrary delegates from scriptblocks in PowerShell...</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx#2958728</link><pubDate>Tue, 29 May 2007 07:22:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2958728</guid><dc:creator>Omid</dc:creator><description>&lt;p&gt;Is it possible to pass a powershell function as a delegate parameter to a .NET method?&lt;/p&gt;</description></item><item><title>re: Creating arbitrary delegates from scriptblocks in PowerShell...</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx#3675568</link><pubDate>Tue, 03 Jul 2007 23:17:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3675568</guid><dc:creator>Pangos</dc:creator><description>&lt;p&gt;You updated the script on the page, but not in the attachment. &amp;nbsp;If you use this utility, be sure to use version on the Blog page.&lt;/p&gt;</description></item><item><title>re: Creating arbitrary delegates from scriptblocks in PowerShell...</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx#6734610</link><pubDate>Tue, 11 Dec 2007 15:36:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6734610</guid><dc:creator>Colin Bowern</dc:creator><description>&lt;p&gt;I'm trying to create a Predicate using this method but the result isn't correct:&lt;/p&gt;
&lt;p&gt;$domains = New-Object &amp;quot;System.Collections.Generic.List``1[System.String]&amp;quot;;&lt;/p&gt;
&lt;p&gt;$domains.Add(&amp;quot;foo.com&amp;quot;);&lt;/p&gt;
&lt;p&gt;$uri = New-Object System.Uri(&amp;quot;&lt;a rel="nofollow" target="_new" href="http://bar.com&amp;quot;"&gt;http://bar.com&amp;quot;&lt;/a&gt;);&lt;/p&gt;
&lt;p&gt;$delegate = get-delegate &amp;quot;System.Predicate``1[System.String]&amp;quot; { Write-Host $uri.Host &amp;quot; : &amp;quot; $args &amp;quot; = &amp;quot; ([String]::Compare($uri.Host, $args[0], $true) -eq 0); return ([String]::Compare($uri.Host, $args[0], $true) -eq 0); };&lt;/p&gt;
&lt;p&gt;$domains.Exists($delegate);&lt;/p&gt;
&lt;p&gt;The call to Exists returns true even though bar.com isn't in the collection.&lt;/p&gt;
&lt;p&gt;Thoughts on how where I'm going wrong?&lt;/p&gt;</description></item><item><title>re: Creating arbitrary delegates from scriptblocks in PowerShell...</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx#6801742</link><pubDate>Wed, 19 Dec 2007 05:31:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6801742</guid><dc:creator>Yuhong Bao</dc:creator><description>&lt;p&gt;Can you use this to create a thread using PowerShell?&lt;/p&gt;</description></item><item><title>re: Creating arbitrary delegates from scriptblocks in PowerShell...</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx#7005798</link><pubDate>Sun, 06 Jan 2008 16:17:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7005798</guid><dc:creator>Richard</dc:creator><description>&lt;p&gt;Cool script, but crashs PowerShell with the following:&lt;/p&gt;
&lt;p&gt;PS E:\&amp;gt; $d = &amp;amp;get-delegate System.Threading.WaitCallback `&lt;/p&gt;
&lt;p&gt;&amp;gt;&amp;gt; {&lt;/p&gt;
&lt;p&gt;&amp;gt;&amp;gt; echo $args[0]&lt;/p&gt;
&lt;p&gt;&amp;gt;&amp;gt; }&lt;/p&gt;
&lt;p&gt;&amp;gt;&amp;gt;&lt;/p&gt;
&lt;p&gt;PS E:\&amp;gt; [System.Threading.ThreadPool]::QueueUserWorkItem ($d, &amp;quot;test&amp;quot;)&lt;/p&gt;</description></item><item><title>re: Creating arbitrary delegates from scriptblocks in PowerShell...</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx#7821405</link><pubDate>Wed, 20 Feb 2008 21:02:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7821405</guid><dc:creator>Nikolaus Rollinger</dc:creator><description>&lt;p&gt;I've detected the same problem as already posted by Colin Bowern.&lt;/p&gt;
&lt;p&gt;Is this not important enough to give it your attention?&lt;/p&gt;
&lt;p&gt;Hey, Jeff and Bruce, give it the necessary &amp;nbsp;attention, please. Don't forget we are your customers!&lt;/p&gt;
&lt;p&gt;I hope this helps!&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;</description></item><item><title>re: Creating arbitrary delegates from scriptblocks in PowerShell...</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx#8396816</link><pubDate>Tue, 15 Apr 2008 10:01:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8396816</guid><dc:creator>Brian Peiris</dc:creator><description>&lt;p&gt;I'd like to see a solution to Colin's problem myself. I've been trying to solve it for a while now, but the IL is over my head.&lt;/p&gt;</description></item><item><title>xion.log &amp;raquo; Triki z PowerShellem #1</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx#8507877</link><pubDate>Thu, 15 May 2008 15:41:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8507877</guid><dc:creator>xion.log &amp;raquo; Triki z PowerShellem #1</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://xion.org.pl/2008/05/15/triki-z-powershellem-1/"&gt;http://xion.org.pl/2008/05/15/triki-z-powershellem-1/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>DynamicMethod revisited: Making Powershell handle arbitrary delegates | Developer Home</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx#8534740</link><pubDate>Fri, 23 May 2008 01:23:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8534740</guid><dc:creator>DynamicMethod revisited: Making Powershell handle arbitrary delegates | Developer Home</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://www.wowgoldip.com/2008/05/22/dynamicmethod-revisited-making-powershell-handle-arbitrary-delegates/"&gt;http://www.wowgoldip.com/2008/05/22/dynamicmethod-revisited-making-powershell-handle-arbitrary-delegates/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Creating arbitrary delegates from scriptblocks in PowerShell...</title><link>http://blogs.msdn.com/powershell/archive/2006/07/25/creating-arbitrary-delegates-from-scriptblocks-in-powershell.aspx#9923963</link><pubDate>Wed, 18 Nov 2009 00:05:39 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9923963</guid><dc:creator>Serge van den Oever</dc:creator><description>&lt;p&gt;This code breaks on PowerShell 2. Are arbitrary delegates supported by PowerShell 2.0 out of the box?&lt;/p&gt;</description></item></channel></rss>