&lt;?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Articles from April 2012 on PowerShell.org - Welcome Automaters!</title><link>https://powershell.org/articles/2012/04/</link><description>Recent content in Articles from April 2012 on PowerShell.org - Welcome Automaters!</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://powershell.org/articles/2012/04/index.xml" rel="self" type="application/rss+xml"/><item><title>PowerShell V3 "“ ObsoleteAttribute</title><link>https://powershell.org/articles/2012-04-29-powershell-v3-obsoleteattribute/</link><guid>https://powershell.org/articles/2012-04-29-powershell-v3-obsoleteattribute/</guid><pubDate>Mon, 30 Apr 2012 04:39:06 +0000</pubDate><description>&lt;p&gt;PowerShell V3 now supports the ObsoleteAttribute for compiled cmdlets but unfortunately not advanced functions. This is handy to let your users know that a binary cmdlet will be going away in a future release of your binary module.&lt;/p&gt;
&lt;p&gt;As we work on PSCX 3.0 there are a few binary cmdlets that we will mark with this attribute to let you know to switch over to PowerShell&amp;quot;™s built-in equivalent before we eliminate the cmdlet completely in the next release. Here&amp;quot;™s a snippet that shows how to apply the ObsoleteAttribute in your source code:&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>PowerShell V3 now supports the ObsoleteAttribute for compiled cmdlets but unfortunately not advanced functions. This is handy to let your users know that a binary cmdlet will be going away in a future release of your binary module.</p><p>As we work on PSCX 3.0 there are a few binary cmdlets that we will mark with this attribute to let you know to switch over to PowerShell"™s built-in equivalent before we eliminate the cmdlet completely in the next release. Here"™s a snippet that shows how to apply the ObsoleteAttribute in your source code:</p><p>`1</p><p>[OutputType(</p><p>typeof</p><p>(MailMessage))]</p><p>2</p><p>[Cmdlet(VerbsCommunications.Send, PscxNouns.SmtpMail,</p><p>3</p><pre><code> DefaultParameterSetName</code></pre><p>=</p><p>"</p><p>Authenticated</p><p>"</p><p>,</p><p>4</p><pre><code> SupportsShouldProcess</code></pre><p>=</p><p>true</p><p>)]</p><p>5</p><p>[Obsolete(</p><p>@"</p><p>The PSCX\SendSmtpMail cmdlet is obsolete</p><p>"</p><ul><li/></ul><p>6</p><p>"</p><p>and will removed in the next version of</p><p>"</p><ul><li/></ul><p>7</p><p>"</p><p>PSCX. Use the built-in Send-MailMessage.</p><p>"</p><p>)]</p><p>8</p><p>public</p><p>class</p><p>SendSmtpMailCommand : PscxCmdlet</p><p>9</p><p>{</p><p>`</p><pre><code>The resulting of executing this cmdlet with PSCX v3 loaded is:</code></pre><p>`C:\PS&gt; Send-SmtpMail</p><p>WARNING: The PSCX\SendSmtpMail cmdlet is obsolete and will removed in the next version of
PSCX. Use the built-in Send-MailMessage.</p><p>`There is an ObsoleteAttribute constructor overload that takes a boolean that converts the warning to an error. I"™m not sure how useful that is but PowerShell does honor that setting and will generate a terminating error in this case:</p><p>`C:\PS&gt; Send-SmtpMail</p><p>The PSCX\SendSmtpMail cmdlet is obsolete and will removed in the next version of PSCX. Use
the built-in Send-MailMessage.
At line:1 char:1</p><ul><li>Send-SmtpMail</li><li><pre tabindex="0"><code> + CategoryInfo : InvalidOperation: (Send-SmtpMail:String) [], RuntimeException
+ FullyQualifiedErrorId : UseOfDeprecatedCmdlet</code></pre></li></ul><p>`It"™s nice to see PowerShell honoring more of the .NET attributes &ldquo;“ where it makes sense that is.</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/rkeithhill.wordpress.com/256/"><img src="http://feeds.wordpress.com/1.0/comments/rkeithhill.wordpress.com/256/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=rkeithhill.wordpress.com&amp;blog=18780344&amp;%23038;post=256&amp;%23038;subd=rkeithhill&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item></channel></rss>