<?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>Controlling PowerShell Function (Re)Definition</title><link>http://blogs.msdn.com/b/powershell/archive/2007/01/25/controlling-powershell-function-re-definition.aspx</link><description>A question came up in the PowerShell news group recently where someone was asking how they could prevent functions from being redefined. 
 
  There are a couple of approaches you can use. First you can make functions read-only or constant. This is pretty</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Controlling PowerShell Function (Re)Definition</title><link>http://blogs.msdn.com/b/powershell/archive/2007/01/25/controlling-powershell-function-re-definition.aspx#1998422</link><pubDate>Sat, 31 Mar 2007 11:06:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1998422</guid><dc:creator>Keith Hill</dc:creator><description>&lt;p&gt;Speaking of the variable provider it sure would be nice if the function provider borrowed the &amp;quot;Description&amp;quot; property that can be associated with variables. &amp;nbsp;Then a package could identify the functions that it defines by setting the function Description to a particular value.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1998422" width="1" height="1"&gt;</description></item><item><title>re: Controlling PowerShell Function (Re)Definition</title><link>http://blogs.msdn.com/b/powershell/archive/2007/01/25/controlling-powershell-function-re-definition.aspx#1559862</link><pubDate>Wed, 31 Jan 2007 02:42:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1559862</guid><dc:creator>PowerShell Team</dc:creator><description>&lt;p&gt;Once an attacker has code running on a victim's computer, they can do anything they wish. Why play around with their profile, when you can just do the Remove-Item damage right away?&lt;/p&gt;
&lt;p&gt;The important thing to remember is that code running on the computer can do anything that the user can.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1559862" width="1" height="1"&gt;</description></item><item><title>re: Controlling PowerShell Function (Re)Definition</title><link>http://blogs.msdn.com/b/powershell/archive/2007/01/25/controlling-powershell-function-re-definition.aspx#1543479</link><pubDate>Sat, 27 Jan 2007 20:34:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1543479</guid><dc:creator>Rob Kenny</dc:creator><description>&lt;p&gt;At the moment it is possible to do the following:&lt;/p&gt;
&lt;p&gt;set-item function:Get-ChildItem {&amp;quot;Bar&amp;quot;}&lt;/p&gt;
&lt;p&gt;&amp;gt; Get-ChildItem&lt;/p&gt;
&lt;p&gt;&amp;gt; Bar&lt;/p&gt;
&lt;p&gt;If a users execution policy allows it (e.g. RemoteSigned or weaker) malicious code could be added to the My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 profile re-writing common functions e.g&lt;/p&gt;
&lt;p&gt;Set-Item function:Get-ChildItem {remove-item C:\*.* -recurse -force}&lt;/p&gt;
&lt;p&gt;I am missing something in my understanding? &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1543479" width="1" height="1"&gt;</description></item><item><title>re: Controlling PowerShell Function (Re)Definition</title><link>http://blogs.msdn.com/b/powershell/archive/2007/01/25/controlling-powershell-function-re-definition.aspx#1537457</link><pubDate>Fri, 26 Jan 2007 20:27:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1537457</guid><dc:creator>Adrian Milliner</dc:creator><description>&lt;p&gt;That's pretty much what I said in my post... unfortunately, the trackback comment here didn't make it obvious that there was more at &lt;a rel="nofollow" target="_new" href="http://ps1.soapyfrog.com/2007/01/26/making-functions-really-read-only/"&gt;http://ps1.soapyfrog.com/2007/01/26/making-functions-really-read-only/&lt;/a&gt; :(&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1537457" width="1" height="1"&gt;</description></item><item><title>re: Controlling PowerShell Function (Re)Definition</title><link>http://blogs.msdn.com/b/powershell/archive/2007/01/25/controlling-powershell-function-re-definition.aspx#1536631</link><pubDate>Fri, 26 Jan 2007 16:22:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1536631</guid><dc:creator>PowerShell Team</dc:creator><description>&lt;p&gt;&amp;gt; However, making a function constant does not prevent it from being shadowed in child scopes. Given that a child scope is created in an..&lt;/p&gt;
&lt;p&gt;Correct. &amp;nbsp;That is what -OPTION ALLSCOPE is for. &amp;nbsp;This defines the element for all scopes. &amp;nbsp;Here is an example:&lt;/p&gt;
&lt;p&gt;PS&amp;gt; set-item function:bar {&amp;quot;Constant&amp;quot;} -option constant,allscope &lt;/p&gt;
&lt;p&gt;Jeffrey Snover [MSFT]&lt;/p&gt;
&lt;p&gt;Windows PowerShell/MMC 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;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1536631" width="1" height="1"&gt;</description></item><item><title>Making functions *really* read-only</title><link>http://blogs.msdn.com/b/powershell/archive/2007/01/25/controlling-powershell-function-re-definition.aspx#1535872</link><pubDate>Fri, 26 Jan 2007 13:24:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1535872</guid><dc:creator>ps1.soapyfrog.com</dc:creator><description>&lt;p&gt;Over at the excellent PowerShell Team Blog, Bruce Payette wrote about Controlling PowerShell Function (Re)Definition.&lt;/p&gt;
&lt;p&gt;However, making a function constant does not prevent it from being shadowed in child scopes. Given that a child scope is created in an..&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1535872" width="1" height="1"&gt;</description></item><item><title>Adventures in SPWonderland - Powershell User Group Meeting</title><link>http://blogs.msdn.com/b/powershell/archive/2007/01/25/controlling-powershell-function-re-definition.aspx#1531627</link><pubDate>Fri, 26 Jan 2007 00:36:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1531627</guid><dc:creator>Adventures in SPWonderland - Powershell User Group Meeting</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,24fde49d-bc53-4773-a679-2bc62db4cae5.aspx"&gt;http://blogs.flexnetconsult.co.uk/colinbyrne/PermaLink,guid,24fde49d-bc53-4773-a679-2bc62db4cae5.aspx&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1531627" width="1" height="1"&gt;</description></item><item><title>Powershell User Group Meeting</title><link>http://blogs.msdn.com/b/powershell/archive/2007/01/25/controlling-powershell-function-re-definition.aspx#1531626</link><pubDate>Fri, 26 Jan 2007 00:36:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1531626</guid><dc:creator>Adventures in SPWonderland</dc:creator><description>&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1531626" width="1" height="1"&gt;</description></item></channel></rss>