<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jonathan Medd&#039;s Blog &#187; cmdlet series</title>
	<atom:link href="http://www.jonathanmedd.net/category/cmdlet-series/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jonathanmedd.net</link>
	<description>Scripting. Powershell, VMware, Windows, Active Directory &#38; Exchange. All that kind of stuff.....</description>
	<lastBuildDate>Wed, 01 Feb 2012 13:58:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>PowerShell 2.0 One Cmdlet at a Time &#8211; Available as PDF download</title>
		<link>http://www.jonathanmedd.net/2010/09/powershell-2-0-one-cmdlet-at-a-time-available-as-pdf-download.html</link>
		<comments>http://www.jonathanmedd.net/2010/09/powershell-2-0-one-cmdlet-at-a-time-available-as-pdf-download.html#comments</comments>
		<pubDate>Mon, 27 Sep 2010 11:51:51 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[cmdlet series]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=1382</guid>
		<description><![CDATA[If you have been following my blog for a while you will know that between November 2009 and July 2010 I ran a series of blog posts covering new cmdlets in PowerShell 2.0. I thought it would be useful to aggregate these posts into one document for reference purposes and so I have made this [...]]]></description>
			<content:encoded><![CDATA[<p>If you have been following my blog for a while you will know that between November 2009 and July 2010 I ran a <a href="http://www.jonathanmedd.net/tag/cmdlet-series" target="_blank">series of blog posts covering new cmdlets in PowerShell 2.0</a>. I thought it would be useful to aggregate these posts into one document for reference purposes and so I have made this series <a href="http://www.jonathanmedd.net/wp-content/uploads/2010/09/PowerShell_2_One_Cmdlet_at_a_Time.pdf" target="_blank">available for download as a PDF</a>.</p>
<p>You&#8217;ll be pleased to know I have spent many hours tidying it up, making links to other cmdlets internal to the document throughout and it has also been thoroughly reviewed by fellow PowerShell MVPs <a href="http://twitter.com/doctordns" target="_blank">Thomas Lee</a> , <a href="http://msmvps.com/blogs/RichardSiddaway/Default.aspx" target="_blank">Richard Siddaway</a> and <a href="http://twitter.com/alexandair" target="_blank">Aleksandar Nikolic</a> &#8211; I am most appreciative of their efforts in reviewing and the feedback given!</p>
<p style="text-align: center;"><a href="http://www.tofs.org.uk/index.php/news/article/TOFS-Awareness-week-/"><img class="size-medium wp-image-1392 aligncenter" title="TOFS" src="http://www.jonathanmedd.net/wp-content/uploads/2010/09/TOFS-300x87.png" alt="" width="300" height="87" /></a></p>
<p>I hope you find this consolidated series useful. If you do then I ask that you consider making a small donation to a UK based charity that help the parents of children born with Tracheo-Oesophageal Fistula (TOF) and Oesophageal Atresia (OA). You can find out more about this charity through their website <a href="http://www.tofs.org.uk/index.php" target="_blank">http://www.tofs.org.uk/index.php</a> and can make a donation here <a href="http://www.justgiving.com/tofs/donate" target="_blank">http://www.justgiving.com/tofs/donate</a> . I know from personal experience what a great job they do. Members of this charitable organisation condition are being particularly encouraged during October 2010 to raise <a href="http://www.tofs.org.uk/index.php/news/article/TOFS-Awareness-week-/" target="_blank">awareness</a> and funding so I hope you will help me in doing that.</p>
<p style="text-align: center;"><a href="http://www.jonathanmedd.net/wp-content/uploads/2010/09/PowerShell_2_One_Cmdlet_at_a_Time.pdf"><img class="aligncenter size-medium wp-image-1386" title="PowerShellOneCmdletatTime" src="http://www.jonathanmedd.net/wp-content/uploads/2010/09/PowerShellOneCmdletatTime1-195x300.png" alt="" width="195" height="300" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2010/09/powershell-2-0-one-cmdlet-at-a-time-available-as-pdf-download.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>PowerShell 2.0: One Cmdlet at a Time #107 Add-Type</title>
		<link>http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-107-add-type.html</link>
		<comments>http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-107-add-type.html#comments</comments>
		<pubDate>Wed, 30 Jun 2010 13:27:02 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[cmdlet series]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=1291</guid>
		<description><![CDATA[Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Add-Type cmdlet. What can I do with it? Imbed code from modern programming languages into your PowerShell session or scripts. The list of valid languages are: C#, C# 3.0, VisualBasic and JScript &#8211; C# is the default. Use [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing the series looking at new cmdlets available in <a href="http://support.microsoft.com/kb/968929" target="_blank">PowerShell                              2.0</a>. This time we look at the <a href="http://go.microsoft.com/fwlink/?LinkID=135195" target="_blank">Add-Type</a> cmdlet.</p>
<p><strong>What can I do with it?</strong></p>
<p>Imbed code from modern programming languages into your PowerShell session or scripts. The list of valid languages are: C#, C# 3.0, VisualBasic and JScript &#8211; C# is the default. Use the <strong>Language</strong> parameter to specify one if it is not C#.</p>
<p><a rel="attachment wp-att-1296" href="http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-107-add-type.html/add-type1-2"><img class="aligncenter size-full wp-image-1296" title="Add-Type1" src="http://www.jonathanmedd.net/wp-content/uploads/2010/06/Add-Type11.JPG" alt="Add-Type1" width="567" height="50" /></a></p>
<p><strong>Example:</strong></p>
<p>Within a PowerShell session use some C# code to create a <strong>TakeAway</strong> class and create a static method <strong>Minus</strong>. Use the Add-Type cmdlet to add the class to the session and then call the <strong>TakeAway</strong> class and <strong>Minus</strong> static method.</p>
<pre><span style="color: #800080;">$csharp</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">@"
</span><span style="color: #800000;">public class TakeAway
{
    public static int Minus(int a, int b)
    {
        return (a - b);
    }
}
</span><span style="color: #800000;">"@</span><span style="color: #000000;">
</span><span style="color: #5F9EA0; font-weight: bold;">Add-Type</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-TypeDefinition</span><span style="color: #000000;"> </span><span style="color: #800080;">$csharp</span><span style="color: #000000;">
[TakeAway]::Minus(</span><span style="color: #000000;">10</span><span style="color: #000000;">,</span><span style="color: #000000;">7</span><span style="color: #000000;">)</span></pre>
<p>You will see that we get the expected answer of 3:</p>
<p><a rel="attachment wp-att-1297" href="http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-107-add-type.html/add-type2"><img class="aligncenter size-full wp-image-1297" title="Add-Type2" src="http://www.jonathanmedd.net/wp-content/uploads/2010/06/Add-Type2.JPG" alt="Add-Type2" width="366" height="223" /></a></p>
<p><strong>How could I have done this in PowerShell 1.0?</strong></p>
<p>PowerShell 1.0 did not support adding C# or other code into PowerShell scripts, you could however have created your own cmdlet which I&#8217;m sure would have been very straightforward for most sysadmins <img src='http://www.jonathanmedd.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> <span style="color: #000000;"><br />
</span></p>
<p><a href="http://blogs.msdn.com/powershell/archive/2008/09/19/a-thousand-things-1-better.aspx" target="_blank">1000 things 1% better!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-107-add-type.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PowerShell 2.0: One Cmdlet at a Time #106 Import-LocalizedData</title>
		<link>http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-106-import-localizeddata.html</link>
		<comments>http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-106-import-localizeddata.html#comments</comments>
		<pubDate>Mon, 28 Jun 2010 13:16:51 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[cmdlet series]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=1284</guid>
		<description><![CDATA[Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Import-LocalizedData cmdlet. What can I do with it? Enable text in scripts displayed to users to be presented in their own language. The cmdlet uses the automatic variable $PSUICulture to determine the language to use and alternate text [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing the series looking at new cmdlets available in <a href="http://support.microsoft.com/kb/968929" target="_blank">PowerShell                             2.0</a>. This time we look at the <a href="http://go.microsoft.com/fwlink/?LinkID=113342" target="_blank">Import-LocalizedData</a> cmdlet.</p>
<p><strong>What can I do with it?</strong></p>
<p>Enable text in scripts displayed to users to be presented in their own language. The cmdlet uses the automatic variable <strong>$PSUICulture</strong> to determine the language to use and alternate text is stored within .psd1 files in subdirectories of the folder that the script is stored.</p>
<p><strong>Example:</strong></p>
<p>In a script called <strong>RegionalTest.ps1</strong> use the <a href="http://www.jonathanmedd.net/2010/03/powershell-2-0-one-cmdlet-at-a-time-85-convertfrom-stringdata.html" target="_blank">ConvertFrom-StringData</a> cmdlet to create a series of text messages to display to the user. Import-LocalizedData will retrieve the value of the <strong>$PSUICulture</strong> automatic variable, get the contents of the <strong>RegionalTest.psd1</strong> file in the <strong>es-ES</strong> directory (assume the user is Spanish) and store the data within the variable designated by the <strong>BindingVariable</strong> parameter. Then display the Welcome text.</p>
<pre><span style="color: #800080;">$UserMessages</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> Data {
    </span><span style="color: #008000;">#</span><span style="color: #008000;"> culture="en-US"</span><span style="color: #008000;">
</span><span style="color: #000000;">    </span><span style="color: #5F9EA0; font-weight: bold;">ConvertFrom-StringData</span><span style="color: #000000;"> </span><span style="color: #800000;">@'
</span><span style="color: #800000;">    Welcome = Welcome to the application
    Error1 = You have entered an incorrect username
    Error2 = You have entered an incorrect password
</span><span style="color: #800000;">'@</span><span style="color: #000000;">
    }

</span><span style="color: #5F9EA0; font-weight: bold;">Import-LocalizedData</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-BindingVariable</span><span style="color: #000000;"> </span><span style="color: #800080;">$UserMessages</span><span style="color: #000000;">

</span><span style="color: #800080;">$UserMessages</span><span style="color: #000000;">.Welcome</span></pre>
<p>The contents of the RegionalTest.psd1 file for Spanish would look like (apologies for any bad translation!)</p>
<pre><span style="color: #5F9EA0; font-weight: bold;">ConvertFrom-StringData</span><span style="color: #000000;"> </span><span style="color: #800000;">@'
</span><span style="color: #800000;">    Welcome = Recepción al uso
    Error1 = Usted ha incorporado un username incorrecto
    Error2 = Usted ha incorporado una contraseña incorrecta
</span><span style="color: #800000;">'@</span></pre>
<p>and be stored in the es-ES folder below C:\Scripts where RegionalTest.ps1 lives</p>
<p><a rel="attachment wp-att-1287" href="http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-106-import-localizeddata.html/import-localizeddata-3"><img class="aligncenter size-full wp-image-1287" title="Import-LocalizedData" src="http://www.jonathanmedd.net/wp-content/uploads/2010/06/Import-LocalizedData2.png" alt="Import-LocalizedData" width="482" height="203" /></a></p>
<p>When run on the Spanish user&#8217;s machine the Spanish text would be displayed rather than the original English.</p>
<p><strong>How could I have done this in PowerShell 1.0?</strong></p>
<p>Script Internationalisation features were introduced in PowerShell 2.0 and not s<span style="color: #000000;">upported in version 1.0 &#8211; <a href="http://technet.microsoft.com/en-us/library/dd315390.aspx" target="_blank">more info here</a>.<br />
</span></p>
<p><a href="http://blogs.msdn.com/powershell/archive/2008/09/19/a-thousand-things-1-better.aspx" target="_blank">1000 things 1% better!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-106-import-localizeddata.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell 2.0: One Cmdlet at a Time #105 Set-StrictMode</title>
		<link>http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-105-set-strictmode.html</link>
		<comments>http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-105-set-strictmode.html#comments</comments>
		<pubDate>Fri, 18 Jun 2010 13:07:28 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[cmdlet series]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=1262</guid>
		<description><![CDATA[Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Set-StrictMode cmdlet. What can I do with it? Configure strict mode for the current scope. An error will be generated when the content of an expression, script or script block violates coding rules. Note: it is possible to [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing the series looking at new cmdlets available in <a href="http://support.microsoft.com/kb/968929" target="_blank">PowerShell                             2.0</a>. This time we look at the <a href="http://go.microsoft.com/fwlink/?LinkID=113450" target="_blank">Set-StrictMode</a> cmdlet.</p>
<p><strong>What can I do with it?</strong></p>
<p>Configure strict mode for the current scope. An error will be generated when the content of an expression, script or script block violates coding rules. Note: it is possible to use the <strong>Version</strong> parameter to pick which coding rules to use. The <a href="http://go.microsoft.com/fwlink/?LinkID=113450" target="_blank">PowerShell help</a> lists the current possible options as:</p>
<p><strong>1.0</strong></p>
<p>&#8211; Prohibits references to uninitialized variables, except for  uninitialized variables in strings.</p>
<p><strong>2.0</strong></p>
<p>&#8211; Prohibits references to uninitialized variables (including  uninitialized variables in strings).</p>
<p>&#8211; Prohibits references to non-existent properties of an  object.</p>
<p>&#8211; Prohibits function calls that use the syntax for calling  methods.</p>
<p>&#8211; Prohibits a variable without a name (${}).</p>
<p><strong>Latest</strong></p>
<p>&#8211;Selects the latest (most strict) version available.  Use this value to  assure that scripts use the strictest available version, even when new  versions are added to Windows PowerShell.</p>
<p><strong>Example:</strong></p>
<p>Examine what happens when you add the undefined $b to the undefined $a with strict mode off. Next, turn on strict mode using Version 1.0 and run the same test.</p>
<pre><span style="color: #800080;">$a</span><span style="color: #000000;"> </span><span style="color: #FF0000;">+</span><span style="color: #000000;"> </span><span style="color: #800080;">$b</span><span style="color: #000000;">
</span><span style="color: #5F9EA0; font-weight: bold;">Set-StrictMode</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-Version</span><span style="color: #000000;"> </span><span style="color: #800000;">1.0</span><span style="color: #000000;">
</span><span style="color: #800080;">$a</span><span style="color: #000000;"> </span><span style="color: #FF0000;">+</span><span style="color: #000000;"> </span><span style="color: #800080;">$b</span></pre>
<p>Note the error message generated with strict mode on because $a has not been initialised.</p>
<p><a rel="attachment wp-att-1263" href="http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-105-set-strictmode.html/set-strictmode1"><img class="aligncenter size-full wp-image-1263" title="Set-StrictMode1" src="http://www.jonathanmedd.net/wp-content/uploads/2010/06/Set-StrictMode1.png" alt="Set-StrictMode1" width="491" height="118" /></a></p>
<p>Examine what happens when you define $a to be a numerical value and attempt to reference a property  with strict mode off. Next, turn on strict mode using Version 2.0 and  run the same test.</p>
<pre><span style="color: #800080;">$a</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">32</span><span style="color: #000000;">
</span><span style="color: #800080;">$a</span><span style="color: #000000;">.Time
</span><span style="color: #5F9EA0; font-weight: bold;">Set-StrictMode</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-Version</span><span style="color: #000000;"> </span><span style="color: #800000;">2.0</span><span style="color: #000000;">
</span><span style="color: #800080;">$a</span><span style="color: #000000;">.Time</span></pre>
<p>Note the error message generated with strict mode on because the Time property does not exist.</p>
<p><a rel="attachment wp-att-1264" href="http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-105-set-strictmode.html/set-strictmode2"><img class="aligncenter size-full wp-image-1264" title="Set-StrictMode2" src="http://www.jonathanmedd.net/wp-content/uploads/2010/06/Set-StrictMode2.png" alt="Set-StrictMode2" width="533" height="122" /></a></p>
<p><strong>How could I have done this in PowerShell 1.0?</strong></p>
<p>You could have used <a href="http://technet.microsoft.com/en-us/library/dd315302.aspx" target="_blank">Set-PSDebug</a>, however Set-Strictmode applies only to the current scope or child scopes and does not impact the global scope. For more information on scopes in PowerShell <a href="http://technet.microsoft.com/en-us/library/dd315289.aspx" target="_blank">look here</a>.</p>
<p><a href="http://blogs.msdn.com/powershell/archive/2008/09/19/a-thousand-things-1-better.aspx" target="_blank">1000 things 1% better!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-105-set-strictmode.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell 2.0: One Cmdlet at a Time #104 Trace-Command</title>
		<link>http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-104-trace-command.html</link>
		<comments>http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-104-trace-command.html#comments</comments>
		<pubDate>Thu, 17 Jun 2010 12:58:34 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[cmdlet series]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=1247</guid>
		<description><![CDATA[Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Trace-Command cmdlet. What can I do with it? Begin a trace of a command or expression. Example: Examine debug info for Parameter Binding when piping a string through to Get-Service. Trace-Command -Name ParameterBinding -Option All -Expression {'winmgmt' &#124; [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing the series looking at new cmdlets available in <a href="http://support.microsoft.com/kb/968929" target="_blank">PowerShell                            2.0</a>. This time we look at the <a href="http://go.microsoft.com/fwlink/?LinkID=113419" target="_blank">Trace-Command</a> cmdlet.</p>
<p><strong>What can I do with it?</strong></p>
<p>Begin a trace of a command or expression.</p>
<p><strong>Example:</strong></p>
<p>Examine debug info for Parameter Binding when piping a string through to Get-Service.</p>
<pre><span style="color: #5F9EA0; font-weight: bold;">Trace-Command</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-Name</span><span style="color: #000000;"> </span><span style="color: #800000;">ParameterBinding</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-Option</span><span style="color: #000000;"> </span><span style="color: #800000;">All</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-Expression</span><span style="color: #000000;"> {</span><span style="color: #800000;">'</span><span style="color: #800000;">winmgmt</span><span style="color: #800000;">'</span><span style="color: #000000;"> | </span><span style="color: #5F9EA0; font-weight: bold;">Get-Service</span><span style="color: #000000;">} </span><span style="color: #5F9EA0; font-style: italic;">-PSHost</span></pre>
<p>You will see it is possible to work through the debug info to find out what is happening:</p>
<p><a rel="attachment wp-att-1248" href="http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-104-trace-command.html/trace-command"><img class="aligncenter size-full wp-image-1248" title="Trace-Command" src="http://www.jonathanmedd.net/wp-content/uploads/2010/06/Trace-Command.png" alt="Trace-Command" width="574" height="259" /></a></p>
<p>Note: it is also possible to output the debug info to a file, simply remove the <strong>PSHost</strong> parameter and use <strong>FilePath</strong> instead.</p>
<pre><span style="color: #5F9EA0; font-weight: bold;">Trace-Command</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-Name</span><span style="color: #000000;"> </span><span style="color: #800000;">ParameterBinding</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-Option</span><span style="color: #000000;"> </span><span style="color: #800000;">All</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-Expression</span><span style="color: #000000;"> {</span><span style="color: #800000;">'</span><span style="color: #800000;">winmgmt</span><span style="color: #800000;">'</span><span style="color: #000000;"> | </span><span style="color: #5F9EA0; font-weight: bold;">Get-Service</span><span style="color: #000000;">} </span><span style="color: #5F9EA0; font-style: italic;">-FilePath</span><span style="color: #000000;"> </span><span style="color: #800000;">C:\Debug.txt</span></pre>
<p>The resulting debug info is now easily viewable in Notepad.</p>
<p><a rel="attachment wp-att-1257" href="http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-104-trace-command.html/trace-command2-2"><img class="aligncenter size-full wp-image-1257" title="Trace-Command2" src="http://www.jonathanmedd.net/wp-content/uploads/2010/06/Trace-Command21.png" alt="Trace-Command2" width="597" height="199" /></a></p>
<p><strong>How could I have done this in PowerShell 1.0?</strong></p>
<p>You could have used <a href="http://technet.microsoft.com/en-us/library/dd315364.aspx" target="_blank">Set-TraceSource</a> , but Trace-Command applies the trace only to the specified command.</p>
<p><a href="http://blogs.msdn.com/powershell/archive/2008/09/19/a-thousand-things-1-better.aspx" target="_blank">1000 things 1% better!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-104-trace-command.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell 2.0: One Cmdlet at a Time #103 Update-List</title>
		<link>http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-103-update-list.html</link>
		<comments>http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-103-update-list.html#comments</comments>
		<pubDate>Thu, 17 Jun 2010 11:58:09 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[cmdlet series]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=1244</guid>
		<description><![CDATA[Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Update-List cmdlet. What can I do with it? Add, Remove or Replace items from a property value of an object. This cmdlet can only update a property when it supports the IList interface. So far this does not [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing the series looking at new cmdlets available in <a href="http://support.microsoft.com/kb/968929" target="_blank">PowerShell                           2.0</a>. This time we look at the <a href="http://go.microsoft.com/fwlink/?LinkID=113447" target="_blank">Update-List</a> cmdlet.</p>
<p><strong>What can I do with it?</strong></p>
<p>Add, Remove or Replace items from a property value of an object. This cmdlet can only update a property when it supports the <a href="http://msdn.microsoft.com/en-us/library/system.collections.ilist.aspx" target="_blank">IList interface</a>. So far this does not include any of the core Windows PowerShell cmdlets &#8211; however it does include some of the cmdlets that ship with Exchange 2007 and later.</p>
<p><strong>Example:</strong></p>
<p>Add additional email addresses to the Test1 user&#8217;s mailbox using the <strong>Add</strong> parameter of Update-List.</p>
<pre><span style="color: #000000;">Get-Mailbox Test1  | </span><span style="color: #5F9EA0; font-weight: bold;">Update-List</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-Property</span><span style="color: #000000;"> </span><span style="color: #800000;">EmailAddresses</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-Add</span><span style="color: #000000;"> admin@</span><span style="color: #800000;">contoso.com</span><span style="color: #000000;">,webmaster@</span><span style="color: #800000;">contoso.com</span><span style="color: #000000;">
| Set-Mailbox</span></pre>
<p><strong>How could I have done this in PowerShell 1.0?</strong></p>
<p>Shay Levy has a great <a href="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2010/02/04/modifying-multivalued-active-directory-attributes.aspx" target="_blank">blog post</a> on dealing with AD / Mailbox accounts with multi-valued attributes.</p>
<p><a href="http://blogs.msdn.com/powershell/archive/2008/09/19/a-thousand-things-1-better.aspx" target="_blank">1000 things 1% better!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2010/06/powershell-2-0-one-cmdlet-at-a-time-103-update-list.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell 2.0: One Cmdlet at a Time #102 Disable-PSRemoting</title>
		<link>http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-102-disable-psremoting.html</link>
		<comments>http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-102-disable-psremoting.html#comments</comments>
		<pubDate>Fri, 21 May 2010 12:29:13 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[cmdlet series]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=1237</guid>
		<description><![CDATA[Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Disable-PSRemoting function. Note: This is a proxy command which calls the Disable-PSSessionConfiguration cmdlet. What can I do with it? Disable PowerShell remoting on a computer that has previously been enabled for remoting. Note: This command must be run [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing the series looking at new cmdlets available in <a href="http://support.microsoft.com/kb/968929" target="_blank">PowerShell                          2.0</a>. This time we look at the <a href="http://go.microsoft.com/fwlink/?LinkID=144298" target="_blank">Disable-PSRemoting</a> function. Note: This is a proxy command which calls the <a href="http://www.jonathanmedd.net/2010/01/powershell-2-0-one-cmdlet-at-a-time-41-disable-pssessionconfiguration.html" target="_blank">Disable-PSSessionConfiguration</a> cmdlet.</p>
<p><strong>What can I do with it?</strong></p>
<p>Disable PowerShell remoting on a computer that has previously been enabled for remoting.<strong> Note:</strong> This command must be run from a PowerShell session with administrative privileges.</p>
<p><strong>Example:</strong></p>
<p>Retrieve the current PSSessionConfiguration settings. Disable PowerShell remoting, then retrieve the PSSessionConfiguration settings again to compare.</p>
<pre><span style="color: #5F9EA0; font-weight: bold;">Get-PSSessionConfiguration</span><span style="color: #000000;">
</span><span style="color: #5F9EA0;">Disable-PSRemoting</span><span style="color: #000000;">
</span><span style="color: #5F9EA0; font-weight: bold;">Get-PSSessionConfiguration</span></pre>
<p>Notice the PSSessionConfiguration on a machine enabled for PowerShell remoting</p>
<p><a rel="attachment wp-att-1238" href="http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-102-disable-psremoting.html/disable-psremoting1"><img class="aligncenter size-full wp-image-1238" title="Disable-PSRemoting1" src="http://www.jonathanmedd.net/wp-content/uploads/2010/05/Disable-PSRemoting1.png" alt="Disable-PSRemoting1" width="557" height="109" /></a></p>
<p>Disable PowerShell Remoting. You will receive the following warning that using this command does not necessarily reverse everythign that Enable-PSRemoting may have done.</p>
<p>WARNING: Disabling the session configurations does not undo all the changes made by the Enable-PSRemoting or<br />
Enable-PSSessionConfiguration cmdlet. You might have to manually undo the changes by following these steps.<br />
1. Stop and disable the WinRM service.<br />
2. Delete the listener that accepts requests on any IP address.<br />
3. Disable the firewall exceptions for WS-Management communications.<br />
4. Restore the value of the LocalAccountTokenFilterPolicy to 0, which restricts remote access to members of the<br />
Administrators group on the computer.</p>
<p><a rel="attachment wp-att-1239" href="http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-102-disable-psremoting.html/disable-psremoting2"><img class="aligncenter size-full wp-image-1239" title="Disable-PSRemoting2" src="http://www.jonathanmedd.net/wp-content/uploads/2010/05/Disable-PSRemoting2.png" alt="Disable-PSRemoting2" width="562" height="147" /></a></p>
<p>Now check the impact on the PSSessionconfiguration &#8211; the <strong>AccessDenied</strong> permission has been applied to <strong>Everyone</strong>.</p>
<p><a rel="attachment wp-att-1240" href="http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-102-disable-psremoting.html/disable-psremoting3"><img class="aligncenter size-full wp-image-1240" title="Disable-PSRemoting3" src="http://www.jonathanmedd.net/wp-content/uploads/2010/05/Disable-PSRemoting3.png" alt="Disable-PSRemoting3" width="578" height="106" /></a></p>
<p><strong>How could I have done this in PowerShell 1.0?</strong></p>
<p>Remoting did not exist in PowerShell 1.0, you would have needed to  use Remote Desktop to run an interactive session on a remote server.</p>
<p><a href="http://blogs.msdn.com/powershell/archive/2008/09/19/a-thousand-things-1-better.aspx" target="_blank">1000 things 1% better!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-102-disable-psremoting.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell 2.0: One Cmdlet at a Time #101 Wait-Process</title>
		<link>http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-101-wait-process.html</link>
		<comments>http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-101-wait-process.html#comments</comments>
		<pubDate>Tue, 18 May 2010 15:59:36 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[cmdlet series]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=1229</guid>
		<description><![CDATA[Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Wait-Process cmdlet. What can I do with it? Wait for a process to stop before proceeding further. Example: Open an instance of Notepad. Use Wait-Process to pause the console session until Notepad is closed. Notepad Wait-Process -Name Notepad [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing the series looking at new cmdlets available in <a href="http://support.microsoft.com/kb/968929" target="_blank">PowerShell                         2.0</a>. This time we look at the <a href="http://go.microsoft.com/fwlink/?LinkID=135277" target="_blank">Wait-Process</a> cmdlet.</p>
<p><strong>What can I do with it?</strong></p>
<p>Wait for a process to stop before proceeding further.</p>
<p><strong>Example:</strong></p>
<p>Open an instance of Notepad. Use Wait-Process to pause the console session until Notepad is closed.</p>
<pre><span style="color: #000000;">Notepad
</span><span style="color: #5F9EA0; font-weight: bold;">Wait-Process</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-Name</span><span style="color: #000000;"> </span><span style="color: #800000;">Notepad</span></pre>
<p>You will notice that the console pauses whilst Notepad is open</p>
<p><a rel="attachment wp-att-1230" href="http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-101-wait-process.html/wait-process1"><img class="aligncenter size-full wp-image-1230" title="Wait-Process1" src="http://www.jonathanmedd.net/wp-content/uploads/2010/05/Wait-Process1.png" alt="Wait-Process1" width="602" height="152" /></a></p>
<p>Once Notepad is closed, control of the session is returned to the user.</p>
<p><a rel="attachment wp-att-1231" href="http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-101-wait-process.html/wait-process2"><img class="aligncenter size-full wp-image-1231" title="Wait-Process2" src="http://www.jonathanmedd.net/wp-content/uploads/2010/05/Wait-Process2.png" alt="Wait-Process2" width="307" height="95" /></a></p>
<p><strong>How could I have done this in PowerShell 1.0?</strong></p>
<p>Store the result of Get-Process Notepad in a variable, then use the <strong>WaitForExit</strong> method to wait for the process to stop.</p>
<pre><span style="color: #000000;">Notepad
</span><span style="color: #800080;">$Process</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-weight: bold;">Get-Process</span><span style="color: #000000;"> </span><span style="color: #800000;">Notepad</span><span style="color: #000000;">
</span><span style="color: #800080;">$Process</span><span style="color: #000000;">.WaitForExit()</span></pre>
<p><a href="http://blogs.msdn.com/powershell/archive/2008/09/19/a-thousand-things-1-better.aspx" target="_blank">1000 things 1% better</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-101-wait-process.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell 2.0: One Cmdlet at a Time #100 Remove-Event</title>
		<link>http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-100-remove-event.html</link>
		<comments>http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-100-remove-event.html#comments</comments>
		<pubDate>Thu, 13 May 2010 13:24:26 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[cmdlet series]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=1224</guid>
		<description><![CDATA[Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Remove-Event cmdlet. What can I do with it? Delete an event from the current session. Note: to unsubscribe from an event you will need to use Unregister-Event. Example: Retrive current events in the queue with Get-Event, use Remove-Event [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing the series looking at new cmdlets available in <a href="http://support.microsoft.com/kb/968929" target="_blank">PowerShell                        2.0</a>. This time we look at the <a href="http://go.microsoft.com/fwlink/?LinkID=135247" target="_blank">Remove-Event </a>cmdlet.</p>
<p><strong>What can I do with it?</strong></p>
<p>Delete an event from the current session. <strong>Note:</strong> to unsubscribe from an event you will need to use <a href="http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-99-unregister-event.html" target="_blank">Unregister-Event</a>.</p>
<p><strong>Example:</strong></p>
<p>Retrive current events in the queue with <a href="http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-97-get-event.html" target="_blank">Get-Event</a>, use Remove-Event to clear the event with the SourceIdentifier of <strong>Timer</strong>, then <a href="../2010/05/powershell-2-0-one-cmdlet-at-a-time-97-get-event.html" target="_blank">Get-Event</a> again to confirm that it has been removed.</p>
<pre><span style="color: #5F9EA0; font-weight: bold;">Get-Event</span><span style="color: #000000;">
</span><span style="color: #5F9EA0; font-weight: bold;">Remove-Event</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-SourceIdentifier</span><span style="color: #000000;"> </span><span style="color: #800000;">Timer</span><span style="color: #000000;">
</span><span style="color: #5F9EA0; font-weight: bold;">Get-Event</span></pre>
<p>You will see that the event has been cleared.</p>
<p><a rel="attachment wp-att-1225" href="http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-100-remove-event.html/remove-event"><img class="aligncenter size-full wp-image-1225" title="Remove-Event" src="http://www.jonathanmedd.net/wp-content/uploads/2010/05/Remove-Event.png" alt="Remove-Event" width="344" height="200" /></a></p>
<p><strong>How could I have done this in PowerShell 1.0?</strong></p>
<p>PowerShell engine events are a new feature in PowerShell 2.0.</p>
<p><a href="http://blogs.msdn.com/powershell/archive/2008/09/19/a-thousand-things-1-better.aspx" target="_blank">1000 things 1% better</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-100-remove-event.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PowerShell 2.0: One Cmdlet at a Time #99 Unregister-Event</title>
		<link>http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-99-unregister-event.html</link>
		<comments>http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-99-unregister-event.html#comments</comments>
		<pubDate>Tue, 11 May 2010 11:44:01 +0000</pubDate>
		<dc:creator>Jonathan Medd</dc:creator>
				<category><![CDATA[cmdlet series]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.jonathanmedd.net/?p=1220</guid>
		<description><![CDATA[Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Unregister-Event cmdlet. What can I do with it? Clear an event subscription. Example: Use Get-EventSubscriber to retrive details of current events. Clear the event with subscription id 1 and Get-EventSubscriber again to confirm that it has been removed. [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing the series looking at new cmdlets available in <a href="http://support.microsoft.com/kb/968929" target="_blank">PowerShell                       2.0</a>. This time we look at the <a href="http://go.microsoft.com/fwlink/?LinkID=135269" target="_blank">Unregister-Event</a> cmdlet.</p>
<p><strong>What can I do with it?</strong></p>
<p>Clear an event subscription.</p>
<p><strong>Example:</strong></p>
<p>Use <a href="http://www.jonathanmedd.net/2010/04/powershell-2-0-one-cmdlet-at-a-time-94-get-eventsubscriber.html" target="_blank">Get-EventSubscriber</a> to retrive details of current events. Clear the event with subscription<strong> </strong>id <strong>1</strong> and <a href="../2010/04/powershell-2-0-one-cmdlet-at-a-time-94-get-eventsubscriber.html" target="_blank">Get-EventSubscriber</a> again to confirm that it has been removed.</p>
<pre><span style="color: #5F9EA0; font-weight: bold;">Get-EventSubscriber</span><span style="color: #000000;">
</span><span style="color: #5F9EA0; font-weight: bold;">Unregister-Event</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-SubscriptionId</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;">
</span><span style="color: #5F9EA0; font-weight: bold;">Get-EventSubscriber</span></pre>
<p>You will see that the event subscription has been cleared.</p>
<p><a rel="attachment wp-att-1221" href="http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-99-unregister-event.html/unregister-event"><img class="aligncenter size-full wp-image-1221" title="Unregister-Event" src="http://www.jonathanmedd.net/wp-content/uploads/2010/05/Unregister-Event.png" alt="Unregister-Event" width="373" height="188" /></a></p>
<p><strong>How could I have done this in PowerShell 1.0?</strong></p>
<p>PowerShell engine events are a new feature in PowerShell 2.0.</p>
<p><a href="http://blogs.msdn.com/powershell/archive/2008/09/19/a-thousand-things-1-better.aspx" target="_blank">1000 things 1% better</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonathanmedd.net/2010/05/powershell-2-0-one-cmdlet-at-a-time-99-unregister-event.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

