<?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>Dynamic Casting</title><link>http://blogs.msdn.com/b/powershell/archive/2007/10/29/dynamic-casting.aspx</link><description>We've seen a couple requests for this on our internal mailing lists so I thought other people would be interested. 
 There are times when you want to do something like:
 $d = [DateTime] [$d]"12/25/2007" 
 Or (using a STRING instead of a TYPE):
 $d</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Dynamic Casting</title><link>http://blogs.msdn.com/b/powershell/archive/2007/10/29/dynamic-casting.aspx#10016907</link><pubDate>Fri, 28 May 2010 14:19:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10016907</guid><dc:creator>Chip</dc:creator><description>&lt;p&gt;Suppose you want to do something like:&lt;/p&gt;
&lt;p&gt; &amp;nbsp;$t = Read-host -Prompt &amp;quot;Type: &amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;$v = Read-host -Prompt &amp;quot;Value: &amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;[$t] $myVar = $v&lt;/p&gt;
&lt;p&gt;In this case -as doesn&amp;#39;t help. What to do?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10016907" width="1" height="1"&gt;</description></item><item><title>re: Dynamic Casting</title><link>http://blogs.msdn.com/b/powershell/archive/2007/10/29/dynamic-casting.aspx#5789575</link><pubDate>Wed, 31 Oct 2007 05:30:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5789575</guid><dc:creator>Oisin Grehan</dc:creator><description>&lt;p&gt;I blogged about this a few weeks ago, explaining how it can be used to ease the pain of using Enums in powershell:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://www.nivot.org/2007/10/12/UsingEnumeratedTypesEnumsInPowerShell.aspx"&gt;http://www.nivot.org/2007/10/12/UsingEnumeratedTypesEnumsInPowerShell.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is probably a more practical example of dynamic casting. ;-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5789575" width="1" height="1"&gt;</description></item><item><title>re: Dynamic Casting</title><link>http://blogs.msdn.com/b/powershell/archive/2007/10/29/dynamic-casting.aspx#5772174</link><pubDate>Tue, 30 Oct 2007 01:38:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5772174</guid><dc:creator>Joe Brinkman</dc:creator><description>&lt;p&gt;This is not working for me. &amp;nbsp;Powershell keeps going into an endless loop. &amp;nbsp;The command I tried is &amp;quot;Joe Brinkman&amp;quot; -as &amp;quot;[PowerShellExpert]&amp;quot; and it just isn't working? &amp;nbsp;What am I doing wrong? ;-) &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5772174" width="1" height="1"&gt;</description></item><item><title>re: Dynamic Casting</title><link>http://blogs.msdn.com/b/powershell/archive/2007/10/29/dynamic-casting.aspx#5771092</link><pubDate>Tue, 30 Oct 2007 00:17:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5771092</guid><dc:creator>Chris Warwick</dc:creator><description>&lt;p&gt;Sounds great - really looking forward to all the new goodies:-)&lt;/p&gt;
&lt;p&gt;But instead (as well) as dynamic casting, can we have dynamic locales? &amp;nbsp;&lt;/p&gt;
&lt;p&gt;12/25/2007 is not a valid date in my environment and you have no idea how inconvenient it is to remember that valid date strings will (sometimes!) be rejected by a cast to [datetime].&lt;/p&gt;
&lt;p&gt;Sorry to go on about it. &amp;nbsp;I know I've brought this up before, but it's the only REAL bad thing to have crept in to v1.0 IMO and I wish you guys would make it better.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Chris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5771092" width="1" height="1"&gt;</description></item></channel></rss>