<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.microsoft.co.il/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>Shay Levy</title><link>http://blogs.microsoft.co.il/blogs/scriptfanatic/</link><description>If you repeat it, PowerShell it!</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>I'm a Microsoft MVP... Again</title><link>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2013/06/30/i-m-a-microsoft-mvp-again.aspx</link><pubDate>Sun, 30 Jun 2013 14:22:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:2219571</guid><dc:creator>ScriptFanatic</dc:creator><slash:comments>27</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/scriptfanatic/rsscomments.aspx?PostID=2219571</wfw:commentRss><comments>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2013/06/30/i-m-a-microsoft-mvp-again.aspx#comments</comments><description>&lt;p&gt;&lt;img style="margin:10px 10px 0px 0px;display:inline;float:left;" align="left" src="http://blogs.microsoft.co.il/blogs/scriptfanatic/MVPLogo_3946BFA8.gif" width="75" height="118" alt="" /&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;It&amp;#39;s that time of the year which feels like having a second birthday.     &lt;br /&gt;I&amp;#39;m proud to announce that I was awarded the MVP title once again.     &lt;br /&gt;This is my 6th year in a row as a PowerShell MVP, and hopefully not my last! &lt;/p&gt;  &lt;p&gt;Thank you all, &lt;a href="http://www.thefreedictionary.com/lechaim"&gt;Lechaim&lt;/a&gt;!!&lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=2219571" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/MVP/default.aspx">MVP</category></item><item><title>Improving the output of Update-Help</title><link>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/12/20/improving-the-output-of-update-help.aspx</link><pubDate>Thu, 20 Dec 2012 23:10:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1569343</guid><dc:creator>ScriptFanatic</dc:creator><slash:comments>25</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/scriptfanatic/rsscomments.aspx?PostID=1569343</wfw:commentRss><comments>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/12/20/improving-the-output-of-update-help.aspx#comments</comments><description>&lt;p&gt;Source: &lt;a href="http://www.powershellmagazine.com/2012/12/20/improving-the-output-of-update-help"&gt;PowerShellMagazine.com&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;If you’ve updated PowerShell to version 3.0 you probably noticed that help is no longer shipped in the box. PowerShell 3.0 includes a new feature, the &lt;a href="http://technet.microsoft.com/en-us/library/hh847735.aspx"&gt;Updatable Help system&lt;/a&gt;, which allows you to ensure that help on the local computer stays up to date.&lt;/p&gt;  &lt;p&gt;PowerShell is now a part of the operating system and operating systems gets to be updated only during service packs or specific patches. The Updatable Help system and its cmdlets (&lt;i&gt;*-Help&lt;/i&gt;) make it easy to download and install help files, or updating exiting help files, as soon as newer help files become available.&lt;/p&gt;  &lt;p&gt;To download and install help files for the first time, use the &lt;i&gt;Update-Help&lt;/i&gt; cmdlet. When executed, &lt;i&gt;Update-Help&lt;/i&gt; goes through a series of steps to get the latest help versions of the modules installed on your system:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;It determines which modules support updatable help by checking the &lt;i&gt;HelpInfoUri&lt;/i&gt; key in the module manifest file.&amp;nbsp; The &lt;i&gt;HelpInfoUri&lt;/i&gt; contains the Internet location where each module stores its updatable help files. &lt;/li&gt;    &lt;li&gt;Compares each module local help files with the newest help files that are available for each module. &lt;/li&gt;    &lt;li&gt;Downloads the new files (packaged in a cab file). &lt;/li&gt;    &lt;li&gt;Unwraps the help file package, verifies that the files are valid, and then installs the help files in the language-specific subdirectory of the module directory. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: There are a few things to take into account when using &lt;i&gt;Update-Help&lt;/i&gt;. First, you must run PowerShell as an administrator as help files are written to the installation folder of PowerShell and that happens to be under the&lt;i&gt;System32&lt;/i&gt; folder. PowerShell allows you to update help files once every 24 hours. To override this behavior you must specify the &lt;i&gt;-Force&lt;/i&gt; switch.&lt;/p&gt;  &lt;p&gt;By default, the &lt;i&gt;Update-Help&lt;/i&gt; cmdlet doesn’t generate any output. When executed, it displays a progress bar that prints information about the current module update phase.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/scriptfanatic/updateHelp_633FAAA6.png"&gt;&lt;img src="http://blogs.microsoft.co.il/blogs/scriptfanatic/updateHelp_thumb_01A9EB90.png" title="updateHelp" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" alt="updateHelp" border="0" height="117" width="586" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If you want to see what’s going on under the hood, include the&lt;i&gt; -Verbose&lt;/i&gt; switch:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/scriptfanatic/updateHelp1_11D5B389.png"&gt;&lt;img src="http://blogs.microsoft.co.il/blogs/scriptfanatic/updateHelp1_thumb_2EFB5B93.png" title="updateHelp1" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" alt="updateHelp1" border="0" height="473" width="585" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;One of the things that really annoys me is the output of the &lt;i&gt;-Verbose&lt;/i&gt; switch, the way it is written makes it very hard to read and determine which files and modules has been updated. In this post I want to introduce you to a new feature in PowerShell 3.0 that can help you change the way the verbose information is displayed in the console.&lt;/p&gt;  &lt;p&gt;In the previous version of PowerShell it was very hard to capture the output of the &lt;i&gt;Verbose&lt;/i&gt; stream, or any other PowerShell-related stream. Luckily, this has changed in PowerShell 3.0 and now it is a very easy thing to do. We can now redirect and merge any of the pipeline output streams (see list below) to text files. You can read more about this in &lt;a href="http://technet.microsoft.com/en-us/library/hh847746.aspx"&gt;about_Redirection&lt;/a&gt; help topic. &lt;br /&gt;&lt;/p&gt;    &lt;p&gt;By default, the&lt;i&gt; Update-Help&lt;/i&gt; command doesn’t write anything to the pipeline so we can safely merge the verbose stream to the standard output stream and parse it without having to worry about information from both sources gets mixed together.&lt;/p&gt;  &lt;p&gt;Each redirection operator uses a character to represent each output type:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;* – All output &lt;/li&gt;    &lt;li&gt;1 – Success output &lt;/li&gt;    &lt;li&gt;2 – Errors &lt;/li&gt;    &lt;li&gt;3 – Warning messages &lt;/li&gt;    &lt;li&gt;4 – Verbose output &lt;/li&gt;    &lt;li&gt;5 – Debug messages &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The &lt;i&gt;Verbose&lt;/i&gt; stream constant is 4, and &lt;i&gt;Success&lt;/i&gt; output is 1, so we use the redirection operator (e.g ‘&amp;gt;’) to funnel the output:&lt;/p&gt;  &lt;pre style="background-color:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; $uh = Update-Help -Verbose -Force 4&amp;gt;&amp;amp;1&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;Let’s examine the first element; we can see that the connection is redirecting to another URI.&lt;/p&gt;

&lt;pre style="background-color:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; $uh[0]
VERBOSE: Your connection has been redirected to the following URI:
VERBOSE: &lt;a href="http://download.microsoft.com/download/3/4/C/34C6B4B6-63FC-46BE-9073-FC75EAD5A136/"&gt;http://download.microsoft.com/download/3/4/C/34C6B4B6-63FC-46BE-9073-FC75EAD5A136/&lt;/a&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;The second element in the output of &lt;i&gt;Update-Help&lt;/i&gt; contains the information we are after. We can see that the&lt;i&gt;Microsoft.PowerShell.Management&lt;/i&gt; was updated, and we 

  &lt;br /&gt;also get information about the path of the help file, its culture, and the version information.&lt;/p&gt;

&lt;pre style="background-color:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; $uh[1]
VERBOSE: Microsoft.PowerShell.Management: Updated
VERBOSE:
C:\Windows\System32\WindowsPowerShell\v1.0\en-US\Microsoft.PowerShell.Commands.Management.dll-hel
p.xml. Culture en-US
VERBOSE: Version 3.1.0.0&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;Let’s see what &lt;i&gt;Get-Member&lt;/i&gt; has to say about it:&lt;/p&gt;

&lt;pre style="background-color:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; $uh[1] | Get-Member

   TypeName: System.Management.Automation.VerboseRecord

Name                  MemberType   Definition
----                  ----------   ----------
Equals                Method       bool Equals(System.Object obj)
GetHashCode           Method       int GetHashCode()
GetType               Method       type GetType()
ToString              Method       string ToString()
WriteVerboseStream    NoteProperty System.Boolean WriteVerboseStream=True
InvocationInfo        Property     System.Management.Automation.InvocationInfo InvocationInfo {get;}
Message               Property     string Message {get;set;}
PipelineIterationInfo Property     System.Collections.ObjectModel.ReadOnlyCollection[int] PipelineIterationInfo {get;}&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;We get a &lt;i&gt;System.Management.Automation.VerboseRecord&lt;/i&gt; object which describes a verbose message sent to the verbose stream, and information about the command that sent the message (&lt;i&gt;InvocationInfo&lt;/i&gt;). The &lt;i&gt;Message&lt;/i&gt; property contains the actual message we see in the console. If you need to identify verbose messages written to the success stream, you can safely rely on this type and filter objects accordingly.&lt;br /&gt;&lt;/p&gt;

&lt;pre style="background-color:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; $uh[1].Message
Microsoft.PowerShell.Management: Updated C:\Windows\System32\WindowsPowerShell\v1.0\en-US\Microsoft.PowerShell.Commands
.Management.dll-help.xml. Culture en-US Version 3.1.0.0&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;We can split the message (by default the &lt;i&gt;Split&lt;/i&gt; method breaks the string on the space character) and get access to the array elements we get back:&lt;/p&gt;

&lt;pre style="background-color:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; $uh[1].Message.split()
Microsoft.PowerShell.Management:
Updated
C:\Windows\System32\WindowsPowerShell\v1.0\en-US\Microsoft.PowerShell.Commands.Management.dll-help.xml.
Culture
en-US
Version
3.1.0.0&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;Based on the output of the &lt;i&gt;Split&lt;/i&gt; operation, we want to extract the relevant pieces of information, create a new custom object and write it back to the pipeline, one object at a time. 

  &lt;br /&gt;The information we want is:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;The module name–it’s the first item (index 0). The value is followed by a colon, we’ll remove it later on. &lt;/li&gt;

  &lt;li&gt;The file path that’s being updated (third line, index 2). &lt;/li&gt;

  &lt;li&gt;The culture of the help file (fifth line, index 4). &lt;/li&gt;

  &lt;li&gt;The version of the new help file (last line, we can refer to it as index -1, which in PowerShell gives back the last array element). &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We can now construct a new custom object. We’ll start by creating a custom object for the first array element:&lt;/p&gt;

&lt;pre style="background-color:#012456;"&gt;&lt;font color="#ffffff"&gt;$message = $uh[1].Message.split()[0,2,4,-1]

[PSCustomObject]@{
	Module = $message[0] -replace &amp;#39;:$&amp;#39;
	FileName = (Split-Path $message[1] -Leaf).Trim(&amp;#39;.&amp;#39;)
	Culture = $message[2]
	Version  = $message[-1]
}

Module                        FileName                      Culture                       Version
------                        --------                      -------                       -------
Microsoft.PowerShell.Manag... Microsoft.PowerShell.Comma... en-US                         3.1.0.0&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;As soon as each object (verbose message) is processed, the object goes out to the console. As you can see, the output of the &lt;i&gt;Module&lt;/i&gt; and &lt;i&gt;FileName&lt;/i&gt; properties is truncated. 

  We could use the &lt;i&gt;-AutoSize&lt;/i&gt; of the&lt;i&gt; Format-Table&lt;/i&gt; cmdlet to adjust the columns size, but doing so will block output of objects to the console until all objects were processed.&lt;/p&gt;

&lt;p&gt;When processing the verbose stream we also want to avoid processing unnecessary messages, we want to skip any messages that contains URI redirections, so we process only messages that contains the word “Updated”. We pipe the custom objects to the &lt;i&gt;Tee-Object&lt;/i&gt; cmdlet, to send output to the console as soon as it flows in, and also save the output to a variable that we can format the way we want it to.&lt;/p&gt;

&lt;p&gt;Here’s the full snippet. Output shown on screen is also saved in the &lt;i&gt;UpdatedHelp&lt;/i&gt; variable. When the script finished executing we can investigate and format it as we like.&lt;/p&gt;

&lt;pre style="background-color:#012456;"&gt;&lt;font color="#ffffff"&gt;Update-Help -Force -Verbose 4&amp;gt;&amp;amp;1 |
Where-Object {$_.Message -like &amp;#39;*: Updated*&amp;#39;} |
ForEach-Object {

    $message = $_.Message.Split()[0,2,4,-1]

    [PSCustomObject]@{
        Module = $message[0] -replace &amp;#39;:$&amp;#39;
        FileName = (Split-Path $message[1] -Leaf).Trim(&amp;#39;.&amp;#39;)
        Culture = $message[2]
        Version  = $message[-1]
    }

} | Tee-Object -Variable UpdatedHelp

$UpdatedHelp | Format-Table -AutoSize&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/scriptfanatic/updateHelp2_76408BB8.png"&gt;&lt;img src="http://blogs.microsoft.co.il/blogs/scriptfanatic/updateHelp2_thumb_21A4ACB3.png" title="updateHelp2" style="border-left-width:0px;border-right-width:0px;background-image:none;border-bottom-width:0px;padding-top:0px;padding-left:0px;display:inline;padding-right:0px;border-top-width:0px;" alt="updateHelp2" border="0" height="380" width="573" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1569343" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShell+Magazine/default.aspx">PowerShell Magazine</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/UpdateHelp/default.aspx">UpdateHelp</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/Verbose/default.aspx">Verbose</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/Redirection/default.aspx">Redirection</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShell+3.0/default.aspx">PowerShell 3.0</category></item><item><title>Skipping empty CSV objects</title><link>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/12/04/skipping-empty-csv-objects.aspx</link><pubDate>Wed, 05 Dec 2012 01:00:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1494564</guid><dc:creator>ScriptFanatic</dc:creator><slash:comments>21</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/scriptfanatic/rsscomments.aspx?PostID=1494564</wfw:commentRss><comments>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/12/04/skipping-empty-csv-objects.aspx#comments</comments><description>&lt;p&gt;Hi, it’s been a while since my last post, I’ve been busy mostly at work and also by investing most of my time running the PowerShell Magazine website together with &lt;a href="http://www.powershellmagazine.com/about/"&gt;my friends&lt;/a&gt;. I hope to post more in the future. For the time being, here’s my latest post, &lt;a href="http://www.powershellmagazine.com/2012/12/04/skipping-empty-csv-objects"&gt;cross-posted on the PowerShell Magazine&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Working with CSV files in PowerShell is a common practice. You import the file, loop on its records and you’re good to go. Sometimes however you may find yourself in a situation where you get a file that has blank lines in it, and those lines can break your script. Consider the following CSV content:&lt;/p&gt;  &lt;pre style="background-color:#012456;"&gt;&lt;font color="#ffffff"&gt;## sample.csv ##
column1,column2,column3
Value1,Value2,Value3
Value1,Value2,Value3


 
## file ends here&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;On the surface, nothing looks suspicious when you import the file: &lt;/p&gt;

&lt;pre style="background-color:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; Import-Csv sample.csv
 
column1  column2  column3
-------  -------  -------
Value1   Value2   Value3
Value1   Value2   Value3
 


PS&amp;gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;But if you pipe it to Format-List you can clearly see what’s going on. You get empty objects for each empty line in the file.&lt;/p&gt;

&lt;pre style="background-color:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; Import-Csv sample.csv | Format-List
 
column1 : Value1
column2 : Value2
column3 : Value3
 
column1 : Value1
column2 : Value2
column3 : Value3
 
column1 :
column2 :
column3 :
 
column1 :
column2 :
column3 :
 
column1 :
column2 :
column3 :&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;To filter out empty objects you need to test that all properties are not equal to an empty string and throw them away. 
  &lt;br /&gt;You might be attempted to do that with:&lt;/p&gt;

&lt;pre style="background-color:#012456;"&gt;&lt;font color="#ffffff"&gt;Import-Csv sample.csv |
Where-Object {$_.column1 -ne &amp;#39;&amp;#39; -and $_.column1 -ne &amp;#39;&amp;#39; -and $_.column1 -ne &amp;#39;&amp;#39;}&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;But what if each record has 20 properties, or even more? This is where the PSObject property comes to rescue. In a nutshell, PSObject allows us to work with any object in the same way without really knowing its structure. PowerShell wraps the base object in a PSObject and provide us a simplified and consistent view of the object, its methods, properties, and so on. One of the properties of PSObject is Properties, and it gives us a list of properties of the base object.&lt;/p&gt;

&lt;p&gt;On a related note, PSObject and other members are not visible when you pipe an object to the Get-Member cmdlet. To reveal those members add the -Force switch to Get-Member.&lt;/p&gt;

&lt;p&gt;For our purpose, we can process the properties list and filter out those who have a Value of null.&lt;/p&gt;

&lt;pre style="background-color:#012456;"&gt;&lt;font color="#ffffff"&gt;Import-Csv sample.csv |
Where-Object { ($_.PSObject.Properties | ForEach-Object {$_.Value}) -ne $null} |
Format-List
 
column1 : Value1
column2 : Value2
column3 : Value3
 
column1 : Value1
column2 : Value2
column3 : Value3&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;In PowerShell 3.0 and the new &lt;a href="http://blogs.msdn.com/b/powershell/archive/2012/06/14/new-v3-language-features.aspx"&gt;Member Enumeration feature&lt;/a&gt; we can get the same result in less characters:&lt;/p&gt;

&lt;pre style="background-color:#012456;"&gt;&lt;font color="#ffffff"&gt;
Import-Csv sample.csv |
Where-Object { $_.PSObject.Properties.Value -ne $null}
&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;I logged an &lt;a href="https://connect.microsoft.com/PowerShell/feedback/details/767851/import-csv-and-blank-lines"&gt;Import-Csv feature enhancement,&lt;/a&gt; and you can add your vote if you’d like to have a built-in option to ignore empty lines.&lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1494564" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/CSV/default.aspx">CSV</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PSObject/default.aspx">PSObject</category></item><item><title>Congratulations 2012 Microsoft MVP</title><link>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/07/01/congratulations-2012-microsoft-mvp.aspx</link><pubDate>Sun, 01 Jul 2012 21:37:57 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1139760</guid><dc:creator>ScriptFanatic</dc:creator><slash:comments>22</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/scriptfanatic/rsscomments.aspx?PostID=1139760</wfw:commentRss><comments>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/07/01/congratulations-2012-microsoft-mvp.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/scriptfanatic/MVPLogo_3946BFA8.gif"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px 10px 0px 0px;padding-left:0px;padding-right:0px;display:inline;float:left;border-top:0px;border-right:0px;padding-top:0px;" title="MVPLogo" border="0" alt="MVPLogo" align="left" src="http://blogs.microsoft.co.il/blogs/scriptfanatic/MVPLogo_thumb_581D3386.gif" width="56" height="88" /&gt;&lt;/a&gt;I’ve just received THE email from Microsoft… I’m a PowerShell MVP for another year! I am very honored!&lt;/p&gt;  &lt;p&gt;This is my 5th renewal and I would like to take this opportunity and say &lt;strong&gt;thank you&lt;/strong&gt; to Microsoft and to all the people who supported me.&lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1139760" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/MVP/default.aspx">MVP</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/ITPRO/default.aspx">ITPRO</category></item><item><title>What is my Exchange server version</title><link>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/05/17/what-is-my-exchange-server-version.aspx</link><pubDate>Thu, 17 May 2012 18:32:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1094211</guid><dc:creator>ScriptFanatic</dc:creator><slash:comments>43</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/scriptfanatic/rsscomments.aspx?PostID=1094211</wfw:commentRss><comments>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/05/17/what-is-my-exchange-server-version.aspx#comments</comments><description>&lt;p&gt;I’ve been asking myself the same question lately. Unfortunately the information is not always available in the product’s title or in Add/Remove programs. The only piece of available information is the product build version (either in About dialog or in the EMS using Get-ExchangeServer), now you need look it up in your favorite search engine and try to find its SP or cumulative patches level. What a pain, why?!&lt;/p&gt; &lt;p&gt;To save the frustration and confusion I’ve put together a quick and dirty function, give it a build number and hopefully you’ll get back the information. It may not contain the full list but it’s better than nothing. The information is based on the following links:&lt;/p&gt;&lt;a href="http://technet.microsoft.com/en-us/library/hh135098"&gt;Exchange Server Build Numbers and Release Dates&lt;/a&gt; &lt;br /&gt;&lt;a href="http://support.microsoft.com/kb/158530"&gt;Build numbers and release dates for Exchange Server&lt;/a&gt; &lt;br /&gt;&lt;a href="http://technet.microsoft.com/en-us/library/bb232170%28EXCHG.80%29.aspx"&gt;Exchange Server 2007: Platforms, Editions, and Versions&lt;/a&gt; &lt;pre&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre style="background-color:#012456;"&gt;&lt;font color="#ffffff"&gt;function Get-ExchangeVersion
{
  param(
    [Parameter(Mandatory=$true,Position=0,ValueFromPipeline=$true)]
    [Alias(&amp;#39;bn&amp;#39;)]
    [string]$BuildNumber
  )

  process
  {
    switch($BuildNumber)
    {
      &amp;#39;4.0.837&amp;#39; {&amp;#39;Exchange Server 4.0&amp;#39;; break}
      &amp;#39;4.0.993&amp;#39; {&amp;#39;Exchange Server 4.0 (a)&amp;#39;; break}
      &amp;#39;4.0.838&amp;#39; {&amp;#39;Exchange Server 4.0 SP1&amp;#39;; break}
      &amp;#39;4.0.993&amp;#39; {&amp;#39;Exchange Server 4.0 SP2&amp;#39;; break}
      &amp;#39;4.0.994&amp;#39; {&amp;#39;Exchange Server 4.0 SP3&amp;#39;; break}
      &amp;#39;4.0.995&amp;#39; {&amp;#39;Exchange Server 4.0 SP4&amp;#39;; break}
      &amp;#39;4.0.996&amp;#39; {&amp;#39;Exchange Server 4.0 SP5&amp;#39;; break}
      &amp;#39;5.0.1457&amp;#39;  {&amp;#39;Exchange Server 5.0&amp;#39;; break}
      &amp;#39;5.0.1458&amp;#39;  {&amp;#39;Exchange Server 5.0 SP1&amp;#39;; break}    
      &amp;#39;5.0.1460&amp;#39;  {&amp;#39;Exchange Server 5.0 SP2&amp;#39;; break}    
      &amp;#39;5.5.1960&amp;#39;  {&amp;#39;Exchange Server 5.5&amp;#39;; break}
      &amp;#39;5.5.2232&amp;#39;  {&amp;#39;Exchange Server 5.5 SP1&amp;#39;; break}
      &amp;#39;5.5.2448&amp;#39;  {&amp;#39;Exchange Server 5.5 SP2&amp;#39;; break}
      &amp;#39;5.5.2650&amp;#39;  {&amp;#39;Exchange Server 5.5 SP3&amp;#39;; break}
      &amp;#39;5.5.2653&amp;#39;  {&amp;#39;Exchange Server 5.5 SP4&amp;#39;; break}
      &amp;#39;6.0.4417&amp;#39;  {&amp;#39;Exchange 2000 Server (a)&amp;#39;; break}
      &amp;#39;6.0.4712&amp;#39;  {&amp;#39;Exchange 2000 Server SP1&amp;#39;; break}
      &amp;#39;6.0.5762&amp;#39;  {&amp;#39;Exchange 2000 Server SP2&amp;#39;; break}
      &amp;#39;6.0.6249&amp;#39;  {&amp;#39;Exchange 2000 Server SP3&amp;#39;; break}
      &amp;#39;6.0.6487&amp;#39;  {&amp;#39;Exchange 2000 Server post-SP3&amp;#39;; break}
      &amp;#39;6.0.6556&amp;#39;  {&amp;#39;Exchange 2000 Server post-SP3&amp;#39;; break}
      &amp;#39;6.0.6603&amp;#39;  {&amp;#39;Exchange 2000 Server post-SP3&amp;#39;; break}
      &amp;#39;6.0.6620.5&amp;#39;{&amp;#39;Exchange 2000 Server post-SP3&amp;#39;; break}
      &amp;#39;6.0.6620.7&amp;#39;{&amp;#39;Exchange 2000 Server post-SP3&amp;#39;; break}
      &amp;#39;6.5.6944&amp;#39;  {&amp;#39;Exchange Server 2003&amp;#39;; break}
      &amp;#39;6.5.7226&amp;#39;  {&amp;#39;Exchange Server 2003 SP1&amp;#39;; break}
      &amp;#39;6.5.7638&amp;#39;  {&amp;#39;Exchange Server 2003 SP2&amp;#39;; break}
      &amp;#39;6.5.7653.33&amp;#39;{&amp;#39;Exchange Server 2003 post-SP2&amp;#39;; break}
      &amp;#39;6.5.7654.4&amp;#39;{&amp;#39;Exchange Server 2003 post-SP2&amp;#39;; break}
      &amp;#39;8.0.685.24&amp;#39;{&amp;#39;Exchange Server 2007&amp;#39;; break}
      &amp;#39;8.0.685.25&amp;#39;{&amp;#39;Exchange Server 2007 RTM&amp;#39;; break}
      &amp;#39;8.0.708.3&amp;#39; {&amp;#39;Update Rollup 1 for Exchange Server 2007&amp;#39;; break}
      &amp;#39;8.0.711.2&amp;#39; {&amp;#39;Update Rollup 2 for Exchange Server 2007&amp;#39;; break}
      &amp;#39;8.0.730.1&amp;#39; {&amp;#39;Update Rollup 3 for Exchange Server 2007&amp;#39;; break}
      &amp;#39;8.0.744.0&amp;#39; {&amp;#39;Update Rollup 4 for Exchange Server 2007&amp;#39;; break}
      &amp;#39;8.0.754.0&amp;#39; {&amp;#39;Update Rollup 5 for Exchange Server 2007&amp;#39;; break}
      &amp;#39;8.0.783.2&amp;#39; {&amp;#39;Update Rollup 6 for Exchange Server 2007&amp;#39;; break}
      &amp;#39;8.0.813.0&amp;#39; {&amp;#39;Update Rollup 7 for Exchange Server 2007&amp;#39;; break} 
      &amp;#39;8.1.240.6&amp;#39; {&amp;#39;Microsoft Exchange Server 2007 SP1&amp;#39;; break}
      &amp;#39;8.1.263.1&amp;#39; {&amp;#39;Update Rollup 1 for Exchange Server 2007 SP1&amp;#39;; break}
      &amp;#39;8.1.278.2&amp;#39; {&amp;#39;Update Rollup 2 for Exchange Server 2007 SP1&amp;#39;; break}
      &amp;#39;8.1.291.2&amp;#39; {&amp;#39;Update Rollup 3 for Exchange Server 2007 SP1&amp;#39;; break}
      &amp;#39;8.1.311.3&amp;#39; {&amp;#39;Update Rollup 4 for Exchange Server 2007 SP1&amp;#39;; break}
      &amp;#39;8.1.336.1&amp;#39; {&amp;#39;Update Rollup 5 for Exchange Server 2007 SP1&amp;#39;; break}
      &amp;#39;8.1.340.1&amp;#39; {&amp;#39;Update Rollup 6 for Exchange Server 2007 SP1&amp;#39;; break}
      &amp;#39;8.1.359.2&amp;#39; {&amp;#39;Update Rollup 7 for Exchange Server 2007 SP1&amp;#39;; break}
      &amp;#39;8.1.375.2&amp;#39; {&amp;#39;Update Rollup 8 for Exchange Server 2007 SP1&amp;#39;; break}
      &amp;#39;8.1.393.1&amp;#39; {&amp;#39;Update Rollup 9 for Exchange Server 2007 SP1&amp;#39;; break}
      &amp;#39;8.2.176.2&amp;#39; {&amp;#39;Exchange Server 2007 SP2&amp;#39;; break}
      &amp;#39;8.3.83.6&amp;#39;  {&amp;#39;Exchange Server 2007 SP3&amp;#39;; break}
      &amp;#39;14.0.639.21&amp;#39;{&amp;#39;Exchange Server 2010 RTM&amp;#39;; break}
      &amp;#39;14.1.218.15&amp;#39;{&amp;#39;Exchange Server 2010 SP1&amp;#39;; break}
      &amp;#39;14.2.247.5&amp;#39; {&amp;#39;Exchange Server 2010 Service Pack 2&amp;#39;; break}
      &amp;#39;14.1.255.2&amp;#39; {&amp;#39;Update Rollup 1 for Exchange Server 2010 SP1)&amp;#39;; break}
      &amp;#39;14.1.270.1&amp;#39;{&amp;#39;Update Rollup 2 for Exchange Server 2010 SP1&amp;#39;; break}
      &amp;#39;14.1.289.7&amp;#39;{&amp;#39;Update Rollup 3 for Exchange Server 2010 SP1&amp;#39;; break}
      &amp;#39;14.1.323.6&amp;#39;{&amp;#39;Update Rollup 4 for Exchange Server 2010 SP1&amp;#39;; break}
      &amp;#39;14.1.339.1&amp;#39;{&amp;#39;Update Rollup 5 for Exchange Server 2010 SP1&amp;#39;; break}
      &amp;#39;14.1.355.2&amp;#39;{&amp;#39;Update Rollup 6 for Exchange Server 2010 SP1&amp;#39;; break}
      &amp;#39;14.2.283.3&amp;#39;{&amp;#39;Update Rollup 1 for Exchange Server 2010 SP2&amp;#39;; break}    
      &amp;#39;14.2.298.4&amp;#39;{&amp;#39;Update Rollup 2 for Exchange Server 2010 SP2&amp;#39;; break}
      default {&amp;#39;Unknown&amp;#39;}
    }
  }
}

# example&lt;br /&gt;PS&amp;gt; Get-ExchangeVersion -BuildNumber 14.1.218.15
Exchange Server 2010 SP1&lt;/font&gt;
&lt;/pre&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1094211" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/Exchange/default.aspx">Exchange</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/ITPRO/default.aspx">ITPRO</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/Version/default.aspx">Version</category></item><item><title>Deprecation of cmdlets</title><link>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/04/30/deprecation-of-cmdlets-in-powershell-3.0.aspx</link><pubDate>Mon, 30 Apr 2012 14:46:23 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1078706</guid><dc:creator>ScriptFanatic</dc:creator><slash:comments>221</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/scriptfanatic/rsscomments.aspx?PostID=1078706</wfw:commentRss><comments>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/04/30/deprecation-of-cmdlets-in-powershell-3.0.aspx#comments</comments><description>&lt;p&gt;Until &lt;a href="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2011/08/31/get-your-game-on-leverage-proxy-functions-in-windows-powershell.aspx"&gt;PowerShell&lt;/a&gt; 3.0, if you shipped a cmdlet there was no good way to deprecate it. Cmdlet developers can use the .NET &lt;a href="http://msdn.microsoft.com/en-us/library/system.obsoleteattribute.aspx"&gt;ObsoleteAttribute&lt;/a&gt; now to let users know that they should not use a cmdlet anymore. In the following example, the cmdlet can run but it will issue a warning that another cmdlet should be used from now on. This gives the user time to prepare for the change and fix any scripts dependent on old commands.&lt;/p&gt;  &lt;pre style="background-color:#012456;"&gt;&lt;font color="#ffffff"&gt;$code = @&amp;#39;
using System;
using System.Management.Automation;
namespace ObsoleteCmdlet
{
    [Cmdlet(&amp;quot;Get&amp;quot;,&amp;quot;Foo&amp;quot;)]
    [Obsolete(&amp;quot;This cmdlet is obsolete. Please use Get-Bar instead.&amp;quot;)]
    public class ObsoleteCmdlet : PSCmdlet
    {
        protected override void ProcessRecord()
        {
            WriteObject(&amp;quot;Hello&amp;quot;);
        }
    }
}
&amp;#39;@&lt;br /&gt;
&lt;font color="#ffffff"&gt;#compile this code into the ObsoleteCmdlet.dll&lt;/font&gt;
PS&amp;gt; &lt;/font&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkID=135195"&gt;&lt;font color="#ffffff"&gt;Add-Type&lt;/font&gt;&lt;/a&gt;&lt;font color="#ffffff"&gt; -TypeDefinition $code -OutputAssembly $env:TEMP\ObsoleteCmdlet.dll

# Import the module and run our cmdlet
PS&amp;gt; &lt;/font&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkID=141553"&gt;&lt;font color="#ffffff"&gt;Import-Module&lt;/font&gt;&lt;/a&gt;&lt;font color="#ffffff"&gt; $env:TEMP\ObsoleteCmdlet.dll
PS&amp;gt; Get-Foo&lt;/font&gt;

&lt;font style="background-color:#000000;" color="#ffff00"&gt;WARNING: This cmdlet is obsolete. Please use Get-Bar instead.&lt;/font&gt;
&lt;font color="#ffffff"&gt;Hello&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;When you ship the next version of your cmdlet you can change the behavior of the Obsolete attribute, &lt;a href="http://msdn.microsoft.com/en-us/library/961hff5d.aspx"&gt;by using another constructor&lt;/a&gt;, and throw an error instead of a warning:&lt;/p&gt;

&lt;pre style="background-color:#012456;"&gt;&lt;font color="#ffffff"&gt;# [Obsolete(&amp;quot;This cmdlet is obsolete. Please use Get-Bar instead.&amp;quot;,true)]
PS&amp;gt; Get-Foo&lt;/font&gt;
&lt;font style="background-color:#000000;" color="#ff0000"&gt;This cmdlet is obsolete. Please use Get-Bar instead.
At line:1 char:1
+ get-foo
+ ~~~~~~~~
   + CategoryInfo          : InvalidOperation: (Get-Foo:String) [], RuntimeException
   + FullyQualifiedErrorId : UseOfDeprecatedCmdlet&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;It would be great to have this attribute in advanced functions and even on parameters. I logged a &lt;a href="https://connect.microsoft.com/PowerShell/feedback/details/732745/the-obsolete-attribute"&gt;suggestion on connect&lt;/a&gt; about this, vote it up if you like it. &lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1078706" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/ITPRO/default.aspx">ITPRO</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/DEV/default.aspx">DEV</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShellV3/default.aspx">PowerShellV3</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/deprecate/default.aspx">deprecate</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/Obsolete/default.aspx">Obsolete</category></item><item><title>Creating objects with a cast in PowerShell 3.0</title><link>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/04/19/creating-objects-with-a-cast-in-powershell-3-0.aspx</link><pubDate>Thu, 19 Apr 2012 19:00:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1067418</guid><dc:creator>ScriptFanatic</dc:creator><slash:comments>20</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/scriptfanatic/rsscomments.aspx?PostID=1067418</wfw:commentRss><comments>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/04/19/creating-objects-with-a-cast-in-powershell-3-0.aspx#comments</comments><description>&lt;p&gt;Starting with &lt;a href="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2011/08/31/get-your-game-on-leverage-proxy-functions-in-windows-powershell.aspx"&gt;PowerShell&lt;/a&gt; 3.0, we now have another cool way to create new objects. We can create them by calling the default constructor of the type and initializing its properties with a cast:&lt;u&gt;&lt;/u&gt;&lt;u&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;&lt;u&gt;&lt;/u&gt;&lt;u&gt;&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;[System.Drawing.Point]@{X=1;Y=2}&lt;/p&gt;  &lt;p&gt;We put the type in square brackets and assign it a hash table containing the properties we want to initialize. Looking at this example got me thinking, how can I know the properties I can set for a specific class/type? As a learning tool, I wrote the Get-HashType function. Give it a type name and it will tell you the properties you can set.&lt;/p&gt;  &lt;br /&gt;  &lt;pre style="background-color:#012456;"&gt;&lt;font color="#ffffff"&gt;#requires -Version 3.0
function Get-TypeHash
{
   [CmdletBinding()]
   [OutputType(&amp;#39;System.String&amp;#39;)]
	
   Param(
      [Parameter(
         Mandatory=$true,
         Position=0,
         ValueFromPipeline=$true,
         ValueFromPipelineByPropertyName=$true)]
      [Alias(&amp;#39;FullName&amp;#39;)]
      [Type]$TypeName
   )

   process
   {
      try
      {  
         if($TypeName.IsClass -and !$TypeName.GetConstructor([Type]::EmptyTypes))
         {
            throw &amp;quot;Constructor not found. Cannot find an appropriate `
                        constructor for type &amp;#39;$TypeFullName&amp;#39;&amp;quot;
         }


         $TypeFullName = $TypeName.FullName
         $WriteableProperties = $TypeName.GetProperties() | where CanWrite

         if($WriteableProperties.Count -gt 0)
         {         
            $hash = &amp;quot;[$TypeFullName]@{&amp;quot;

            $WriteableProperties | ForEach-Object {
               $hash+=&amp;quot;`n`t{0} = &amp;lt;{1}&amp;gt;&amp;quot; -f $_.Name,$_.PropertyType
            }
         
            $hash+&amp;quot;`n}&amp;quot; 
         }
         else
         {
            Write-Warning &amp;quot;No writable properties found for type &amp;#39;$TypeFullName&amp;#39;&amp;quot;
         }    
      }
      catch
      {
         Write-Error $_
      }
   }
}


PS&amp;gt; Add-Type –Assembly System.Drawing&lt;br /&gt;PS&amp;gt; Get-TypeHash –TypeName System.Drawing.Point 

[System.Drawing.Point]@{
	X = &amp;lt;System.Int32&amp;gt;
	Y = &amp;lt;System.Int32&amp;gt;
}
&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;The output includes the writeable properties of the type and their corresponding value type. Copy the output, assign the values and paste it back to the console. This will create the object:&lt;/p&gt;

&lt;pre style="background-color:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; [System.Drawing.Point]@{
&amp;gt;&amp;gt; X = 1
&amp;gt;&amp;gt; Y = 1
&amp;gt;&amp;gt; }
&amp;gt;&amp;gt;
 IsEmpty   X   Y
 -------   -   -
   False   1   1&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;The function works for types that have a default constructor and for structure types. In the example above, &lt;a href="http://msdn.microsoft.com/en-us/library/system.drawing.point.aspx"&gt;System.Drawing.Point&lt;/a&gt; is a structure. &lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1067418" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/ITPRO/default.aspx">ITPRO</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShellV3/default.aspx">PowerShellV3</category></item><item><title>How to protect your PowerShell Functions</title><link>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/04/17/How-to-protect-your-PowerShell-Functions.aspx</link><pubDate>Tue, 17 Apr 2012 18:00:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:994833</guid><dc:creator>ScriptFanatic</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/scriptfanatic/rsscomments.aspx?PostID=994833</wfw:commentRss><comments>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/04/17/How-to-protect-your-PowerShell-Functions.aspx#comments</comments><description>&lt;p&gt;&lt;font size="2"&gt;Creating &lt;a href="http://go.microsoft.com/fwlink/?LinkID=113231"&gt;functions&lt;/a&gt; in &lt;/font&gt;&lt;font size="2"&gt;PowerShell&lt;/font&gt;&lt;font size="2"&gt; is relatively a simple operation. You declare the function’s name and value, press the Enter key and you’re good to go. &lt;/font&gt;&lt;font style="font-family:Tahoma, Arial, Helvetica;font-size:13px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;orphans:2;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;widows:2;word-spacing:0px;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0px;"&gt;It is also very simple to override the function just by re-creating it; t&lt;/font&gt;&lt;font style="font-family:Tahoma, Arial, Helvetica;font-size:13px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;orphans:2;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;widows:2;word-spacing:0px;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0px;"&gt;hat’s all it takes, simple and easy.&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;What if you need to prevent that from happening? You don’t want to allow someone or something from overriding your functions? &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2011/08/31/get-your-game-on-leverage-proxy-functions-in-windows-powershell.aspx"&gt;&lt;font size="2"&gt;PowerShell&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; gives us the option to do that via a dynamic parameter. &lt;a href="http://go.microsoft.com/fwlink/?LinkID=135173"&gt;Dynamic parameters&lt;/a&gt; are cmdlet parameters that are added by a Windows PowerShell provider and are available only when the cmdlet is being used in the provider-enabled drive. The &lt;i&gt;Options&lt;/i&gt; dynamic parameter is supported by &lt;/font&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkID=113353"&gt;&lt;font size="2"&gt;New-Item&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; and &lt;/font&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkID=113395"&gt;&lt;font size="2"&gt;Set-Item&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; when you use them with the Alias,Variable or Function providers.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;The &lt;i&gt;Options&lt;/i&gt; parameter &amp;lt;System.Management.Automation.ScopedItemOptions&amp;gt; possible values:&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;&lt;font size="2"&gt;None - &lt;/font&gt;&lt;/b&gt;&lt;font size="2"&gt;No options. &amp;quot;None&amp;quot; is the default.&lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;&lt;b&gt;Private&lt;/b&gt; - &lt;/font&gt;&lt;font size="2"&gt;The function is visible only in the current scope (not in child scopes).&lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;&lt;b&gt;ReadOnly&lt;/b&gt; - &lt;/font&gt;&lt;font size="2"&gt;The properties of the function cannot be changed except by using the Force parameter. You can use &lt;/font&gt;&lt;a href="http://technet.microsoft.com/en-us/library/dd315401.aspx" id="ctl00_MTCS_main_ctl20"&gt;&lt;font size="2"&gt;Remove-Item&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; to delete the function.&lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;&lt;b&gt;Constant&lt;/b&gt; - &lt;/font&gt;&lt;font size="2"&gt;The function cannot be deleted, and its properties cannot be changed. Constant is available only when you are creating a function. You cannot change the option of an existing function to Constant.&lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2"&gt;&lt;b&gt;AllScope&lt;/b&gt; - &lt;/font&gt;&lt;font size="2"&gt;The function is copied to any new scopes that are created.&lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;   &lt;br /&gt;&lt;font size="2"&gt;Let’s see how we can protect a function, we’ll start by marking it Read only. &lt;/font&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;# create a function&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;PS&amp;gt; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;function test { &amp;quot;I&amp;#39;m a read-only function&amp;quot; }&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;# set it as readonly&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;PS&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt; Set-Item –Path Function:test –Options ReadOnly&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;# try to update the function definition&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;PS&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt; function test { &amp;quot;new value&amp;quot; }&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;Cannot write to function test because it is read-only or constant.&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;At line:8 char:1&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;+ function test { &amp;quot;new value&amp;quot; }&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:9pt;"&gt;+ CategoryInfo&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;: WriteError: (test:String) [], SessionStateUnauthorizedAccessException&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:9pt;"&gt;+ FullyQualifiedErrorId : FunctionNotWritable &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;We get an error when we try to update the function. Let’s try to override it with the Force switch:&lt;/font&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;PS&amp;gt; Set-Item –Path Function:test -Value { &amp;quot;new value&amp;quot; } -Force&lt;br /&gt;PS&amp;gt; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;test&lt;br /&gt;&lt;br /&gt; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;new value&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt; &lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font color="#ff0000" face="Lucida Console"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;This time we don’t get the error and the function has been updated. If ReadOnly is not enough and doesn’t really protect the function like we want to, then we can set another value. This time let’s try to make it constant.&lt;/font&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;PS&amp;gt; Set-Item –Path Function:test -Value { &amp;quot;I&amp;#39;m constant&amp;quot; } -Options Constant -Force&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;Set-Item : Existing function test cannot be made constant. Functions can be made constant only at creation time.&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;At line:1 char:1&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;+ Set-Item –Path Function:test -Value { &amp;quot;I&amp;#39;m constant&amp;quot; } -Options Constant -Force&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:9pt;"&gt;+ CategoryInfo&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;: WriteError: (test:String) [Set-Item], SessionStateUnauthorizedAccessException&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:9pt;"&gt;+ FullyQualifiedErrorId : FunctionCannotBeMadeConstant,Microsoft.PowerShell.Commands.SetItemCommand&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt; &lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#f5f5f5"&gt;&lt;font style="font-size:9pt;"&gt;PS&amp;gt;&lt;/font&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:9pt;"&gt;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;We get an error that functions can be made constant only at creation time. Let’s create a new function and then try to override it and remove it:&lt;/font&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;PS C:\&amp;gt; # create a constant function&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;# # create a constant function         &lt;br /&gt;PS&amp;gt; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;New-Item –Path Function:test2 -Value { &amp;quot;I&amp;#39;m constant&amp;quot; } -Options Constant&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font color="#f5f5f5" face="Lucida Console"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#f5f5f5"&gt;&lt;font style="font-size:9pt;"&gt;Capability&lt;span style="mso-spacerun:yes;"&gt; &lt;/span&gt;Name ModuleName&lt;/font&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:9pt;"&gt; &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#f5f5f5"&gt;&lt;font style="font-size:9pt;"&gt;----------&lt;span style="mso-spacerun:yes;"&gt; &lt;/span&gt;---- ----------&lt;span style="mso-spacerun:yes;"&gt; &lt;/span&gt;&lt;/font&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:9pt;"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#f5f5f5"&gt;&lt;font style="font-size:9pt;"&gt;Script&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:9pt;"&gt; test2 &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;# try to update the function&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;PS&amp;gt; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;Set-Item –Path Function:test2 -Value { &amp;quot;I&amp;#39;m constant 2&amp;quot; } -Force&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;# try to remove it&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;PS&amp;gt; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;Remove-Item Path Function:test2 -Force&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;Set-Item : Cannot write to function test2 because it is read-only or constant.&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;At line:5 char:1&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;+ Set-Item –Path Function:test2 -Value { &amp;quot;I&amp;#39;m constant 2&amp;quot; } -Force&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:9pt;"&gt;+ CategoryInfo&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp; &lt;/span&gt;: WriteError: (test2:String) [Set-Item], SessionStateUnauthorizedAccessException&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:9pt;"&gt;+ FullyQualifiedErrorId : FunctionNotWritable,Microsoft.PowerShell.Commands.SetItemCommand&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;Remove-Item : A positional parameter cannot be found that accepts argument &amp;#39;Function:test2&amp;#39;.&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;At line:8 char:1&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;+ Remove-Item Path Function:test2 -Force&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:9pt;"&gt;+ CategoryInfo&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;: InvalidArgument: (:) [Remove-Item], ParameterBindingException&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:9pt;"&gt;+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#f5f5f5"&gt;&lt;font style="font-size:9pt;"&gt;PS&amp;gt;&lt;/font&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:9pt;"&gt;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;font size="2"&gt;&lt;font color="#ff0000"&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#ff0000" size="2"&gt;&lt;/font&gt;&lt;/p&gt;   &lt;font color="#ff0000"&gt;&lt;font color="#000000" size="2"&gt;As you can see none of the above changes the function. It is protected and the only option to get rid of it is by closing the shell.&lt;/font&gt;&lt;/font&gt;&amp;nbsp;  &lt;p&gt;&lt;font size="2"&gt;In addition to Aliases and Functions, we can also protect other objects, like: variables and modules. For variables use the &lt;/font&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkID=113401"&gt;&lt;font size="2"&gt;Set-Variable&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; cmdlet, it has its own options parameter. To protect modules from being unloaded we need to set the module’s AccessMode property. Here’s an example using dynamic module.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;PS&amp;gt; New-Module -Name CantTouchThis -ScriptBlock { &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#f5f5f5"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:9pt;"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:9pt;"&gt;$ExecutionContext.SessionState.Module.AccessMode = &amp;#39;constant&amp;#39; &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;} | Import-Module &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;Remove-Module -Name CantTouchThis -Force &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;Remove-Module : Unable to remove module &amp;#39;CantTouchThis&amp;#39; because it is marked as constant. A module cannot be removed if it is marked constant.&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;At line:5 char:1&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;+ Remove-Module -Name CantTouchThis -Force&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:9pt;"&gt;+ CategoryInfo&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;: PermissionDenied: (CantTouchThis:PSModuleInfo) [Remove-Module], InvalidOperationException&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:9pt;"&gt;+ FullyQualifiedErrorId : Modules_ModuleIsConstant,Microsoft.PowerShell.Commands.RemoveModuleCommand&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;Remove-Module : No modules were removed. Verify that the specification of modules to remove is correct and those modules exist in the runspace.&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;At line:5 char:1&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;+ Remove-Module -Name CantTouchThis -Force&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:9pt;"&gt;+ CategoryInfo&lt;span style="mso-spacerun:yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;: ResourceUnavailable: (:) [Remove-Module], InvalidOperationException&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font color="#ff0000"&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font style="font-size:9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;font style="font-size:9pt;"&gt;+ FullyQualifiedErrorId : Modules_NoModulesRemoved,Microsoft.PowerShell.Commands.RemoveModuleCommand&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="mso-spacerun:yes;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#ff0000"&gt; &lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin:0cm 0cm 0pt;background:#012456;mso-layout-grid-align:none;" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family:&amp;#39;Lucida Console&amp;#39;;"&gt;&lt;font face="Lucida Console"&gt;&lt;font style="font-size:9pt;" color="#f5f5f5"&gt;PS&amp;gt; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I would like to have another way to create constant functions or modules so I logged two suggestions on Microsoft&amp;#39;s Connect website, one for &lt;a href="https://connect.microsoft.com/PowerShell/feedback/details/733277/creating-functions-that-cannot-be-overwritten-or-removed"&gt;functions &lt;/a&gt;and another one for &lt;a href="https://connect.microsoft.com/PowerShell/feedback/details/730425/psmoduleinfo-accessmode"&gt;modules&lt;/a&gt;, vote them up and maybe we&amp;#39;ll get them in v4 :)&lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=994833" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/ITPRO/default.aspx">ITPRO</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/Protecting/default.aspx">Protecting</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/Options/default.aspx">Options</category></item><item><title>Custom objects default display in PowerShell 3.0</title><link>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/04/13/Custom-objects-default-display-in-PowerShell-3-0.aspx</link><pubDate>Fri, 13 Apr 2012 20:00:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1058277</guid><dc:creator>ScriptFanatic</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/scriptfanatic/rsscomments.aspx?PostID=1058277</wfw:commentRss><comments>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/04/13/Custom-objects-default-display-in-PowerShell-3-0.aspx#comments</comments><description>&lt;p&gt;In &lt;a href="http://www.microsoft.com/download/en/details.aspx?id=27548"&gt;PowerShell 3.0&lt;/a&gt; we can now create new custom objects using a hash table. &lt;/p&gt;  &lt;pre style="background:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; [PSCustomObject]@{
   One = 1 
   Two = 2 
   Three = 3 
   Four = 4 
   Five = 5 
}


One   : 1
Two   : 2
Three : 3
Four  : 4
Five  : 5&lt;/font&gt; &lt;/pre&gt;

&lt;p&gt;Behind the scenes, PowerShell creates a hash table and wraps it a PSCustomObject. It is way faster than using the &lt;a href="http://go.microsoft.com/fwlink/?LinkID=113355"&gt;New-Object&lt;/a&gt; cmdlet and it also provides consistency, while maintaining backwards compatibility. Another benefit of using PSCustomObject over New-Object is property order. PSCustomObject preserve the order of defined properties while New-Object doesn&amp;#39;t.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;pre style="background:#012456;"&gt;&lt;font color="#ffffff"&gt;PS &amp;gt; [PSCustomObject]@{One=1;Two=2;Three=3} 

One Two Three
--- --- -----
  1   2     3


PS &amp;gt; New-Object PSObject -Property @{One=1;Two=2;Three=3}

One Three Two
--- ----- ---
  1     3   2&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;Notice that when the new PSCustomObject is returned, all of its properties are displayed in the console. We can control the default display property set of an object by setting a DefaultDisplayPropertySet. &lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;pre style="background:#012456;"&gt;&lt;font color="#ffffff"&gt;$psco = [PSCustomObject]@{
   One = 1
   Two = 2
   Three = 3
   Four = 4
   Five = 5 
}

 
[string[]]$DefaultProperties = &amp;#39;Two&amp;#39;,&amp;#39;Four&amp;#39;,&amp;#39;Five&amp;#39;

# Add the PSStandardMembers.DefaultDisplayPropertySet member
$ddps = New-Object System.Management.Automation.PSPropertySet `&lt;br /&gt;         DefaultDisplayPropertySet,$DefaultProperties
$PSStandardMembers = [System.Management.Automation.PSMemberInfo[]]$ddps 

# Attach default display property set
$psco | Add-Member -MemberType MemberSet -Name PSStandardMembers `&lt;br /&gt;         -Value $PSStandardMembers -PassThru&lt;/font&gt;



&lt;font color="#ffffff"&gt;Two Four Five
--- ---- ----
  2    4    5&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;We can also define the properties of the type that will be displayed by default with the formatting cmdlets.&lt;/p&gt;

&lt;pre style="background:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; Get-Date | Format-List 
PS&amp;gt; Update-TypeData -TypeName System.DateTime -DefaultDisplayPropertySet `&lt;br /&gt;       DateTime,DayOfWeek,Year,Month,Day 
PS&amp;gt; Get-Date | Format-List 

DisplayHint : DateTime
Date        : 4/9/2012 12:00:00 AM
Day         : 9
DayOfWeek   : Monday
DayOfYear   : 100
Hour        : 8
Kind        : Local
Millisecond : 598
Minute      : 15
Month       : 4
Second      : 38
Ticks       : 634695561385980985
TimeOfDay   : 08:15:38.5980985
Year        : 2012
DateTime    : Monday, April 09, 2012 8:15:38 AM


DateTime  : Monday, April 09, 2012 8:15:39 AM
DayOfWeek : Monday
Year      : 2012
Month     : 4
Day       : 9
&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;I have put together a function that wraps the process of creating a new PSCustomObject and specifying a list of default properties to display.&lt;/p&gt;

&lt;pre style="background:#012456;"&gt;&lt;font color="#ffffff"&gt;function New-PSCustomObject
{
       [CmdletBinding()] 

       param(
              [Parameter(Mandatory,Position=0)]
              [ValidateNotNullOrEmpty()]
              [System.Collections.Hashtable]$Property,

              [Parameter(Position=1)]
              [ValidateNotNullOrEmpty()]
              [Alias(&amp;#39;dp&amp;#39;)]
              [System.String[]]$DefaultProperties
       )


       $psco = [PSCustomObject]$Property 

       # define a subset of properties
       $ddps = New-Object System.Management.Automation.PSPropertySet `&lt;br /&gt;                DefaultDisplayPropertySet,$DefaultProperties
       $PSStandardMembers = [System.Management.Automation.PSMemberInfo[]]$ddps 

       # Attach default display property set
       $psco | Add-Member -MemberType MemberSet -Name PSStandardMembers `&lt;br /&gt;                -Value $PSStandardMembers -PassThru
}&lt;br /&gt;
# usage example
# define 5 properties 
PS&amp;gt; $property = @{Name=&amp;#39;My Object&amp;#39;;One=1;Two=2;Three=3;Four=4} 

# create the object and set just three properties for default display
PS&amp;gt; New-PSCustomObject -Property $property -DefaultProperties Name,Two,Four 

Two Four Five
--- ---- ----
  2    4    5&lt;/font&gt;&lt;/pre&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1058277" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/ITPRO/default.aspx">ITPRO</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/Formatting/default.aspx">Formatting</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShellV3/default.aspx">PowerShellV3</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PSCustomObject/default.aspx">PSCustomObject</category></item><item><title>Add-Member enhancements in PowerShell 3.0</title><link>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/04/11/add-member-enhancements-in-powershell-3-0.aspx</link><pubDate>Wed, 11 Apr 2012 20:00:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1058187</guid><dc:creator>ScriptFanatic</dc:creator><slash:comments>40</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/scriptfanatic/rsscomments.aspx?PostID=1058187</wfw:commentRss><comments>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/04/11/add-member-enhancements-in-powershell-3-0.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://www.microsoft.com/download/en/details.aspx?id=27548"&gt;PowerShell&lt;/a&gt;&lt;a href="http://www.microsoft.com/download/en/details.aspx?id=27548"&gt; 3.0&lt;/a&gt; offers new ways to add Note properties to objects. In PowerShell 2.0, a typical command to do that would look like:&lt;/p&gt;  &lt;pre style="background:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; New-Object -TypeName PSObject | 
Add-Member -MemberType NoteProperty -Name One -Value 1 -PassThru

One
---
  1&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;And when adding multiple note properties:&lt;/p&gt;

&lt;pre style="background:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; New-Object -TypeName PSObject | 
      Add-Member -MemberType NoteProperty -Name One -Value 1 -PassThru | 
      Add-Member -MemberType NoteProperty -Name Two -Value 2 -PassThru | 
      Add-Member -MemberType NoteProperty -Name Three -Value 3 -PassThru


One Two Three
--- --- -----
  1   2     3&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;As you can see the syntax was very long and each time you created a NoteProperty you had to specify that. In Powershell 3.0 &lt;a href="http://go.microsoft.com/fwlink/?LinkID=113280"&gt;Add-Member&lt;/a&gt; have to new parameters: NotePropertyName and NotePropertyValue. Now you can easily add a NoteProperty without having to specify the member type and without having to specify parameter names, we take advantage of their positional value. &lt;/p&gt;

&lt;pre style="background:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; New-Object -TypeName PSObject | Add-Member One 1

One
---
  1&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;To add multiple NoteProperty we can now use a hashtable: &lt;/p&gt;

&lt;pre style="background:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; New-Object -TypeName PSObject | Add-Member @{One=1; Two=2; Three=3} -PassThru

One Three Two
--- ----- ---
  1     3   2&lt;/font&gt;&lt;/pre&gt;

&lt;br /&gt;

&lt;p&gt;Notice that the object we got back didn&amp;#39;t preserve the order of properties defined in the hashtable. Order in a dictionary is defined the moment you create it and the regular hashtable syntax @{} is an unordered dictionary. To make sure properties are listed in the order we defined them, we use an ordered hashtable. &lt;/p&gt;

&lt;pre style="background:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; $pso = New-Object -TypeName PSObject&lt;br /&gt;PS&amp;gt; $pso | Add-Member ([ordered]@{One=1; Two=2; Three=3}) -PassThru

One Two Three
--- --- -----
  1   2     3
&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;Finally, there&amp;#39;s another interesting new parameter: TypeName. We can use it to specify a name for the resultant object type. This is very useful when you use &lt;a href="http://go.microsoft.com/fwlink/?LinkID=113230"&gt;format files&lt;/a&gt; to define the default display of your objects. Previously we had to add the type name to the object&amp;#39;s PSTypeNames list, now it is even easier.&lt;/p&gt;

&lt;pre style="background:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; $pso = New-Object -TypeName PSObject 
PS&amp;gt; $pso | Add-Member ([ordered]@{One=1; Two=2; Three=3}) -TypeName MyType.MyObject &lt;br /&gt;PS&amp;gt; $pso | Get-Member

   TypeName: &lt;b&gt;MyType.MyObject&lt;/b&gt;

Name        MemberType   Definition                    
----        ----------   ----------                    
Equals      Method       bool Equals(System.Object obj)
GetHashCode Method       int GetHashCode()             
GetType     Method       type GetType()                
ToString    Method       string ToString()             
One         NoteProperty System.Int32 One=1            
Three       NoteProperty System.Int32 Three=3          
Two         NoteProperty System.Int32 Two=2            &lt;/font&gt;&lt;/pre&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1058187" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/ITPRO/default.aspx">ITPRO</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShellV3/default.aspx">PowerShellV3</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/Add-Member/default.aspx">Add-Member</category></item><item><title>Measuring objects in PowerShell 3.0</title><link>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/04/09/Measuring-objects-in-PowerShell-3-0.aspx</link><pubDate>Mon, 09 Apr 2012 14:03:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1058852</guid><dc:creator>ScriptFanatic</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/scriptfanatic/rsscomments.aspx?PostID=1058852</wfw:commentRss><comments>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/04/09/Measuring-objects-in-PowerShell-3-0.aspx#comments</comments><description>&lt;p&gt;The &lt;a href="http://go.microsoft.com/fwlink/?LinkID=113349"&gt;Measure-Object&lt;/a&gt; cmdlet gives us a great way to find minimum and maximum values in a collection of objects. For example, if we want to know the smallest and largest size of a file in the current directory:     &lt;br /&gt;&lt;/p&gt;  &lt;pre style="background:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; Get-ChildItem | Measure-Object -Property Length -Minimum -Maximum

Count    : 2751
Average  :
Sum      :
Maximum  : 56297240
Minimum  : 35
Property : Length&lt;/font&gt;&lt;/pre&gt;

&lt;br /&gt;

&lt;p&gt;In PowerShell 2.0 it only worked with numeric properties (integers), we couldn&amp;#39;t use it to compare properties like LastWriteTime (DateTime). In &lt;a href="http://www.microsoft.com/download/en/details.aspx?id=27548"&gt;PowerShell 3.0&lt;/a&gt; we can now use the Minimum and Maximum parameters to work with anything that is &lt;a href="http://msdn.microsoft.com/en-us/library/system.icomparable.aspx"&gt;IComparable&lt;/a&gt;. We can tell if an instance of an object is IComparable by checking if the CompareTo method exist on the instance:&lt;/p&gt;

&lt;pre style="background:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; $object.PSObject.Methods | Where-Object {$_.Name -eq &amp;#39;CompareTo&amp;#39;}&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;But there&amp;#39;s a simpler way using the -is operator. If we get $true - we can measure it:&lt;/p&gt;

&lt;pre style="background:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; $object -is [IComparable]&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;In this example we measure the LastWriteTime property, which is a DateTime object. We can see the modification time of the oldest and newest files in the current directory.&lt;/p&gt;

&lt;pre style="background:#012456;"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; Get-ChildItem | Measure-Object -Property LastWriteTime -Minimum -Maximum

Count    : 2844
Average  :
Sum      :
Maximum  : 4/8/2012 8:03:32 PM
Minimum  : 9/4/2004 3:00:00 AM
Property : LastWriteTime&lt;/font&gt;&lt;/pre&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1058852" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/Measure/default.aspx">Measure</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/ITPRO/default.aspx">ITPRO</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShellV3/default.aspx">PowerShellV3</category></item><item><title>Leveraging Proxy Functions in PowerShell</title><link>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/03/30/leveraging-proxy-functions-in-powershell.aspx</link><pubDate>Fri, 30 Mar 2012 19:27:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1049109</guid><dc:creator>ScriptFanatic</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/scriptfanatic/rsscomments.aspx?PostID=1049109</wfw:commentRss><comments>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/03/30/leveraging-proxy-functions-in-powershell.aspx#comments</comments><description>&lt;p&gt;&lt;a href="https://twitter.com/#%21/DSotnikov/"&gt;@DSotnikov&lt;/a&gt; just released the video recording of the session from the PowerShell Deep Dive in Frankfurt (last year). In this video, &lt;a href="http://poshoholic.com/"&gt;MVP Kirk Munro (&lt;/a&gt;&lt;a href="http://poshoholic.com/"&gt;poshoholic&lt;/a&gt;&lt;a href="http://poshoholic.com/"&gt;)&lt;/a&gt; and I demoed a project we&amp;#39;ve been working on that let&amp;#39;s you create proxy functions. Here&amp;#39;s a reminder of the session abstract.&lt;/p&gt;  &lt;p&gt;&lt;i&gt;In this session as they take a deep dive into proxy functions in PowerShell. Shay and Kirk have been working together on PowerShell Proxy Extensions, a powerful module that leverages proxy functions and makes it easier than ever to create these powerful extensions to PowerShell. They will demonstrate what proxy functions are and why they are important, and then show how a little scripting savvy (and a really long script) can make your life easier by allowing you to create everything from very simple proxy functions that extend PowerShell to more complex proxy functions that override existing commands, fixing bugs and adding missing features at the same time, all while leveraging inline help as much as possible.&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;The module we demoed is available at &lt;a href="http://pspx.codeplex.com/" title="http://pspx.codeplex.com/"&gt;http://pspx.codeplex.com/&lt;/a&gt;. Unfortunately I won&amp;#39;t be able to make it this year to the &lt;a href="http://www.theexpertsconference.com/us/2012/powershell-deep-dive/"&gt;Deep Dive in San Diego&lt;/a&gt;, but if you&amp;#39;re attending you&amp;#39;ll get the chance to see the module in action, plus a very cool project, written on top of the &lt;a href="http://pspx.codeplex.com/"&gt;PowerShell Proxy Extensions (PSPX&lt;/a&gt;) module.&lt;/p&gt; &lt;iframe src="http://www.youtube.com/embed/X80AZuETB9Q" frameborder="0" height="315" width="520"&gt;&lt;/iframe&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1049109" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/ITPRO/default.aspx">ITPRO</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/TEC/default.aspx">TEC</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/TEC2011/default.aspx">TEC2011</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/IT/default.aspx">IT</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/Proxy+Functions/default.aspx">Proxy Functions</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/Functions/default.aspx">Functions</category></item><item><title>Counting objects in PowerShell 3.0</title><link>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/03/19/Counting-objects-in-PowerShell-3.0.aspx</link><pubDate>Mon, 19 Mar 2012 19:31:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:1037766</guid><dc:creator>ScriptFanatic</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/scriptfanatic/rsscomments.aspx?PostID=1037766</wfw:commentRss><comments>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/03/19/Counting-objects-in-PowerShell-3.0.aspx#comments</comments><description>&lt;p&gt;Consider the following command, how many objects are in $dir?&lt;/p&gt;  &lt;pre style="background-color:#012456;" class="PowerShellColorizedScript"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; $dir = Get-ChildItem&lt;br /&gt; &lt;/font&gt;&lt;font color="#ffffff"&gt;
&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;The most common way to find it is to check the Count property:&lt;/p&gt;

&lt;pre style="background-color:#012456;" class="PowerShellColorizedScript"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; &lt;font color="#ffffff"&gt;$dir.Count&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;But… the Count property is available only if Get-Something returns more than one object (array/collection), If the result has one object only (scalar) the Count property returns nothing, not even zero. If the result contains more than one object, the objects are accumulated in an Array (collection), and Arrays have a Count property so we get the number of objects. &lt;/p&gt;

&lt;p&gt;Now back to the question above, how can we safely determine object count? The most common solution was to use the @(…) array construction to force the result to an array:&lt;/p&gt;

&lt;pre style="background-color:#012456;" class="PowerShellColorizedScript"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; @($dir).Count&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;Now Count will return 0 or another positive number. Although we could get object count this way, it was very irritating and tedious to always make sure to convert the output!&lt;/p&gt;

&lt;p&gt;In &lt;a href="http://www.microsoft.com/download/en/details.aspx?id=27548"&gt;PowerShell 3.0&lt;/a&gt; &lt;b&gt;the saga ends&lt;/b&gt;! We are no longer required to convert the result. The magicians at Microsoft had spread some of their magic powder and now the Count property is available on single objects as well!&lt;/p&gt;

&lt;pre style="background-color:#012456;" class="PowerShellColorizedScript"&gt;&lt;font color="#ffffff"&gt;# get the process that is hosting the current Windows PowerShell session 
PS&amp;gt; $ps = Get-Process -Id $PID 
PS&amp;gt; $ps.Count
1
&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;
  &lt;br /&gt;If you try to use tab completion on a single object, Count will not be one of the options and it is also not visible to the &lt;a href="http://go.microsoft.com/fwlink/?LinkID=113322"&gt;Get-Member&lt;/a&gt; cmdlet, you need to explicitly write it in order to get the value. &lt;/p&gt;

&lt;p&gt;One more thing to notice is when the command didn’t return any objects($null result). Unlike other languages, $null in PowerShell “has” a Count property, and it makes sense. If you base you script on the Count property you may get 0 or 1 or more objects. In the case of the former, $null.count gives back 0.&lt;/p&gt;

&lt;p&gt;Enjoy!&lt;/p&gt;

&lt;div class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_button_google_plusone"&gt;&lt;/a&gt;&lt;a class="addthis_button_print"&gt;&lt;/a&gt;&lt;a class="addthis_button_linkedin"&gt;&lt;/a&gt;&lt;a class="addthis_button_gmail"&gt;&lt;/a&gt;&lt;a class="addthis_button_googletranslate"&gt;&lt;/a&gt;&lt;a class="addthis_button_hotmail"&gt;&lt;/a&gt;&lt;a class="addthis_button_preferred_1"&gt;&lt;/a&gt;&lt;a class="addthis_button_preferred_2"&gt;&lt;/a&gt;&lt;a class="addthis_button_preferred_3"&gt;&lt;/a&gt;&lt;a class="addthis_button_favorites"&gt;&lt;/a&gt;&lt;a class="addthis_button_email"&gt;&lt;/a&gt;&lt;a class="addthis_button_compact"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_bubble_style"&gt;&lt;/a&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt;var addthis_config = {&amp;quot;data_track_clickback&amp;quot;:true};&lt;/script&gt;&lt;script src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=shaylevy" type="text/javascript"&gt;&lt;/script&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=1037766" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShellV3/default.aspx">PowerShellV3</category></item><item><title>Auto reconnect to a server you just rebooted with PowerShell 3.0</title><link>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/01/08/Auto-reconnect-to-a-server-you-just-rebooted-with-PowerShell-3.0.aspx</link><pubDate>Sun, 08 Jan 2012 22:51:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:982663</guid><dc:creator>ScriptFanatic</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/scriptfanatic/rsscomments.aspx?PostID=982663</wfw:commentRss><comments>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2012/01/08/Auto-reconnect-to-a-server-you-just-rebooted-with-PowerShell-3.0.aspx#comments</comments><description>&lt;p&gt;Yesterday I saw a tweet that caught my eye: &lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/scriptfanatic/image_32993CCD.png"&gt;&lt;img style="BACKGROUND-IMAGE:none;BORDER-RIGHT-WIDTH:0px;PADDING-LEFT:0px;PADDING-RIGHT:0px;DISPLAY:inline;BORDER-TOP-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-LEFT-WIDTH:0px;PADDING-TOP:0px;" title="image" border="0" alt="image" src="http://blogs.microsoft.co.il/blogs/scriptfanatic/image_thumb_17806DBF.png" width="571" height="252" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Sounds familiar? What do you usually do to reconnect to your server once it is back online? How do you monitor it’s availability? &lt;a href="http://www.justaprogrammer.net/2012/01/07/making-an-rdp-connection-to-a-server-you-just-rebooted-with-powershell/"&gt;In this post&lt;/a&gt;, Justin shares a great function (115 lines) that restarts a server, waits for it to come back online and then starts a remote desktop connection to it.&lt;/p&gt;
&lt;p&gt;Now, what if I told you that in &lt;a href="http://www.microsoft.com/download/en/details.aspx?id=27548"&gt;PowerShell 3.0&lt;/a&gt; you can replace that function with only two lines of code? &lt;/p&gt;
&lt;p&gt;In PowerShell 3.0, the Restart-Computer cmdlet got improved (mainly to support Workflow scenarios) and it now supports a few more parameters, notably the –Wait and –For parameters. When –Wait is specified, the command waits for all of the following service types to be available (can take a lot of time) before you can proceed to the next line of code. The following command lists the service types: &lt;/p&gt;&lt;pre style="BACKGROUND-COLOR:#012456;" class="PowerShellColorizedScript"&gt;&lt;font color="#ffffff"&gt;PS&amp;gt; [Enum]::GetNames&lt;/span&gt;&lt;/font&gt;&lt;font color="#ffffff"&gt;&lt;span style="COLOR:#000000;"&gt;&lt;font color="#ffffff"&gt;(‘Microsoft.PowerShell.Commands.WaitForServiceTypes’)&lt;/font&gt;&lt;br /&gt;&lt;/span&gt;Wmi
WinRM
PowerShell&lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;Actually, these types are the possible values of the –For parameter. In the previous CTP version, there used to be a ‘Network’ type too, but looks like it was removed. We can specify one of above types, Restart-Computer waits for that component only to be available and then the rest of our code is executed.&lt;/p&gt;
&lt;p&gt;In our case, we need to wait for the Remote Desktop Services service to start, but there’s no related service type we can use for that. We can wait for the ‘Wmi’ service. That’s because the WMI and the RDS services are dependent on the Remote Procedure Call (RPC) service, so if the WMI service is started we can assume that the RDS service is up as well.&lt;/p&gt;&lt;pre style="BACKGROUND-COLOR:#012456;" class="PowerShellColorizedScript"&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkID=135253"&gt;&lt;font color="#ffffff"&gt;Restart-Computer&lt;/font&gt;&lt;/a&gt;&lt;font color="#ffffff"&gt; &lt;/span&gt;–ComputerName &lt;/span&gt;Server1&lt;/span&gt;&lt;font color="#ffffff"&gt; -Wait&lt;/span&gt; &lt;/font&gt;&lt;span style="COLOR:#000080;"&gt;&lt;font color="#ffffff"&gt;-For &lt;/font&gt;&lt;font color="#ffffff"&gt;Wmi –Force&lt;/font&gt;&lt;/span&gt;             
mstsc –v&lt;/span&gt; Server1 /admin&lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;That’s all it takes to connect to Server1 once it’s back online. Notice that the Restart-Computer command may fail if there are users logged on to the remote computer or if there are opened applications, so make sure you include the –Force switch. One “caveat” though, the command waits until the computer has finished restarting and doesn’t give back your prompt, you’re stuck waiting for it to finish. To continue working you can spin a new background job:&lt;/p&gt;&lt;pre style="BACKGROUND-COLOR:#012456;" class="PowerShellColorizedScript"&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkID=113405"&gt;&lt;font color="#ffffff"&gt;Start-Job&lt;/font&gt;&lt;/a&gt;&lt;font color="#ffffff"&gt; -ScriptBlock{&lt;/span&gt;             
    &lt;/font&gt;&lt;span style="COLOR:#0000ff;"&gt;&lt;font color="#ffffff"&gt;Restart-Computer –ComputerName $args[0] -Wait -For Wmi–Force           
    mstsc -v $args[0] /admin             
} -ArgumentList Server1&lt;/font&gt;&lt;/pre&gt;
&lt;div class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_button_google_plusone"&gt;&lt;/a&gt;&lt;a class="addthis_button_print"&gt;&lt;/a&gt;&lt;a class="addthis_button_linkedin"&gt;&lt;/a&gt;&lt;a class="addthis_button_gmail"&gt;&lt;/a&gt;&lt;a class="addthis_button_googlereader"&gt;&lt;/a&gt;&lt;a class="addthis_button_hotmail"&gt;&lt;/a&gt;&lt;a class="addthis_button_preferred_1"&gt;&lt;/a&gt;&lt;a class="addthis_button_preferred_2"&gt;&lt;/a&gt;&lt;a class="addthis_button_preferred_3"&gt;&lt;/a&gt;&lt;a class="addthis_button_favorites"&gt;&lt;/a&gt;&lt;a class="addthis_button_email"&gt;&lt;/a&gt;&lt;a class="addthis_button_compact"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_bubble_style"&gt;&lt;/a&gt;&lt;/div&gt;&lt;/span&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=982663" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/ITPRO/default.aspx">ITPRO</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/RDS/default.aspx">RDS</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShellV3/default.aspx">PowerShellV3</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/Restart-Computer/default.aspx">Restart-Computer</category></item><item><title>PSRR - Remote Registry PowerShell 3.0 Module</title><link>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2011/11/02/psrr-remote-registry-powershell-3.0-module.aspx</link><pubDate>Wed, 02 Nov 2011 17:00:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:923927</guid><dc:creator>ScriptFanatic</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/scriptfanatic/rsscomments.aspx?PostID=923927</wfw:commentRss><comments>http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2011/11/02/psrr-remote-registry-powershell-3.0-module.aspx#comments</comments><description>&lt;div class="addthis_toolbox addthis_default_style "&gt;&lt;a class="addthis_button_facebook_like"&gt;&lt;/a&gt;&lt;a class="addthis_button_tweet"&gt;&lt;/a&gt;&lt;a class="addthis_button_google_plusone"&gt;&lt;/a&gt;&lt;a class="addthis_button_print"&gt;&lt;/a&gt;&lt;a class="addthis_button_linkedin"&gt;&lt;/a&gt;&lt;a class="addthis_button_gmail"&gt;&lt;/a&gt;&lt;a class="addthis_button_googlereader"&gt;&lt;/a&gt;&lt;a class="addthis_button_hotmail"&gt;&lt;/a&gt;&lt;a class="addthis_button_preferred_1"&gt;&lt;/a&gt;&lt;a class="addthis_button_preferred_2"&gt;&lt;/a&gt;&lt;a class="addthis_button_preferred_3"&gt;&lt;/a&gt;&lt;a class="addthis_button_favorites"&gt;&lt;/a&gt;&lt;a class="addthis_button_email"&gt;&lt;/a&gt;&lt;a class="addthis_button_compact"&gt;&lt;/a&gt;&lt;a class="addthis_counter addthis_bubble_style"&gt;&lt;/a&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt;var addthis_config = {&amp;quot;data_track_clickback&amp;quot;:true};&lt;/script&gt;&lt;script src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=shaylevy" type="text/javascript"&gt;&lt;/script&gt;
&lt;p&gt;&lt;a href="http://psrr.codeplex.com/"&gt;&lt;img src="http://blogs.microsoft.co.il/blogs/scriptfanatic/PSRemoteRegistry_12E76DFA.png" style="background-image:none;border-bottom:0px;border-left:0px;margin:0px 10px 0px 0px;padding-left:0px;padding-right:0px;display:inline;float:left;border-top:0px;border-right:0px;padding-top:0px;" title="PSRemoteRegistry" alt="PSRemoteRegistry" align="left" border="0" height="84" width="123" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;One of the new improvements in the .NET Framework version 4 is the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.win32.registryview.aspx"&gt;Microsoft.Win32.RegistryView&lt;/a&gt; enumeration. &lt;/p&gt;  &lt;p&gt;On the 64-bit version of Windows, portions of the registry are stored separately for 32-bit and 64-bit applications. There is a 32-bit view for 32-bit applications and a 64-bit view for 64-bit applications. Many of the 32-bit keys have the same names as their 64-bit counterparts, and vice versa. In the 64-bit version of Registry Editor, 32-bit keys are displayed under the following registry key: HKEY_LOCAL_MACHINE\Software\WOW6432Node.&lt;/p&gt;  &lt;p&gt;I’m pleased to announce that the &lt;a href="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2010/01/10/remote-registry-powershell-module.aspx"&gt;PSRemoteRegistry&lt;/a&gt; module has a new version &lt;b&gt;specifically &lt;/b&gt;for PowerShell v3 that implements the new feature mentioned above. The new module, now called PSRR (to avoid name collisions with the previous module and to allow you to type less when you load it), was rewritten and is using &lt;a href="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2011/10/24/New-advanced-functions-language-features-in-PowerShell-v3.aspx"&gt;the new language features introduced in PowerShell v3&lt;/a&gt;. To improve the readability of the functions, all functions&amp;#39; help are now stored in MAML files (instead of comment-based help).&lt;/p&gt;  &lt;p&gt;The major addition to the PSRR module is the ability to manage both 64-bit and 32-bit registry keys and values by using the new &lt;i&gt;&lt;b&gt;View&lt;/b&gt;&lt;/i&gt; parameter (available on all module functions) from PowerShell x86 or x64 instances. See the help for any function on how to use the&lt;i&gt;View&lt;/i&gt; Parameter. &lt;/p&gt;  &lt;p&gt;You can download it &lt;a href="http://psrr.codeplex.com/"&gt;HERE&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=923927" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/Registry/default.aspx">Registry</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/ITPRO/default.aspx">ITPRO</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/Module/default.aspx">Module</category><category domain="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/tags/PowerShellV3/default.aspx">PowerShellV3</category></item></channel></rss>