<?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>$MindWarpingPower = $Cmdlets + $ScriptBlock_Parameters</title><link>http://blogs.msdn.com/powershell/archive/2008/04/21/mindwarpingpower-cmdlets-scriptblock-parameters.aspx</link><description>A while ago I blogged about the power of Flexible Pipeling Scriptblock parameters .&amp;#160; The mechanics of this are quite simple:&amp;#160; In a pipeline environment, if you provide a SCRIPTBLOCK to a parameter which does not take a SCRIPTBLOCK or an OBJECT,</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Microsoft news and tips &amp;raquo; $MindWarpingPower = $Cmdlets + $ScriptBlock_Parameters</title><link>http://blogs.msdn.com/powershell/archive/2008/04/21/mindwarpingpower-cmdlets-scriptblock-parameters.aspx#8413205</link><pubDate>Mon, 21 Apr 2008 03:10:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8413205</guid><dc:creator>Microsoft news and tips &amp;raquo; $MindWarpingPower = $Cmdlets + $ScriptBlock_Parameters</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://microsoftnews.askpcdoc.com/?p=3373"&gt;http://microsoftnews.askpcdoc.com/?p=3373&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: $MindWarpingPower = $Cmdlets + $ScriptBlock_Parameters</title><link>http://blogs.msdn.com/powershell/archive/2008/04/21/mindwarpingpower-cmdlets-scriptblock-parameters.aspx#8414486</link><pubDate>Mon, 21 Apr 2008 15:05:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8414486</guid><dc:creator>Roman Kuzmin</dc:creator><description>&lt;p&gt;It is a great idea to promulgate this. It seems to me that most of PowerShell users including fanatics never heard about this technique.&lt;/p&gt;
&lt;p&gt;Will it work in the same way for script cmdlets?&lt;/p&gt;</description></item><item><title>re: $MindWarpingPower = $Cmdlets + $ScriptBlock_Parameters</title><link>http://blogs.msdn.com/powershell/archive/2008/04/21/mindwarpingpower-cmdlets-scriptblock-parameters.aspx#8414505</link><pubDate>Mon, 21 Apr 2008 15:33:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8414505</guid><dc:creator>PowerShellTeam</dc:creator><description>&lt;p&gt;&amp;gt; Will it work in the same way for script cmdlets?&lt;/p&gt;
&lt;p&gt;It doesn't right now but it should.&lt;/p&gt;
&lt;p&gt;Jeffrey Snover [MSFT]&lt;/p&gt;
&lt;p&gt;Windows Management Partner Architect&lt;/p&gt;
&lt;p&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;/p&gt;
&lt;p&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;&lt;/p&gt;
</description></item><item><title>re: $MindWarpingPower = $Cmdlets + $ScriptBlock_Parameters</title><link>http://blogs.msdn.com/powershell/archive/2008/04/21/mindwarpingpower-cmdlets-scriptblock-parameters.aspx#8416517</link><pubDate>Tue, 22 Apr 2008 16:22:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8416517</guid><dc:creator>Don Jones</dc:creator><description>&lt;p&gt;Pingback from &lt;a rel="nofollow" target="_new" href="http://blog.sapien.com/index.php/2008/04/22/scriptblocks-as-cmdlet-parameter-values/"&gt;http://blog.sapien.com/index.php/2008/04/22/scriptblocks-as-cmdlet-parameter-values/&lt;/a&gt;&lt;/p&gt;</description></item><item><title>re: $MindWarpingPower = $Cmdlets + $ScriptBlock_Parameters</title><link>http://blogs.msdn.com/powershell/archive/2008/04/21/mindwarpingpower-cmdlets-scriptblock-parameters.aspx#8416755</link><pubDate>Tue, 22 Apr 2008 19:02:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8416755</guid><dc:creator>karl prosser</dc:creator><description>&lt;p&gt;this here therefore sets the parameter to a different value each time an item comes through the pipeline despite the fact that the cmdlet gets called only once?&lt;/p&gt;
&lt;p&gt;Thus it will only behave correctly for cmdlets that read the parameter each item, rather than just reading it in the beginprocess section?&lt;/p&gt;
&lt;p&gt;-Karl&lt;/p&gt;</description></item><item><title>re: $MindWarpingPower = $Cmdlets + $ScriptBlock_Parameters</title><link>http://blogs.msdn.com/powershell/archive/2008/04/21/mindwarpingpower-cmdlets-scriptblock-parameters.aspx#8416836</link><pubDate>Tue, 22 Apr 2008 19:41:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8416836</guid><dc:creator>vbNullString</dc:creator><description>&lt;p&gt;I have been personally evangelizing PowerShell at work and also on my blog for a while now. The more I dig into PowerShell, the more I realize how powerful it is and it will change the face of shell world.&lt;/p&gt;
&lt;p&gt;So I made a PowerShell cap.&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://www.devslife.com/2008/04/20/powershell帽/"&gt;http://www.devslife.com/2008/04/20/powershell帽/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Though I blog in Japanese, I live near Seattle. If you see me wearing the cap, please say hi to me! :)&lt;/p&gt;</description></item><item><title>re: $MindWarpingPower = $Cmdlets + $ScriptBlock_Parameters</title><link>http://blogs.msdn.com/powershell/archive/2008/04/21/mindwarpingpower-cmdlets-scriptblock-parameters.aspx#8418688</link><pubDate>Wed, 23 Apr 2008 12:30:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8418688</guid><dc:creator>Maximilian Hänel</dc:creator><description>&lt;p&gt;@karl &lt;/p&gt;
&lt;p&gt;I haven't tried it, but I don't think scriptblock parameters are much different from pipline parameters. So I guess you have to re-read the parameter for each item in the pipline. &lt;/p&gt;
&lt;p&gt;The alternative would be that your CmdLets Begin/Bla/Process methods are called for each pipline item in the case of scriptblock parameters being present. But then your CmdLet would behave rather different in those two scenarios (think about measure-object), so I don't think it works that way.&lt;/p&gt;</description></item><item><title>re: $MindWarpingPower = $Cmdlets + $ScriptBlock_Parameters</title><link>http://blogs.msdn.com/powershell/archive/2008/04/21/mindwarpingpower-cmdlets-scriptblock-parameters.aspx#8420320</link><pubDate>Thu, 24 Apr 2008 03:46:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8420320</guid><dc:creator>Oisin Grehan</dc:creator><description>&lt;p&gt;uh.. never heard of this.. madness. Does this work for v1.0 ? (only have v2 ctp here).&lt;/p&gt;</description></item><item><title>re: $MindWarpingPower = $Cmdlets + $ScriptBlock_Parameters</title><link>http://blogs.msdn.com/powershell/archive/2008/04/21/mindwarpingpower-cmdlets-scriptblock-parameters.aspx#8420557</link><pubDate>Thu, 24 Apr 2008 06:12:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8420557</guid><dc:creator>PowerShellTeam</dc:creator><description>&lt;p&gt;&amp;gt; Does this work for v1.0 ?&lt;/p&gt;
&lt;p&gt;Yes.&lt;/p&gt;
&lt;p&gt;Jeffrey Snover [MSFT]&lt;/p&gt;
&lt;p&gt;Windows Management Partner Architect&lt;/p&gt;
&lt;p&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;/p&gt;
&lt;p&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;&lt;/p&gt;
</description></item><item><title>re: $MindWarpingPower = $Cmdlets + $ScriptBlock_Parameters</title><link>http://blogs.msdn.com/powershell/archive/2008/04/21/mindwarpingpower-cmdlets-scriptblock-parameters.aspx#8424950</link><pubDate>Sat, 26 Apr 2008 02:48:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8424950</guid><dc:creator>sbq</dc:creator><description>&lt;p&gt;This sounds a lot like what I did with my AD mail enabled object dump scripts. &amp;nbsp;Being an old crusty Exchange admin I've learned that it's nice to have a directory dump that you can refer back to from time to time, I came up with something like this when Powershell came out and I started using it (abbreviated and sanitized):&lt;/p&gt;
&lt;p&gt;$date = get-date -format yyyyMMdd&lt;/p&gt;
&lt;p&gt;$fname = &amp;quot;userDump-&amp;quot; + $date + &amp;quot;.csv&amp;quot;&lt;/p&gt;
&lt;p&gt;$domain = New-Object System.DirectoryServices.DirectoryEntry&lt;/p&gt;
&lt;p&gt;$DN1 = (get-content Z:\Directory\UserDump\DN-import.txt)&lt;/p&gt;
&lt;p&gt;$DN2 = $DN1 | foreach {&lt;/p&gt;
&lt;p&gt;$domain.PSBase.Children.find($_)&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;filter Format-DumpADUser {&lt;/p&gt;
&lt;p&gt;$_ | select @{name='distinguishedName';Expression={$_.distinguishedName} },&lt;/p&gt;
&lt;p&gt;@{ name='homeMDB'; Expression={$_.homeMDB} },&lt;/p&gt;
&lt;p&gt;@{ name='displayName'; Expression={$_.displayName} },&lt;/p&gt;
&lt;p&gt;@{ name='mail'; Expression={$_.mail} },&lt;/p&gt;
&lt;p&gt;@{ name='proxyAddresses'; Expression={$_.proxyAddresses} },&lt;/p&gt;
&lt;p&gt;@{ name='memberOf'; Expression={$_.memberOf} },&lt;/p&gt;
&lt;p&gt;@{ name='whenChanged'; Expression={$_.whenChanged} },&lt;/p&gt;
&lt;p&gt;@{ name='whenCreated'; Expression={$_.whenCreated} },&lt;/p&gt;
&lt;p&gt;@{ name='extensionAttribute1'; Expression={$_.extensionAttribute1} },&lt;/p&gt;
&lt;p&gt;@{ name='mailNickname'; Expression={$_.mailNickname} },&lt;/p&gt;
&lt;p&gt;@{ name='mDBUseDefaults'; Expression={$_.mDBUseDefaults} },&lt;/p&gt;
&lt;p&gt;@{ name='mDBOverQuotaLimit'; Expression={$_.mDBOverQuotaLimit} },&lt;/p&gt;
&lt;p&gt;@{ name='mDBStorageQuota'; Expression={$_.mDBStorageQuota} }&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;$DN2 | foreach {&lt;/p&gt;
&lt;p&gt;$_.PSBase.Children&lt;/p&gt;
&lt;p&gt;} | Format-DumpADUser | export-csv -NoTypeInformation Z:\Directory\Archive\$fname&lt;/p&gt;</description></item><item><title>re: $MindWarpingPower = $Cmdlets + $ScriptBlock_Parameters</title><link>http://blogs.msdn.com/powershell/archive/2008/04/21/mindwarpingpower-cmdlets-scriptblock-parameters.aspx#8434832</link><pubDate>Mon, 28 Apr 2008 11:35:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8434832</guid><dc:creator>Shay</dc:creator><description>&lt;p&gt;I have a case where a scriptblock parameter is evaluated literally:&lt;/p&gt;
&lt;p&gt;Get-DistributionGroup | Set-DistributionGroup -DisplayName {&amp;quot;~$($_.name)&amp;quot;}&lt;/p&gt;
&lt;p&gt;The name of the groups are updated with: &amp;quot;~$($_.name)&amp;quot;. &lt;/p&gt;
&lt;p&gt;Could it be because -DisplayName is a dynamic parameter?&lt;/p&gt;
&lt;p&gt;Here is the The relevant trace-command output:&lt;/p&gt;
&lt;p&gt;DEBUG: ParameterBinding Information: 0 : BIND NAMED cmd line args &lt;/p&gt;
&lt;p&gt;[Set-DistributionGroup]&lt;/p&gt;
&lt;p&gt;DEBUG: ParameterBinding Information: 0 : BIND POSITIONAL cmd line args &lt;/p&gt;
&lt;p&gt;[Set-DistributionGroup]&lt;/p&gt;
&lt;p&gt;DEBUG: ParameterBinding Information: 0 : BIND cmd line args to DYNAMIC &lt;/p&gt;
&lt;p&gt;parameters.&lt;/p&gt;
&lt;p&gt;DEBUG: ParameterBinding Information: 0 : DYNAMIC parameter object:&lt;/p&gt;
&lt;p&gt;[Microsoft.Exchange.Data.Directory.Management.DistributionGroup]&lt;/p&gt;
&lt;p&gt;DEBUG: ParameterBinding Information: 0 : BIND NAMED args to DYNAMIC &lt;/p&gt;
&lt;p&gt;parameters&lt;/p&gt;
&lt;p&gt;DEBUG: ParameterBinding Information: 0 : BIND arg [&amp;quot;~$($_.name)&amp;quot;]&lt;/p&gt;
&lt;p&gt;to parameter [DisplayName]&lt;/p&gt;
&lt;p&gt;DEBUG: ParameterBinding Information: 0 : COERCE arg type &lt;/p&gt;
&lt;p&gt;[System.Management.Automation.ScriptBlock]&lt;/p&gt;
&lt;p&gt;to&lt;/p&gt;
&lt;p&gt;[System.String]&lt;/p&gt;
&lt;p&gt;DEBUG: ParameterBinding Information: 0 : CONVERT arg type&lt;/p&gt;
&lt;p&gt;to param type using&lt;/p&gt;
&lt;p&gt;LanguagePrimitives.ConvertTo&lt;/p&gt;
&lt;p&gt;DEBUG: ParameterBinding Information: 0 : CONVERT SUCCESSFUL&lt;/p&gt;
&lt;p&gt;using LanguagePrimitives.ConvertTo:&lt;/p&gt;
&lt;p&gt;[&amp;quot;~$($_.name)&amp;quot;]&lt;/p&gt;
&lt;p&gt;DEBUG: ParameterBinding Information: 0 : BIND arg &lt;/p&gt;
&lt;p&gt;[&amp;quot;~$($_.name)&amp;quot;]&lt;/p&gt;
&lt;p&gt;to param [DisplayName] SUCCESSFUL&lt;/p&gt;
&lt;p&gt;-----&lt;/p&gt;
&lt;p&gt;Shay Levi&lt;/p&gt;
&lt;p&gt;$cript Fanatic&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://scriptolog.blogspot.com"&gt;http://scriptolog.blogspot.com&lt;/a&gt;&lt;/p&gt;</description></item></channel></rss>