&lt;?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Articles from January 2013 on PowerShell.org - Welcome Automaters!</title><link>https://powershell.org/articles/2013/01/</link><description>Recent content in Articles from January 2013 on PowerShell.org - Welcome Automaters!</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://powershell.org/articles/2013/01/index.xml" rel="self" type="application/rss+xml"/><item><title>PowerShell and Active Directory recording</title><link>https://powershell.org/articles/2013-01-30-powershell-and-active-directory-recording/</link><guid>https://powershell.org/articles/2013-01-30-powershell-and-active-directory-recording/</guid><pubDate>Wed, 30 Jan 2013 22:05:51 +0000</pubDate><description>&lt;p&gt;The recording, slides and demo script from yesterday&amp;quot;™s PowerShell and Active Directory session can be found here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://skydrive.live.com/?cid=43cfa46a74cf3e96#cid=43CFA46A74CF3E96&amp;amp;id=43CFA46A74CF3E96%2140563" title="https://skydrive.live.com/?cid=43cfa46a74cf3e96#cid=43CFA46A74CF3E96&amp;amp;id=43CFA46A74CF3E96%2140563"&gt;https://skydrive.live.com/?cid=43cfa46a74cf3e96#cid=43CFA46A74CF3E96&amp;amp;id=43CFA46A74CF3E96%2140563&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2801/"&gt;&lt;img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2801/" alt=""&gt;&lt;/a&gt;&lt;img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;amp;blog=16267735&amp;amp;%23038;post=2801&amp;amp;%23038;subd=richardspowershellblog&amp;amp;%23038;ref=&amp;amp;%23038;feed=1" alt=""&gt;&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>The recording, slides and demo script from yesterday"™s PowerShell and Active Directory session can be found here:</p><p><a href="https://skydrive.live.com/?cid=43cfa46a74cf3e96#cid=43CFA46A74CF3E96&amp;id=43CFA46A74CF3E96%2140563" title="https://skydrive.live.com/?cid=43cfa46a74cf3e96#cid=43CFA46A74CF3E96&amp;id=43CFA46A74CF3E96%2140563">https://skydrive.live.com/?cid=43cfa46a74cf3e96#cid=43CFA46A74CF3E96&amp;id=43CFA46A74CF3E96%2140563</a></p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2801/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2801/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2801&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>PowerShell workflows"“now we are six</title><link>https://powershell.org/articles/2013-01-30-powershell-workflows-now-we-are-six/</link><guid>https://powershell.org/articles/2013-01-30-powershell-workflows-now-we-are-six/</guid><pubDate>Wed, 30 Jan 2013 19:11:03 +0000</pubDate><description>&lt;p&gt;The sixth in the series of articles on PowerShell workflows that are appearing on the Scripting Guy blog has been published.&lt;/p&gt;
&lt;p&gt;The articles in the series that have been published are:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx"&gt;http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx&lt;/a&gt;&lt;br&gt;
&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx"&gt;http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx&lt;/a&gt;&lt;br&gt;
&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/09/powershell-workflows-nesting.aspx"&gt;http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/09/powershell-workflows-nesting.aspx&lt;/a&gt;&lt;br&gt;
&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/16/powershell-workflows-job-engine.aspx"&gt;http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/16/powershell-workflows-job-engine.aspx&lt;/a&gt;&lt;br&gt;
&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/23/powershell-workflows-restarting-the-computer.aspx"&gt;http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/23/powershell-workflows-restarting-the-computer.aspx&lt;/a&gt;&lt;br&gt;
&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/30/powershell-workflows-using-parameters.aspx"&gt;http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/30/powershell-workflows-using-parameters.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Look for the next article in one weeks time.&lt;/p&gt;
&lt;p&gt;Until then Enjoy!&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2800/"&gt;&lt;img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2800/" alt=""&gt;&lt;/a&gt;&lt;img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;amp;blog=16267735&amp;amp;%23038;post=2800&amp;amp;%23038;subd=richardspowershellblog&amp;amp;%23038;ref=&amp;amp;%23038;feed=1" alt=""&gt;&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>The sixth in the series of articles on PowerShell workflows that are appearing on the Scripting Guy blog has been published.</p><p>The articles in the series that have been published are:</p><p><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx">http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx</a><br><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx">http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx</a><br><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/09/powershell-workflows-nesting.aspx">http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/09/powershell-workflows-nesting.aspx</a><br><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/16/powershell-workflows-job-engine.aspx">http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/16/powershell-workflows-job-engine.aspx</a><br><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/23/powershell-workflows-restarting-the-computer.aspx">http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/23/powershell-workflows-restarting-the-computer.aspx</a><br><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/30/powershell-workflows-using-parameters.aspx">http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/30/powershell-workflows-using-parameters.aspx</a></p><p>Look for the next article in one weeks time.</p><p>Until then Enjoy!</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2800/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2800/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2800&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>The 2013 Winter Scripting Camp</title><link>https://powershell.org/articles/2013-01-28-the-2013-winter-scripting-camp/</link><guid>https://powershell.org/articles/2013-01-28-the-2013-winter-scripting-camp/</guid><pubDate>Mon, 28 Jan 2013 20:56:00 +0000</pubDate><description>&lt;p&gt;We&amp;rsquo;ll be announcing Winter Scripting Camp the first week of February. This is a special invite-only event that will be open to subscribers of the PowerShell.org TechLetter. It will work just like the Scripting Games, but will feature only a couple of events and will not include any prizes. We will, however, announce the top scorers.&lt;br&gt;
Scripting Camp is primarily an opportunity for us to audition our new platform, to kick the tires, and make sure everything&amp;rsquo;s ready for the official Games, which will kick off in April at the &lt;a href="https://powershell.org/summit/"&gt;PowerShell Summit 2013 North America&lt;/a&gt;.&lt;br&gt;
If you&amp;rsquo;re interested in Camping with us, please sign up for the TechLetter this week (prior to Feb 1st). We&amp;rsquo;ll be sending out a special notification to the TechLetter subscriber list with sign-up instructions.&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>We&rsquo;ll be announcing Winter Scripting Camp the first week of February. This is a special invite-only event that will be open to subscribers of the PowerShell.org TechLetter. It will work just like the Scripting Games, but will feature only a couple of events and will not include any prizes. We will, however, announce the top scorers.<br>
Scripting Camp is primarily an opportunity for us to audition our new platform, to kick the tires, and make sure everything&rsquo;s ready for the official Games, which will kick off in April at the<a href="/summit/">PowerShell Summit 2013 North America</a>.<br>
If you&rsquo;re interested in Camping with us, please sign up for the TechLetter this week (prior to Feb 1st). We&rsquo;ll be sending out a special notification to the TechLetter subscriber list with sign-up instructions.</p>
]]></content:encoded></item><item><title>PowerShell and Active Directory"“reminder</title><link>https://powershell.org/articles/2013-01-28-powershell-and-active-directory-reminder/</link><guid>https://powershell.org/articles/2013-01-28-powershell-and-active-directory-reminder/</guid><pubDate>Mon, 28 Jan 2013 18:14:58 +0000</pubDate><description>&lt;p&gt;Quick reminder for tomorrow&amp;quot;™s session from the UK PowerShell group. Details from:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://msmvps.com/blogs/richardsiddaway/archive/2013/01/16/uk-powershell-group-29-january-2013.aspx" title="http://msmvps.com/blogs/richardsiddaway/archive/2013/01/16/uk-powershell-group-29-january-2013.aspx"&gt;http://msmvps.com/blogs/richardsiddaway/archive/2013/01/16/uk-powershell-group-29-january-2013.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2799/"&gt;&lt;img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2799/" alt=""&gt;&lt;/a&gt;&lt;img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;amp;blog=16267735&amp;amp;%23038;post=2799&amp;amp;%23038;subd=richardspowershellblog&amp;amp;%23038;ref=&amp;amp;%23038;feed=1" alt=""&gt;&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>Quick reminder for tomorrow"™s session from the UK PowerShell group. Details from:</p><p><a href="http://msmvps.com/blogs/richardsiddaway/archive/2013/01/16/uk-powershell-group-29-january-2013.aspx" title="http://msmvps.com/blogs/richardsiddaway/archive/2013/01/16/uk-powershell-group-29-january-2013.aspx">http://msmvps.com/blogs/richardsiddaway/archive/2013/01/16/uk-powershell-group-29-january-2013.aspx</a></p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2799/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2799/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2799&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>Piping between functions</title><link>https://powershell.org/articles/2013-01-19-piping-between-functions/</link><guid>https://powershell.org/articles/2013-01-19-piping-between-functions/</guid><pubDate>Sat, 19 Jan 2013 17:04:01 +0000</pubDate><description>&lt;p&gt;A question came up about piping between advanced functions. The input to the second function might be an array. To illustrate how this works imagine a function that gets disk information &amp;ldquo;“ or better still use this one.&lt;/p&gt;
&lt;p&gt;`function&lt;/p&gt;
&lt;p&gt;get-mydisk&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;[&lt;/p&gt;
&lt;p&gt;CmdletBinding&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;]&lt;/p&gt;
&lt;p&gt;param&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;[string]&lt;/p&gt;
&lt;p&gt;$computername&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;&amp;ldquo;$env:COMPUTERNAME&amp;rdquo;&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;BEGIN&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;#begin&lt;/p&gt;
&lt;p&gt;PROCESS&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;Get-WmiObject&lt;/p&gt;
&lt;p&gt;-Class&lt;/p&gt;
&lt;p&gt;Win32_LogicalDisk&lt;/p&gt;
&lt;p&gt;-ComputerName&lt;/p&gt;
&lt;p&gt;$computername&lt;/p&gt;
&lt;p&gt;|&lt;/p&gt;
&lt;p&gt;foreach&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;New-Object&lt;/p&gt;
&lt;p&gt;-TypeName&lt;/p&gt;
&lt;p&gt;PSObject&lt;/p&gt;
&lt;p&gt;-Property&lt;/p&gt;
&lt;p&gt;@{&lt;/p&gt;
&lt;p&gt;Disk&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;$_&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;DeviceID&lt;/p&gt;
&lt;p&gt;Free&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;$_&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;FreeSpace&lt;/p&gt;
&lt;p&gt;Size&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;$_&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;Size&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;#process&lt;/p&gt;
&lt;p&gt;END&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>A question came up about piping between advanced functions. The input to the second function might be an array. To illustrate how this works imagine a function that gets disk information &ldquo;“ or better still use this one.</p><p>`function</p><p>get-mydisk</p><p>{</p><p>[</p><p>CmdletBinding</p><p>(</p><p>)</p><p>]</p><p>param</p><p>(</p><p>[string]</p><p>$computername</p><p>=</p><p>&ldquo;$env:COMPUTERNAME&rdquo;</p><p>)</p><p>BEGIN</p><p>{</p><p>}</p><p>#begin</p><p>PROCESS</p><p>{</p><p>Get-WmiObject</p><p>-Class</p><p>Win32_LogicalDisk</p><p>-ComputerName</p><p>$computername</p><p>|</p><p>foreach</p><p>{</p><p>New-Object</p><p>-TypeName</p><p>PSObject</p><p>-Property</p><p>@{</p><p>Disk</p><p>=</p><p>$_</p><p>.</p><p>DeviceID</p><p>Free</p><p>=</p><p>$_</p><p>.</p><p>FreeSpace</p><p>Size</p><p>=</p><p>$_</p><p>.</p><p>Size</p><p>}</p><p>}</p><p>}</p><p>#process</p><p>END</p><p>{</p><p>}</p><p>#end</p><p>}</p><p>`Use a computername as a parameter. Use WMI to get the disk information and output an object.</p><p>PS&gt; get-mydisk | ft -AutoSize</p><p>Disk Free Size
—- —- —-
C: 149778239488 249951154176
D: 69271552 104853504
E:<br>
F:</p><p>This works as well</p><p>PS&gt; get-mydisk | where Size -gt 0 | ft -AutoSize</p><p>Disk Free Size
—- —- —-
C: 149778108416 249951154176
D: 69271552 104853504</p><p>You now have a function outputs objects that behave properly on the pipeline.</p><p>So now you want those objects piped into another function or you want an array of objects used as the input</p><p>`function</p><p>get-freeperc</p><p>{</p><p>[</p><p>CmdletBinding</p><p>(</p><p>)</p><p>]</p><p>param</p><p>(</p><p>[</p><p>parameter</p><p>(</p><p>ValueFromPipeline</p><p>=</p><p>$true</p><p>)</p><p>]</p><p>[Object[]]</p><p>$disklist</p><p>)</p><p>BEGIN</p><p>{</p><p>}</p><p>#begin</p><p>PROCESS</p><p>{</p><p>foreach</p><p>(</p><p>$disk</p><p>in</p><p>$disklist</p><p>)</p><p>{</p><p>if</p><p>(</p><p>$disk</p><p>.</p><p>Size</p><p>-gt</p><p>)</p><p>{</p><p>$disk</p><p>|</p><p>Select</p><p>Disk</p><p>,</p><p>@{</p><p>N</p><p>=</p><p>&ldquo;Size(GB)&rdquo;</p><p>;</p><p>E</p><p>=</p><p>{</p><p>[math]</p><p>::</p><p>Round</p><p>(</p><p>(</p><p>$(</p><p>$_</p><p>.</p><p>Size</p><p>)</p><p>/</p><p>1GB</p><p>)</p><p>,</p><p>2</p><p>)</p><p>}</p><p>}</p><p>,</p><p>@{</p><p>N</p><p>=</p><p>&ldquo;FreePerc&rdquo;</p><p>;</p><p>E</p><p>=</p><p>{</p><p>[math]</p><p>::</p><p>Round</p><p>(</p><p>(</p><p>$(</p><p>$_</p><p>.</p><p>Free</p><p>)</p><p>/</p><p>$(</p><p>$_</p><p>.</p><p>Size</p><p>)</p><p>)</p><ul><li/></ul><p>100</p><p>,</p><p>2</p><p>)</p><p>}</p><p>}</p><p>}</p><p>}</p><p>}</p><p>#process</p><p>END</p><p>{</p><p>}</p><p>#end</p><p>}</p><p>`* Set the parameter to accept pipeline input
* Set the parameter to accept an array of objects
* Use a process block
* Use a foreach block in the process block</p><pre><code> This works
PS&gt; get-mydisk | get-freeperc | ft -AutoSize
Disk Size(GB) FreePerc</code></pre><p>—- ——– ——–
C: 232.79 59.92
D: 0.1 66.07</p><pre><code> or this
$disks = get-mydisk
get-freeperc -disklist $disks
or this
get-freeperc -disklist (get-mydisk)
[![](http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2798/)](http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2798/)![](http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2798&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1)</code></pre>
]]></content:encoded></item><item><title>Starting virtual machines for WSUS</title><link>https://powershell.org/articles/2013-01-17-starting-virtual-machines-for-wsus/</link><guid>https://powershell.org/articles/2013-01-17-starting-virtual-machines-for-wsus/</guid><pubDate>Thu, 17 Jan 2013 19:50:54 +0000</pubDate><description>&lt;p&gt;My test environment usually has a dozen or so machines at any one time. Some of these are short lived and used for a particular piece of testing &amp;ldquo;“ others are kept for years. I decided that I wanted to keep up to date on the patching of these virtual machines so installed WSUS on a Windows 2012 box.&lt;/p&gt;
&lt;p&gt;One issue is that if a VM isn&amp;rdquo;™t started for 10 days WSUS starts complaining that it hasn&amp;quot;™t been contacted and if you run the WSUS clean up wizard the non-reporting servers may be removed. Checking the WSUS console for which machines haven&amp;quot;™t sync&amp;quot;™d recently is a chore.&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>My test environment usually has a dozen or so machines at any one time. Some of these are short lived and used for a particular piece of testing &ldquo;“ others are kept for years. I decided that I wanted to keep up to date on the patching of these virtual machines so installed WSUS on a Windows 2012 box.</p><p>One issue is that if a VM isn&rdquo;™t started for 10 days WSUS starts complaining that it hasn"™t been contacted and if you run the WSUS clean up wizard the non-reporting servers may be removed. Checking the WSUS console for which machines haven"™t sync"™d recently is a chore.</p><p>In Windows 2012 both WSUS and Hyper-V come with a PowerShell module. This means I can do this:</p><p>`$date</p><p>=</p><p>(</p><p>Get-Date</p><p>)</p><p>.</p><p>AddDays</p><p>(</p><p>-10</p><p>)</p><p>Get-WsusComputer</p><p>-ToLastSyncTime</p><p>$date</p><p>|</p><p>sort</p><p>LastSyncTime</p><p>|</p><p>select</p><p>-First</p><p>4</p><p>|</p><p>foreach</p><p>{</p><p>$computer</p><p>=</p><p>(</p><p>$_</p><p>.</p><p>FullDomainName</p><p>-split</p><p>&ldquo;.&rdquo;</p><p>)</p><p>[</p><p>]</p><p>Start-VM</p><p>-Name</p><p>$computer</p><p>-ComputerName</p><p>Server02</p><p>-Passthru</p><p>}</p><p>`I"™m using the WSUS server as my admin box but if you were accessing a remote WSUS machine change the code to</p><p>Get-WsusServer -Name w12sus -PortNumber 8530 | Get-WsusComputer &ldquo;“ToLastSyncTime $date |</p><p>I sorted the computers WSUS knows about by date &ldquo;“ picked the last 4 to sync so I didn&rdquo;™t overwhelm the Hyper-V host and started them up. Only trick is to get the computer name out of the FullDomainName property.</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2797/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2797/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2797&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>Account SIDs"“hopefully my last word</title><link>https://powershell.org/articles/2013-01-17-account-sids-hopefully-my-last-word/</link><guid>https://powershell.org/articles/2013-01-17-account-sids-hopefully-my-last-word/</guid><pubDate>Thu, 17 Jan 2013 08:25:50 +0000</pubDate><description>&lt;p&gt;Ok the embarrassing moral of this story is that you shouldn&amp;rsquo;t answer questions in a hurry at the end of the evening. 5 minutes after shutting down I realised that there is a far, far simpler way to get the info. Win32_AccountSID is a WMI linking class. It links Win32_SystemAccount and Win32_SID classes.&lt;/p&gt;
&lt;p&gt;Get-WmiObject -Class Win32_SystemAccount | select Caption, Domain, Name, SID, LocalAccount&lt;/p&gt;
&lt;p&gt;gets you all you need&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2796/"&gt;&lt;img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2796/" alt=""&gt;&lt;/a&gt;&lt;img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;amp;blog=16267735&amp;amp;%23038;post=2796&amp;amp;%23038;subd=richardspowershellblog&amp;amp;%23038;ref=&amp;amp;%23038;feed=1" alt=""&gt;&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>Ok the embarrassing moral of this story is that you shouldn&rsquo;t answer questions in a hurry at the end of the evening. 5 minutes after shutting down I realised that there is a far, far simpler way to get the info. Win32_AccountSID is a WMI linking class. It links Win32_SystemAccount and Win32_SID classes.</p><p>Get-WmiObject -Class Win32_SystemAccount | select Caption, Domain, Name, SID, LocalAccount</p><p>gets you all you need</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2796/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2796/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2796&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>Account SIDs revisited</title><link>https://powershell.org/articles/2013-01-16-account-sids-revisited/</link><guid>https://powershell.org/articles/2013-01-16-account-sids-revisited/</guid><pubDate>Wed, 16 Jan 2013 22:48:05 +0000</pubDate><description>&lt;p&gt;I realised there is an easier way to get the data&lt;/p&gt;
&lt;p&gt;`function&lt;/p&gt;
&lt;p&gt;get-SID&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;param&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;[string]&lt;/p&gt;
&lt;p&gt;$computername&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;$env:COMPUTERNAME&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;Get-WmiObject&lt;/p&gt;
&lt;p&gt;-Class&lt;/p&gt;
&lt;p&gt;Win32_AccountSID&lt;/p&gt;
&lt;p&gt;-ComputerName&lt;/p&gt;
&lt;p&gt;$computername&lt;/p&gt;
&lt;p&gt;|&lt;/p&gt;
&lt;p&gt;foreach&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;$exp&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;&amp;ldquo;[wmi]'&amp;rdquo;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;$(&lt;/p&gt;
&lt;p&gt;$_&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;Element&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;ldquo;'&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Invoke-Expression&lt;/p&gt;
&lt;p&gt;-Command&lt;/p&gt;
&lt;p&gt;$exp&lt;/p&gt;
&lt;p&gt;|&lt;/p&gt;
&lt;p&gt;select&lt;/p&gt;
&lt;p&gt;Domain&lt;/p&gt;
&lt;p&gt;,&lt;/p&gt;
&lt;p&gt;Name&lt;/p&gt;
&lt;p&gt;,&lt;/p&gt;
&lt;p&gt;SID&lt;/p&gt;
&lt;p&gt;,&lt;/p&gt;
&lt;p&gt;LocalAccount&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;`Use the wmi type accelerator with the path from the Element and you can just select the data you want. As a bonus you can discover if the account is local or not&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>I realised there is an easier way to get the data</p><p>`function</p><p>get-SID</p><p>{</p><p>param</p><p>(</p><p>[string]</p><p>$computername</p><p>=</p><p>$env:COMPUTERNAME</p><p>)</p><p>Get-WmiObject</p><p>-Class</p><p>Win32_AccountSID</p><p>-ComputerName</p><p>$computername</p><p>|</p><p>foreach</p><p>{</p><p>$exp</p><p>=</p><p>&ldquo;[wmi]'&rdquo;</p><ul><li/></ul><p>$(</p><p>$_</p><p>.</p><p>Element</p><p>)</p><ul><li/></ul><p>&ldquo;'&rdquo;</p><p>Invoke-Expression</p><p>-Command</p><p>$exp</p><p>|</p><p>select</p><p>Domain</p><p>,</p><p>Name</p><p>,</p><p>SID</p><p>,</p><p>LocalAccount</p><p>}</p><p>}</p><p>`Use the wmi type accelerator with the path from the Element and you can just select the data you want. As a bonus you can discover if the account is local or not</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2795/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2795/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2795&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>Passing function names</title><link>https://powershell.org/articles/2013-01-16-passing-function-names/</link><guid>https://powershell.org/articles/2013-01-16-passing-function-names/</guid><pubDate>Wed, 16 Jan 2013 22:32:38 +0000</pubDate><description>&lt;p&gt;A question asked about passing a function name into another function which then called the function. It sounds worse than it is. if you need to pass the name of a command and then call it try using invoke-expression&lt;/p&gt;
&lt;p&gt;`function&lt;/p&gt;
&lt;p&gt;ffour&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;Get-Random&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;function&lt;/p&gt;
&lt;p&gt;fthree&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;Get-Date&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;function&lt;/p&gt;
&lt;p&gt;ftwo&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;param&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;[string]&lt;/p&gt;
&lt;p&gt;$fname&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;Invoke-Expression&lt;/p&gt;
&lt;p&gt;$fname&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;&amp;ldquo;date&amp;rdquo;&lt;/p&gt;
&lt;p&gt;ftwo&lt;/p&gt;
&lt;p&gt;fthree&lt;/p&gt;
&lt;p&gt;&amp;ldquo;random&amp;rdquo;&lt;/p&gt;
&lt;p&gt;ftwo&lt;/p&gt;
&lt;p&gt;ffour&lt;/p&gt;
&lt;p&gt;`&lt;a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2794/"&gt;&lt;img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2794/" alt=""&gt;&lt;/a&gt;&lt;img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;amp;blog=16267735&amp;amp;%23038;post=2794&amp;amp;%23038;subd=richardspowershellblog&amp;amp;%23038;ref=&amp;amp;%23038;feed=1" alt=""&gt;&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>A question asked about passing a function name into another function which then called the function. It sounds worse than it is. if you need to pass the name of a command and then call it try using invoke-expression</p><p>`function</p><p>ffour</p><p>{</p><p>Get-Random</p><p>}</p><p>function</p><p>fthree</p><p>{</p><p>Get-Date</p><p>}</p><p>function</p><p>ftwo</p><p>{</p><p>param</p><p>(</p><p>[string]</p><p>$fname</p><p>)</p><p>Invoke-Expression</p><p>$fname</p><p>}</p><p>&ldquo;date&rdquo;</p><p>ftwo</p><p>fthree</p><p>&ldquo;random&rdquo;</p><p>ftwo</p><p>ffour</p><p>`<a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2794/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2794/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2794&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>Account SIDs</title><link>https://powershell.org/articles/2013-01-16-account-sids/</link><guid>https://powershell.org/articles/2013-01-16-account-sids/</guid><pubDate>Wed, 16 Jan 2013 22:22:45 +0000</pubDate><description>&lt;p&gt;A question on the forum asked about finding the accounts and SIDs on the local machine.&lt;/p&gt;
&lt;p&gt;`function&lt;/p&gt;
&lt;p&gt;get-SID&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;param&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;[string]&lt;/p&gt;
&lt;p&gt;$computername&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;$env:COMPUTERNAME&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;Get-WmiObject&lt;/p&gt;
&lt;p&gt;-Class&lt;/p&gt;
&lt;p&gt;Win32_AccountSID&lt;/p&gt;
&lt;p&gt;-ComputerName&lt;/p&gt;
&lt;p&gt;$computername&lt;/p&gt;
&lt;p&gt;|&lt;/p&gt;
&lt;p&gt;foreach&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;$da&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;$_&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;Element&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;Split&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;&amp;ldquo;.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;[&lt;/p&gt;
&lt;p&gt;1&lt;/p&gt;
&lt;p&gt;]&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;Split&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;&amp;ldquo;,&amp;rdquo;&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;$sid&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;$_&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;Setting&lt;/p&gt;
&lt;p&gt;-split&lt;/p&gt;
&lt;p&gt;&amp;ldquo;=&amp;rdquo;&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;[&lt;/p&gt;
&lt;p&gt;1&lt;/p&gt;
&lt;p&gt;]&lt;/p&gt;
&lt;p&gt;-replace&lt;/p&gt;
&lt;p&gt;&amp;lsquo;&amp;quot;&amp;rsquo;&lt;/p&gt;
&lt;p&gt;,&lt;/p&gt;
&lt;p&gt;''&lt;/p&gt;
&lt;p&gt;$props&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;[ordered]&lt;/p&gt;
&lt;p&gt;@{&lt;/p&gt;
&lt;p&gt;Domain&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;$da&lt;/p&gt;
&lt;p&gt;[&lt;/p&gt;
&lt;p&gt;]&lt;/p&gt;
&lt;p&gt;-split&lt;/p&gt;
&lt;p&gt;&amp;ldquo;=&amp;rdquo;&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;[&lt;/p&gt;
&lt;p&gt;1&lt;/p&gt;
&lt;p&gt;]&lt;/p&gt;
&lt;p&gt;-replace&lt;/p&gt;
&lt;p&gt;&amp;lsquo;&amp;quot;&amp;rsquo;&lt;/p&gt;
&lt;p&gt;,&lt;/p&gt;
&lt;p&gt;''&lt;/p&gt;
&lt;p&gt;Account&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;$da&lt;/p&gt;
&lt;p&gt;[&lt;/p&gt;
&lt;p&gt;1&lt;/p&gt;
&lt;p&gt;]&lt;/p&gt;
&lt;p&gt;-split&lt;/p&gt;
&lt;p&gt;&amp;ldquo;=&amp;rdquo;&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;[&lt;/p&gt;
&lt;p&gt;1&lt;/p&gt;
&lt;p&gt;]&lt;/p&gt;
&lt;p&gt;-replace&lt;/p&gt;
&lt;p&gt;&amp;lsquo;&amp;quot;&amp;rsquo;&lt;/p&gt;
&lt;p&gt;,&lt;/p&gt;
&lt;p&gt;''&lt;/p&gt;
&lt;p&gt;SID&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;$sid&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;New-Object&lt;/p&gt;
&lt;p&gt;-TypeName&lt;/p&gt;
&lt;p&gt;PSObject&lt;/p&gt;
&lt;p&gt;-Property&lt;/p&gt;
&lt;p&gt;$props&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;`Pass a computer name into the function &amp;ldquo;“ default is local machine.&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>A question on the forum asked about finding the accounts and SIDs on the local machine.</p><p>`function</p><p>get-SID</p><p>{</p><p>param</p><p>(</p><p>[string]</p><p>$computername</p><p>=</p><p>$env:COMPUTERNAME</p><p>)</p><p>Get-WmiObject</p><p>-Class</p><p>Win32_AccountSID</p><p>-ComputerName</p><p>$computername</p><p>|</p><p>foreach</p><p>{</p><p>$da</p><p>=</p><p>(</p><p>(</p><p>$_</p><p>.</p><p>Element</p><p>)</p><p>.</p><p>Split</p><p>(</p><p>&ldquo;.&rdquo;</p><p>)</p><p>[</p><p>1</p><p>]</p><p>)</p><p>.</p><p>Split</p><p>(</p><p>&ldquo;,&rdquo;</p><p>)</p><p>$sid</p><p>=</p><p>(</p><p>$_</p><p>.</p><p>Setting</p><p>-split</p><p>&ldquo;=&rdquo;</p><p>)</p><p>[</p><p>1</p><p>]</p><p>-replace</p><p>&lsquo;"&rsquo;</p><p>,</p><p>''</p><p>$props</p><p>=</p><p>[ordered]</p><p>@{</p><p>Domain</p><p>=</p><p>(</p><p>$da</p><p>[</p><p>]</p><p>-split</p><p>&ldquo;=&rdquo;</p><p>)</p><p>[</p><p>1</p><p>]</p><p>-replace</p><p>&lsquo;"&rsquo;</p><p>,</p><p>''</p><p>Account</p><p>=</p><p>(</p><p>$da</p><p>[</p><p>1</p><p>]</p><p>-split</p><p>&ldquo;=&rdquo;</p><p>)</p><p>[</p><p>1</p><p>]</p><p>-replace</p><p>&lsquo;"&rsquo;</p><p>,</p><p>''</p><p>SID</p><p>=</p><p>$sid</p><p>}</p><p>New-Object</p><p>-TypeName</p><p>PSObject</p><p>-Property</p><p>$props</p><p>}</p><p>}</p><p>`Pass a computer name into the function &ldquo;“ default is local machine.</p><p>Use the AccountSID class which links Win32_SystemAccount and Win32_SID. For each returned instance clean up the data and create an object with three properties &ldquo;“ domain, account and SID.</p><p>You will see more than you thought &ldquo;“ some very useful information buried in there</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2793/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2793/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2793&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>UK PowerShell group "“ 29 January 2013</title><link>https://powershell.org/articles/2013-01-16-uk-powershell-group-29-january-2013/</link><guid>https://powershell.org/articles/2013-01-16-uk-powershell-group-29-january-2013/</guid><pubDate>Wed, 16 Jan 2013 20:28:38 +0000</pubDate><description>&lt;p&gt;`**When: Tuesday, Jan 29, 2013 7:30 PM (GMT)&lt;/p&gt;
&lt;p&gt;Where: virtual&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; *~*~*~*~*~*~*~*~*~*
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`Active Directory is one of the commonest automation targets for administrators. This session will covert the basics of automating your AD admin – scripts and the Microsoft cmdlets. The new features in PowerShell for Windows 2012 AD will also be covered&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; Notes**`Richard Siddaway has invited you to attend an online meeting using Live Meeting.**[Join the meeting.](https://www.livemeeting.com/cc/usergroups/join?id=RCRWH3&amp;amp;role=attend&amp;amp;pw=5p7%24%7DS_%21h)****Audio Information****Computer Audio****To use computer audio, you need speakers and microphone, or a headset.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;First Time Users:&lt;strong&gt;&lt;strong&gt;To save time before the meeting, &lt;a href="http://go.microsoft.com/fwlink/?LinkId=90703"&gt;check your system &lt;/a&gt;to make sure it is ready to use Microsoft Office Live Meeting.
Troubleshooting&lt;/strong&gt;&lt;/strong&gt;Unable to join the meeting? Follow these steps:&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>`**When: Tuesday, Jan 29, 2013 7:30 PM (GMT)</p><p>Where: virtual</p><pre><code> *~*~*~*~*~*~*~*~*~*</code></pre><p>`Active Directory is one of the commonest automation targets for administrators. This session will covert the basics of automating your AD admin – scripts and the Microsoft cmdlets. The new features in PowerShell for Windows 2012 AD will also be covered</p><pre><code> Notes**`Richard Siddaway has invited you to attend an online meeting using Live Meeting.**[Join the meeting.](https://www.livemeeting.com/cc/usergroups/join?id=RCRWH3&amp;role=attend&amp;pw=5p7%24%7DS_%21h)****Audio Information****Computer Audio****To use computer audio, you need speakers and microphone, or a headset.</code></pre><p>First Time Users:<strong><strong>To save time before the meeting,<a href="http://go.microsoft.com/fwlink/?LinkId=90703">check your system</a>to make sure it is ready to use Microsoft Office Live Meeting.
Troubleshooting</strong></strong>Unable to join the meeting? Follow these steps:</p><ul><li><p>Copy this address and paste it into your web browser:<a href="https://www.livemeeting.com/cc/usergroups/join">https://www.livemeeting.com/cc/usergroups/join</a></p><p>Copy and paste the required information:
Meeting ID: RCRWH3
Entry Code: 5p7$}S_!h
Location:<a href="https://www.livemeeting.com/cc/usergroups">https://www.livemeeting.com/cc/usergroups</a></p><p>If you still cannot enter the meeting,<a href="http://r.office.microsoft.com/r/rlidLiveMeeting?p1=12&amp;p2=en_US&amp;p3=LMInfo&amp;p4=support">contact support</a></p><p>Notice**
Microsoft Office Live Meeting can be used to record meetings. By participating in this meeting, you agree that your communications may be monitored or recorded at any time during the meeting.</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2792/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2792/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2792&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/></li></ul>
]]></content:encoded></item><item><title>PowerShell wins award</title><link>https://powershell.org/articles/2013-01-16-powershell-wins-award/</link><guid>https://powershell.org/articles/2013-01-16-powershell-wins-award/</guid><pubDate>Wed, 16 Jan 2013 18:19:21 +0000</pubDate><description>&lt;p&gt;PowerShell has won one on InfoWorld&amp;quot;™s Technology of the Year awards for 2013&lt;/p&gt;
&lt;p&gt;See &lt;a href="http://www.infoworld.com/slideshow/80986/infoworlds-2013-technology-of-the-year-award-winners-210419#slide24"&gt;http://www.infoworld.com/slideshow/80986/infoworlds-2013-technology-of-the-year-award-winners-210419#slide24&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;for details&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2791/"&gt;&lt;img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2791/" alt=""&gt;&lt;/a&gt;&lt;img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;amp;blog=16267735&amp;amp;%23038;post=2791&amp;amp;%23038;subd=richardspowershellblog&amp;amp;%23038;ref=&amp;amp;%23038;feed=1" alt=""&gt;&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>PowerShell has won one on InfoWorld"™s Technology of the Year awards for 2013</p><p>See<a href="http://www.infoworld.com/slideshow/80986/infoworlds-2013-technology-of-the-year-award-winners-210419#slide24">http://www.infoworld.com/slideshow/80986/infoworlds-2013-technology-of-the-year-award-winners-210419#slide24</a></p><p>for details</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2791/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2791/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2791&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>Workflow article 4</title><link>https://powershell.org/articles/2013-01-16-workflow-article-4/</link><guid>https://powershell.org/articles/2013-01-16-workflow-article-4/</guid><pubDate>Wed, 16 Jan 2013 17:03:48 +0000</pubDate><description>&lt;p&gt;The next in the series of articles on PowerShell workflows that are appearing on the Scripting Guy blog has been published.&lt;/p&gt;
&lt;p&gt;The articles in the series that have been published are:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx"&gt;http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx&lt;/a&gt;&lt;br&gt;
&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx"&gt;http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx&lt;/a&gt;&lt;br&gt;
&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/09/powershell-workflows-nesting.aspx"&gt;http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/09/powershell-workflows-nesting.aspx&lt;/a&gt;&lt;br&gt;
&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/16/powershell-workflows-job-engine.aspx"&gt;http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/16/powershell-workflows-job-engine.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Look for the next article in one weeks time.&lt;/p&gt;
&lt;p&gt;Until then Enjoy!&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2790/"&gt;&lt;img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2790/" alt=""&gt;&lt;/a&gt;&lt;img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;amp;blog=16267735&amp;amp;%23038;post=2790&amp;amp;%23038;subd=richardspowershellblog&amp;amp;%23038;ref=&amp;amp;%23038;feed=1" alt=""&gt;&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>The next in the series of articles on PowerShell workflows that are appearing on the Scripting Guy blog has been published.</p><p>The articles in the series that have been published are:</p><p><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx">http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx</a><br><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx">http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx</a><br><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/09/powershell-workflows-nesting.aspx">http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/09/powershell-workflows-nesting.aspx</a><br><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/16/powershell-workflows-job-engine.aspx">http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/16/powershell-workflows-job-engine.aspx</a></p><p>Look for the next article in one weeks time.</p><p>Until then Enjoy!</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2790/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2790/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2790&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>Updating Help on PowerShell v3</title><link>https://powershell.org/articles/2013-01-15-updating-help-on-powershell-v3/</link><guid>https://powershell.org/articles/2013-01-15-updating-help-on-powershell-v3/</guid><pubDate>Tue, 15 Jan 2013 21:37:41 +0000</pubDate><description>&lt;p&gt;One of the new features in PowerShell v3 is the capability to update the help files. In fact you have to do this because PowerShell v3 doesn&amp;quot;™t ship with any help files. Since Windows 8 RTM&amp;quot;™d there have been a succession of new help files released.&lt;/p&gt;
&lt;p&gt;I discovered one of my netbooks didn&amp;quot;™t have the latest version of the help files installed. So I needed to update them. This got me thinking that it would be better if the machine did this for me.&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>One of the new features in PowerShell v3 is the capability to update the help files. In fact you have to do this because PowerShell v3 doesn"™t ship with any help files. Since Windows 8 RTM"™d there have been a succession of new help files released.</p><p>I discovered one of my netbooks didn"™t have the latest version of the help files installed. So I needed to update them. This got me thinking that it would be better if the machine did this for me.</p><p>I could think of two easy ways to do this &ldquo;“ a scheduled job or a scheduled task. I chose the scheduled task because the ScheduledTasks module is available on the version of PowerShell v3 for Windows 7 and other legacy versions of Windows. The PSScheduledJob module is only available on Windows 8/2012 as it&rdquo;™s based on WMI classes not present on older versions of Windows.</p><p>`$actionscript</p><p>=</p><p>&lsquo;-NonInteractive -WindowStyle Normal -NoLogo -NoProfile -NoExit -Command &ldquo;&amp; {Update-Help -UICulture en-US -Force}&rdquo;&rsquo;</p><p>$pstart</p><p>=</p><p>&ldquo;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe&rdquo;</p><p>#$days = &ldquo;Monday&rdquo;, &ldquo;Tuesday&rdquo;, &ldquo;Wednesday&rdquo;, &ldquo;Thursday&rdquo;, &ldquo;Friday&rdquo;, &ldquo;Saturday&rdquo;, &ldquo;Sunday&rdquo;</p><p>$days</p><p>=</p><p>&lsquo;Wednesday&rsquo;</p><p>Get-ScheduledTask</p><p>-TaskName</p><p>UpdatePSHelp</p><p>|</p><p>Unregister-ScheduledTask</p><p>-Confirm:</p><p>$false</p><p>$act</p><p>=</p><p>New-ScheduledTaskAction</p><p>-Execute</p><p>$pstart</p><p>-Argument</p><p>$actionscript</p><p>$trig</p><p>=</p><p>New-ScheduledTaskTrigger</p><p>-Weekly</p><p>-WeeksInterval</p><p>4</p><p>-At</p><p>19:00</p><p>-DaysOfWeek</p><p>$days</p><p>Register-ScheduledTask</p><p>-TaskName</p><p>UpdatePSHelp</p><p>-Action</p><p>$act</p><p>-Trigger</p><p>$trig</p><p>-RunLevel</p><p>Highest</p><p>`Start by creating the command strings to start PowerShell and the arguments you pass to it. I left it as a visible PowerShell window that stays opn so I can see the results. The PowerShell command</p><p>Update-Help -UICulture en-US &ldquo;“Force</p><p>performs the actual update. You will need to change the culture to match yours if you aren&rdquo;™t using English. You can find it by using</p><p>Get-UICulture</p><p>I"™m only going to run this on Wednesdays .</p><p>Any old copies of the task are cleaned out and new task actions (to execute PowerShell) and trigger to define when it runs are created. The last line registers the task.</p><p>You can view the task</p><p>Get-ScheduledTask -TaskName UpdatePSHelp</p><p>or start the task manually</p><p>Start-ScheduledTask -TaskName UpdatePSHelp</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2789/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2789/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2789&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>Planning the PowerShell Summit North America 2014</title><link>https://powershell.org/articles/2013-01-12-planning-the-powershell-summit-north-america-2014/</link><guid>https://powershell.org/articles/2013-01-12-planning-the-powershell-summit-north-america-2014/</guid><pubDate>Sat, 12 Jan 2013 20:35:17 +0000</pubDate><description>&lt;p&gt;We&amp;rsquo;re already planning for the 2014 Summit&amp;hellip; you have to get way out in front of these things to secure space, plan a budget, and more.&lt;br&gt;
Here&amp;rsquo;s what we know:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We&amp;rsquo;ll definitely still be in the Seattle metro area. That&amp;rsquo;s the best way to ensure participation from the PowerShell team, since it doesn&amp;rsquo;t require them to leave town for days at a time.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We&amp;rsquo;ll be in April 2014. We&amp;rsquo;re going to try for April 14-16 to avoid Easter, or April 28-30.&lt;/li&gt;
&lt;li&gt;We&amp;rsquo;ll be in a bigger venue. We hope to support a crowd of up to 300, although we&amp;rsquo;re still aiming for a smaller group. That&amp;rsquo;ll give us more flexibility in session planning, along with the possibility of on-site evening events.&lt;/li&gt;
&lt;li&gt;We will &lt;strong&gt;open up early bird ticketing&lt;/strong&gt; for 2013 alumni the week of April 29-May 3. 50 tickets will be available. If there are any of those tickets left after May 3, they&amp;rsquo;ll be offered to the public May 6 through 10. Any remaining early bird tickets will be converted to full-price tickets after May 10, when general sales will begin. Early bird pricing will be in the $650 range. Full pricing will be around $850. This is more than 2013, but will help us (a) fully reimburse speaker travel expenses, which we couldn&amp;rsquo;t do in 2013, (b) pay for the larger conference venue, (c) offer a full hot breakfast every day and beverages throughout the day, and (d) allow for bussing to the event venue (see below). Early Bird tickets will be fully refundable until the end of 2013.&lt;/li&gt;
&lt;li&gt;We are going to try and hold a percentage of our full-price tickets for release in January 2014. That way, people who can&amp;rsquo;t get budget until the year-of will still have a shot at tickets. This will be a small block of tickets, though - probably less than 30 - so if you can get budget to buy your tickets in 2013, do it.&lt;/li&gt;
&lt;li&gt;We will offer bussing from &lt;strong&gt;one&lt;/strong&gt; hotel complex to the event venue in the mornings, with return busses at night. It will be crucial that you book your hotel as soon as possible once we announce, so that you can lock in a room. This can help eliminate the need for a rental car, and lower your trip expenses. At least one hotel option at around $100-$110 a night will be offered, although it may be a limited room block. For folks in the US, you should be able to attend for about $2,000 including air, hotel, and registration. Add in dinners (which we don&amp;rsquo;t provide) and you should be able to attend for under $2500 including expenses. Not bad!&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As you can see, we&amp;rsquo;re still trying to keep things as affordable and accessible as possible, in keeping with the nature of a community-owned event. We&amp;rsquo;re also trying to build this event into one that can support itself and continue to grow.&lt;br&gt;
I know a lot of folks who wanted to come in 2013 missed out&amp;hellip; so that&amp;rsquo;s why I&amp;rsquo;m giving you as much heads-up as possible. Start getting the boss on board. Get purchasing on board. Start planning to have the credit card ready in April 2013. We&amp;rsquo;ll get as many folks as we can into the 2014 Summit!&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>We&rsquo;re already planning for the 2014 Summit&hellip; you have to get way out in front of these things to secure space, plan a budget, and more.<br>
Here&rsquo;s what we know:</p><ul><li/></ul><p>We&rsquo;ll definitely still be in the Seattle metro area. That&rsquo;s the best way to ensure participation from the PowerShell team, since it doesn&rsquo;t require them to leave town for days at a time.</p><ul><li>We&rsquo;ll be in April 2014. We&rsquo;re going to try for April 14-16 to avoid Easter, or April 28-30.</li><li>We&rsquo;ll be in a bigger venue. We hope to support a crowd of up to 300, although we&rsquo;re still aiming for a smaller group. That&rsquo;ll give us more flexibility in session planning, along with the possibility of on-site evening events.</li><li>We will <strong>open up early bird ticketing</strong> for 2013 alumni the week of April 29-May 3. 50 tickets will be available. If there are any of those tickets left after May 3, they&rsquo;ll be offered to the public May 6 through 10. Any remaining early bird tickets will be converted to full-price tickets after May 10, when general sales will begin. Early bird pricing will be in the $650 range. Full pricing will be around $850. This is more than 2013, but will help us (a) fully reimburse speaker travel expenses, which we couldn&rsquo;t do in 2013, (b) pay for the larger conference venue, (c) offer a full hot breakfast every day and beverages throughout the day, and (d) allow for bussing to the event venue (see below). Early Bird tickets will be fully refundable until the end of 2013.</li><li>We are going to try and hold a percentage of our full-price tickets for release in January 2014. That way, people who can&rsquo;t get budget until the year-of will still have a shot at tickets. This will be a small block of tickets, though - probably less than 30 - so if you can get budget to buy your tickets in 2013, do it.</li><li>We will offer bussing from <strong>one</strong> hotel complex to the event venue in the mornings, with return busses at night. It will be crucial that you book your hotel as soon as possible once we announce, so that you can lock in a room. This can help eliminate the need for a rental car, and lower your trip expenses. At least one hotel option at around $100-$110 a night will be offered, although it may be a limited room block. For folks in the US, you should be able to attend for about $2,000 including air, hotel, and registration. Add in dinners (which we don&rsquo;t provide) and you should be able to attend for under $2500 including expenses. Not bad!</li></ul><p>As you can see, we&rsquo;re still trying to keep things as affordable and accessible as possible, in keeping with the nature of a community-owned event. We&rsquo;re also trying to build this event into one that can support itself and continue to grow.<br>
I know a lot of folks who wanted to come in 2013 missed out&hellip; so that&rsquo;s why I&rsquo;m giving you as much heads-up as possible. Start getting the boss on board. Get purchasing on board. Start planning to have the credit card ready in April 2013. We&rsquo;ll get as many folks as we can into the 2014 Summit!</p>
]]></content:encoded></item><item><title>Select-string "“ keeping in context</title><link>https://powershell.org/articles/2013-01-11-select-string-keeping-in-context/</link><guid>https://powershell.org/articles/2013-01-11-select-string-keeping-in-context/</guid><pubDate>Fri, 11 Jan 2013 19:43:05 +0000</pubDate><description>&lt;p&gt;Today&amp;quot;™s question involves using the Context parameter:&lt;/p&gt;
&lt;p&gt;*It&amp;rsquo;s probably just me, but I&amp;rsquo;ve never gotten the switch &amp;lsquo;-context 5 *&lt;em&gt;or -context 2, 7′ to work predictably – where 5 lines before and after or 2
before and 7 after will come out – have you?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Let&amp;quot;™s start by looking at the default behaviour of select-string using the search pattern you&amp;quot;™ve seen previously:&lt;/p&gt;
&lt;p&gt;PS&amp;gt; Select-String -Path c:\test*.txt -Pattern &amp;ldquo;\A\w{5}ABCD&amp;rdquo;&lt;/p&gt;
&lt;p&gt;C:\test\fixedcol.txt:1:12345ABCD123451234512345&lt;/p&gt;
&lt;p&gt;C:\test\fixedcol.txt:3:12345ABCD123451234512345&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>Today"™s question involves using the Context parameter:</p><p>*It&rsquo;s probably just me, but I&rsquo;ve never gotten the switch &lsquo;-context 5 *<em>or -context 2, 7′ to work predictably – where 5 lines before and after or 2
before and 7 after will come out – have you?</em></p><p>Let"™s start by looking at the default behaviour of select-string using the search pattern you"™ve seen previously:</p><p>PS&gt; Select-String -Path c:\test*.txt -Pattern &ldquo;\A\w{5}ABCD&rdquo;</p><p>C:\test\fixedcol.txt:1:12345ABCD123451234512345</p><p>C:\test\fixedcol.txt:3:12345ABCD123451234512345</p><p>C:\test\fixedcol.txt:4:12345abcd123451234512345</p><p>C:\test\fixedcol.txt:6:12345ABCD123451234512345</p><p>C:\test\fixedcol2.txt:1:12345ABCD123451234512345</p><p>As you can see the line which matches your pattern is returned.</p><p>Often this is all that is required but there are occasions when you need to be able to put the line into context that is you need to understand how the line containing you pattern relates to the data around it.</p><p>The is what the context parameter can provide.</p><p>If you look at the Select-String help file you will find this information on context.</p><p>-Context** *</p><p>Captures the specified number of lines before and after the line with the match. This allows you to view the match in context.</p><p>Required?</p><p>false</p><p>Position?</p><p>named</p><p>Default value</p><p>Accept pipeline input?</p><p>false</p><p>Accept wildcard characters?</p><p>false</p><p>The first thing to note is that the parameter takes an array of integers. The first (or only member of the array) tells PowerShell how many lines to show from before* and *after *the matching line while the second member of the array controls the number of lines that are displayed<em>after</em> the matching line. Put simply if you supply one values it controls the number of lines from before and after you match that are displayed but if you specify two values then you explicitly control the lines from before the match with the first value and the lines from after the match with the second. Some examples should make this clear.</p><p>I"™m going to use a file where we know the contents &ldquo;“ it makes the explanations easier. If you run this:</p><p>Get-Process | sort CPU -Descending | Out-File -FilePath c:\test\proc.txt &ldquo;“Force</p><p>You get a text file with the processes listed by CPU usage. You can examine the file for a particular process &ldquo;“ this case let&rdquo;™s look at Word:</p><p>PS&gt; Select-String -Path c:\test*.txt -Pattern &ldquo;Winword&rdquo; -SimpleMatch</p><p>C:\test\proc.txt:8:</p><p>360</p><p>25</p><p>20368</p><p>61728</p><p>331</p><p>41.89</p><p>4976 WINWORD</p><p>You know that the file is ordered by CPU usage so what are the processes using similar amounts of CPU to Word?</p><p>PS&gt; Select-String -Path c:\test*.txt -Pattern &ldquo;Winword&rdquo; -SimpleMatch -Context 2</p><p>C:\test\proc.txt:6:</p><p>653</p><p>34</p><p>66640</p><p>94416</p><p>286</p><p>48.77</p><p>3724 powershell</p><p>C:\test\proc.txt:7:</p><p>1124</p><p>29</p><p>13912</p><p>19336</p><p>210</p><p>47.71</p><p>5868 LiveComm</p><blockquote><p>C:\test\proc.txt:8:</p></blockquote><p>360</p><p>25</p><p>20368</p><p>61728</p><p>331</p><p>41.89</p><p>4976 WINWORD</p><p>C:\test\proc.txt:9:</p><p>212</p><p>9</p><p>2788</p><p>10956</p><p>78</p><p>28.67</p><p>4112 SynTPEnh</p><p>C:\test\proc.txt:10:</p><p>565</p><p>35</p><p>49172</p><p>82572</p><p>347</p><p>12.50</p><p>5660 WWAHost</p><p>The matching line is marked with a &gt; symbol. I&rdquo;™ve made it bold in the above listing for emphasis.</p><p>If you specify a number such that the file doesn&rdquo;™t have enough lines to display then only those lines that are available will be displayed for instance</p><p>Select-String -Path c:\test*.txt -Pattern &ldquo;Winword&rdquo; -SimpleMatch -Context 12</p><p>This can only display the seven lines prior to the match so that"™s all it does.</p><p>What about the situation where you only want the three processes that are using more CPU than Word?</p><p>PS&gt; Select-String -Path c:\test*.txt -Pattern &ldquo;Winword&rdquo; -SimpleMatch -Context 3,0</p><p>C:\test\proc.txt:5:</p><p>1555</p><p>74</p><p>30660</p><p>87176</p><p>465</p><p>80.70</p><p>5308 explorer</p><p>C:\test\proc.txt:6:</p><p>653</p><p>34</p><p>66640</p><p>94416</p><p>286</p><p>48.77</p><p>3724 powershell</p><p>C:\test\proc.txt:7:</p><p>1124</p><p>29</p><p>13912</p><p>19336</p><p>210</p><p>47.71</p><p>5868 LiveComm</p><blockquote><p>C:\test\proc.txt:8:</p></blockquote><p>360</p><p>25</p><p>20368</p><p>61728</p><p>331</p><p>41.89</p><p>4976 WINWORD</p><p>This works as well</p><p>PS&gt; Select-String -Path c:\test*.txt -Pattern &ldquo;Winword&rdquo; -SimpleMatch -Context 3,$null</p><p>C:\test\proc.txt:5:</p><p>1555</p><p>74</p><p>30660</p><p>87176</p><p>465</p><p>80.70</p><p>5308 explorer</p><p>C:\test\proc.txt:6:</p><p>653</p><p>34</p><p>66640</p><p>94416</p><p>286</p><p>48.77</p><p>3724 powershell</p><p>C:\test\proc.txt:7:</p><p>1124</p><p>29</p><p>13912</p><p>19336</p><p>210</p><p>47.71</p><p>5868 LiveComm</p><blockquote><p>C:\test\proc.txt:8:</p></blockquote><p>360</p><p>25</p><p>20368</p><p>61728</p><p>331</p><p>41.89</p><p>4976 WINWORD</p><p>The one thing you can"™t do is this:</p><p>PS&gt; Select-String -Path c:\test*.txt -Pattern &ldquo;Winword&rdquo; -SimpleMatch -Context 3,</p><blockquote><blockquote/></blockquote><p>PowerShell expects something after the comma and will prompt you to supply it.</p><p>The converse holds true if you want the lines that occur after the match. You can use a 0 as the first element:</p><p>PS&gt; Select-String -Path c:\test*.txt -Pattern &ldquo;Winword&rdquo; -SimpleMatch -Context 0,3</p><blockquote><p>C:\test\proc.txt:8:</p></blockquote><p>360</p><p>25</p><p>20368</p><p>61728</p><p>331</p><p>41.89</p><p>4976 WINWORD</p><p>C:\test\proc.txt:9:</p><p>212</p><p>9</p><p>2788</p><p>10956</p><p>78</p><p>28.67</p><p>4112 SynTPEnh</p><p>C:\test\proc.txt:10:</p><p>565</p><p>35</p><p>49172</p><p>82572</p><p>347</p><p>12.50</p><p>5660 WWAHost</p><p>C:\test\proc.txt:11:</p><p>276</p><p>19</p><p>6608</p><p>12628</p><p>88</p><p>9.33</p><p>5252 taskhostex</p><p>Or $null</p><p>PS&gt; Select-String -Path c:\test*.txt -Pattern &ldquo;Winword&rdquo; -SimpleMatch -Context $null,3</p><blockquote><p>C:\test\proc.txt:8:</p></blockquote><p>360</p><p>25</p><p>20368</p><p>61728</p><p>331</p><p>41.89</p><p>4976 WINWORD</p><p>C:\test\proc.txt:9:</p><p>212</p><p>9</p><p>2788</p><p>10956</p><p>78</p><p>28.67</p><p>4112 SynTPEnh</p><p>C:\test\proc.txt:10:</p><p>565</p><p>35</p><p>49172</p><p>82572</p><p>347</p><p>12.50</p><p>5660 WWAHost</p><p>C:\test\proc.txt:11:</p><p>276</p><p>19</p><p>6608</p><p>12628</p><p>88</p><p>9.33</p><p>5252 taskhostex</p><p>You can"™t leave the first element blank</p><p>PS&gt; Select-String -Path c:\test*.txt -Pattern &ldquo;Winword&rdquo; -SimpleMatch -Context ,3</p><p>At line:1 char:76</p><ul><li><p>Select-String -Path c:\test*.txt -Pattern &ldquo;Winword&rdquo; -SimpleMatch -Context ,3</p></li><li/></ul><p>~</p><p>Missing argument in parameter list.</p><ul><li>CategoryInfo</li></ul><p>: ParserError: (:) [], ParentContainsErrorRecordException</p><ul><li><p>FullyQualifiedErrorId : MissingArgument</p><p>This leads to the situation where you need to display a different number of lines before and after the match:</p><p>PS&gt; Select-String -Path c:\test*.txt -Pattern &ldquo;Winword&rdquo; -SimpleMatch -Context 3,2</p></li></ul><p>C:\test\proc.txt:5:</p><p>1555</p><p>74</p><p>30660</p><p>87176</p><p>465</p><p>80.70</p><p>5308 explorer</p><p>C:\test\proc.txt:6:</p><p>653</p><p>34</p><p>66640</p><p>94416</p><p>286</p><p>48.77</p><p>3724 powershell</p><p>C:\test\proc.txt:7:</p><p>1124</p><p>29</p><p>13912</p><p>19336</p><p>210</p><p>47.71</p><p>5868 LiveComm</p><blockquote><p>C:\test\proc.txt:8:</p></blockquote><p>360</p><p>25</p><p>20368</p><p>61728</p><p>331</p><p>41.89</p><p>4976 WINWORD</p><p>C:\test\proc.txt:9:</p><p>212</p><p>9</p><p>2788</p><p>10956</p><p>78</p><p>28.67</p><p>4112 SynTPEnh</p><p>C:\test\proc.txt:10:</p><p>565</p><p>35</p><p>49172</p><p>82572</p><p>347</p><p>12.50</p><p>5660 WWAHost</p><p>What happens if you have multiple matches and their contexts overlap?</p><p>PS&gt; Select-String -Path c:\test*.txt -Pattern &ldquo;PowerShell&rdquo; -SimpleMatch</p><p>C:\test\proc.txt:9:</p><p>669</p><p>34</p><p>67544</p><p>62228</p><p>286</p><p>54.99</p><p>3724 powershell</p><p>C:\test\proc.txt:12:</p><p>473</p><p>23</p><p>69112</p><p>86616</p><p>366</p><p>11.73</p><p>1688 powershell_ise</p><p>C:\test\proc.txt:19:</p><p>346</p><p>13</p><p>39576</p><p>44540</p><p>207</p><p>3.15</p><p>280 PowerShell</p><p>This file shows matches on lines 9, 12 and 19 so let"™s try this</p><p>PS&gt; Select-String -Path c:\test*.txt -Pattern &ldquo;PowerShell&rdquo; -SimpleMatch -Context 4,5</p><p>C:\test\proc.txt:5:</p><p>1840</p><p>91</p><p>35836</p><p>75652</p><p>545</p><p>142.49</p><p>5308 explorer</p><p>C:\test\proc.txt:6:</p><p>618</p><p>23</p><p>68524</p><p>28788</p><p>194</p><p>108.84</p><p>5072 SkyDrive</p><p>C:\test\proc.txt:7:</p><p>1377</p><p>29</p><p>15668</p><p>23440</p><p>210</p><p>95.07</p><p>5868 LiveComm</p><p>C:\test\proc.txt:8:</p><p>211</p><p>9</p><p>2792</p><p>4516</p><p>78</p><p>59.98</p><p>4112 SynTPEnh</p><p>**&gt; C:\test\proc.txt:9:</p><p>669</p><p>34</p><p>67544</p><p>62228</p><p>286</p><p>54.99</p><p>3724 powershell**</p><p>C:\test\proc.txt:10:</p><p>560</p><p>35</p><p>53480</p><p>88760</p><p>370</p><p>22.95</p><p>2656 WWAHost</p><p>C:\test\proc.txt:11:</p><p>240</p><p>8</p><p>1952</p><p>2340</p><p>71</p><p>12.32</p><p>5580 TabTip</p><p>**&gt; C:\test\proc.txt:12:</p><p>473</p><p>23</p><p>69112</p><p>86616</p><p>366</p><p>11.73</p><p>1688 powershell_ise**</p><p>C:\test\proc.txt:13:</p><p>254</p><p>9</p><p>4684</p><p>9940</p><p>86</p><p>11.31</p><p>6136 RuntimeBroker</p><p>C:\test\proc.txt:14:</p><p>285</p><p>14</p><p>4116</p><p>4724</p><p>84</p><p>10.19</p><p>5252 taskhostex</p><p>C:\test\proc.txt:15:</p><p>82</p><p>5</p><p>2008</p><p>6148</p><p>55</p><p>7.52</p><p>2416 conhost</p><p>C:\test\proc.txt:16:</p><p>305</p><p>14</p><p>17608</p><p>5088</p><p>184</p><p>5.19</p><p>404 IAStorIcon</p><p>C:\test\proc.txt:17:</p><p>337</p><p>8</p><p>2180</p><p>536</p><p>76</p><p>4.79</p><p>376 InputPersonalization</p><p>C:\test\proc.txt:18:</p><p>409</p><p>12</p><p>4416</p><p>5464</p><p>79</p><p>4.26</p><p>5276 taskhost</p><p>**&gt; C:\test\proc.txt:19:</p><p>346</p><p>13</p><p>39576</p><p>44540</p><p>207</p><p>3.15</p><p>280 powershell**</p><p>C:\test\proc.txt:20:</p><p>125</p><p>5</p><p>2820</p><p>744</p><p>70</p><p>2.61</p><p>908 splwow64</p><p>C:\test\proc.txt:21:</p><p>347</p><p>13</p><p>12180</p><p>804</p><p>183</p><p>2.40</p><p>4788 PopUp_DM</p><p>C:\test\proc.txt:22:</p><p>335</p><p>10</p><p>2576</p><p>1756</p><p>83</p><p>2.20</p><p>4636 AdobeARM</p><p>C:\test\proc.txt:23:</p><p>249</p><p>21</p><p>6628</p><p>540</p><p>129</p><p>1.44</p><p>5220 SRSPremiumPanel</p><p>C:\test\proc.txt:24:</p><p>387</p><p>11</p><p>3436</p><p>12280</p><p>83</p><p>0.94</p><p>3828 WSHost</p><p>I"™ve highlighted the lines that actually match.</p><p>Starting with the first match you get 4 lines before it as requested. There should be 5 lines after the match BUT the next match is only 3 lines on and you asked for 5 lines after that. The lines before the last match overlap the lines after the second match. The lines after the last match are shown as requested.</p><p>At first glance it looks like the command hasn"™t worked but what seems to be happening is that only unique lines are displayed.</p><p>I looked at the individual matches</p><p>$finds = Select-String -Path c:\test*.txt -Pattern &ldquo;PowerShell&rdquo; -SimpleMatch -Context 4,5</p><p>for ($i=0; $i -le $finds.count; $i++){$finds[$i]; &ldquo;###"*8}</p><p>and received this output (I&rdquo;™ve split the display so you can see what is produced.</p><p>First match:</p><p>C:\test\proc.txt:5:</p><p>1840</p><p>91</p><p>35836</p><p>75652</p><p>545</p><p>142.49</p><p>5308 explorer</p><p>C:\test\proc.txt:6:</p><p>618</p><p>23</p><p>68524</p><p>28788</p><p>194</p><p>108.84</p><p>5072 SkyDrive</p><p>C:\test\proc.txt:7:</p><p>1377</p><p>29</p><p>15668</p><p>23440</p><p>210</p><p>95.07</p><p>5868 LiveComm</p><p>C:\test\proc.txt:8:</p><p>211</p><p>9</p><p>2792</p><p>4516</p><p>78</p><p>59.98</p><p>4112 SynTPEnh</p><p>**&gt; C:\test\proc.txt:9:</p><p>669</p><p>34</p><p>67544</p><p>62228</p><p>286</p><p>54.99</p><p>3724 powershell**</p><p>C:\test\proc.txt:10:</p><p>560</p><p>35</p><p>53480</p><p>88760</p><p>370</p><p>22.95</p><p>2656 WWAHost</p><p>C:\test\proc.txt:11:</p><p>240</p><p>8</p><p>1952</p><p>2340</p><p>71</p><p>12.32</p><p>5580 TabTip</p><p>########################</p><p>Correct number before but restricted output after</p><p>Second match:</p><p>**&gt; C:\test\proc.txt:12:</p><p>473</p><p>23</p><p>69112</p><p>86616</p><p>366</p><p>11.73</p><p>1688 powershell_ise**</p><p>C:\test\proc.txt:13:</p><p>254</p><p>9</p><p>4684</p><p>9940</p><p>86</p><p>11.31</p><p>6136 RuntimeBroker</p><p>C:\test\proc.txt:14:</p><p>285</p><p>14</p><p>4116</p><p>4724</p><p>84</p><p>10.19</p><p>5252 taskhostex</p><p>C:\test\proc.txt:15:</p><p>82</p><p>5</p><p>2008</p><p>6148</p><p>55</p><p>7.52</p><p>2416 conhost</p><p>C:\test\proc.txt:16:</p><p>305</p><p>14</p><p>17608</p><p>5088</p><p>184</p><p>5.19</p><p>404 IAStorIcon</p><p>C:\test\proc.txt:17:</p><p>337</p><p>8</p><p>2180</p><p>536</p><p>76</p><p>4.79</p><p>376 InputPersonalization</p><p>########################</p><p>Nothing before and correct output after the match</p><p>Last match:</p><p>C:\test\proc.txt:18:</p><p>409</p><p>12</p><p>4416</p><p>5464</p><p>79</p><p>4.26</p><p>5276 taskhost</p><p>**&gt; C:\test\proc.txt:19:</p><p>346</p><p>13</p><p>39576</p><p>44540</p><p>207</p><p>3.15</p><p>280 powershell**</p><p>C:\test\proc.txt:20:</p><p>125</p><p>5</p><p>2820</p><p>744</p><p>70</p><p>2.61</p><p>908 splwow64</p><p>C:\test\proc.txt:21:</p><p>347</p><p>13</p><p>12180</p><p>804</p><p>183</p><p>2.40</p><p>4788 PopUp_DM</p><p>C:\test\proc.txt:22:</p><p>335</p><p>10</p><p>2576</p><p>1756</p><p>83</p><p>2.20</p><p>4636 AdobeARM</p><p>C:\test\proc.txt:23:</p><p>249</p><p>21</p><p>6628</p><p>540</p><p>129</p><p>1.44</p><p>5220 SRSPremiumPanel</p><p>C:\test\proc.txt:24:</p><p>387</p><p>11</p><p>3436</p><p>12280</p><p>83</p><p>0.94</p><p>3828 WSHost</p><p>########################</p><p>One line before the match and correct number after the match.</p><p>This confirms that if a line has appeared in a previous match you won"™t see it again. Is there a way to see the full context for each match? Unfortunately, Select-String doesn"™t appear to provide that capability directly. A little bit of working with the output should enable this.</p><p>Select-String -Path c:\test*.txt -Pattern &ldquo;PowerShell&rdquo; -SimpleMatch -Context 4,5 |</p><p>foreach {</p><p>#matching line</p><p>$padlength = (" {0}:{1:00}: " -f $<em>.Path, $</em>.LineNumber).Length</p><p>$pad = " &ldquo;*$padlength</p><p>$<em>.Context.PreContext | foreach {$</em>.Trim().Insert(0,$pad)}</p><p>"&rdquo;</p><p>" {0}:{1:00}: {2}" -f $<em>.Path, $</em>.LineNumber, ($_.Line).Trim()</p><p>""</p><p>$<em>.Context.PostContext | foreach {$</em>.Trim().Insert(0,$pad)}</p><p>""</p><p>""</p><p>}</p><p>Run the select-string as before. For each of the matches find the length of the formatted path and line number and create a blank string of that length.</p><p>If you examine the MatchInfo type that Select-String produces you will see a Property called Context. If you examine that you will see it contains the collection of data for the pre and post context. (There are also display versions of the context).</p><p>For each line in the pre-context insert the pad characters at the beginning. Display the formatted match line and then display the post-context data.</p><p>I"™ve inserted some blank lines to help format the display</p><p>You will get output like this:</p><p>1840</p><p>91</p><p>35836</p><p>75652</p><p>545</p><p>142.49</p><p>5308 explorer</p><p>618</p><p>23</p><p>68524</p><p>28788</p><p>194</p><p>108.84</p><p>5072 SkyDrive</p><p>1377</p><p>29</p><p>15668</p><p>23440</p><p>210</p><p>95.07</p><p>5868 LiveComm</p><p>211</p><p>9</p><p>2792</p><p>4516</p><p>78</p><p>59.98</p><p>4112 SynTPEnh</p><p>C:\test\proc.txt:09: 669</p><p>34</p><p>67544</p><p>62228</p><p>286</p><p>54.99</p><p>3724 powershell</p><p>560</p><p>35</p><p>53480</p><p>88760</p><p>370</p><p>22.95</p><p>2656 WWAHost</p><p>240</p><p>8</p><p>1952</p><p>2340</p><p>71</p><p>12.32</p><p>5580 TabTip</p><p>473</p><p>23</p><p>69112</p><p>86616</p><p>366</p><p>11.73</p><p>1688 powershell_ise</p><p>254</p><p>9</p><p>4684</p><p>9940</p><p>86</p><p>11.31</p><p>6136 RuntimeBroker</p><p>285</p><p>14</p><p>4116</p><p>4724</p><p>84</p><p>10.19</p><p>5252 taskhostex</p><p>211</p><p>9</p><p>2792</p><p>4516</p><p>78</p><p>59.98</p><p>4112 SynTPEnh</p><p>669</p><p>34</p><p>67544</p><p>62228</p><p>286</p><p>54.99</p><p>3724 powershell</p><p>560</p><p>35</p><p>53480</p><p>88760</p><p>370</p><p>22.95</p><p>2656 WWAHost</p><p>240</p><p>8</p><p>1952</p><p>2340</p><p>71</p><p>12.32</p><p>5580 TabTip</p><p>C:\test\proc.txt:12: 473</p><p>23</p><p>69112</p><p>86616</p><p>366</p><p>11.73</p><p>1688 powershell_ise</p><p>254</p><p>9</p><p>4684</p><p>9940</p><p>86</p><p>11.31</p><p>6136 RuntimeBroker</p><p>285</p><p>14</p><p>4116</p><p>4724</p><p>84</p><p>10.19</p><p>5252 taskhostex</p><p>82</p><p>5</p><p>2008</p><p>6148</p><p>55</p><p>7.52</p><p>2416 conhost</p><p>305</p><p>14</p><p>17608</p><p>5088</p><p>184</p><p>5.19</p><p>404 IAStorIcon</p><p>337</p><p>8</p><p>2180</p><p>536</p><p>76</p><p>4.79</p><p>376 InputPersonalization</p><p>82</p><p>5</p><p>2008</p><p>6148</p><p>55</p><p>7.52</p><p>2416 conhost</p><p>305</p><p>14</p><p>17608</p><p>5088</p><p>184</p><p>5.19</p><p>404 IAStorIcon</p><p>337</p><p>8</p><p>2180</p><p>536</p><p>76</p><p>4.79</p><p>376 InputPersonalization</p><p>409</p><p>12</p><p>4416</p><p>5464</p><p>79</p><p>4.26</p><p>5276 taskhost</p><p>C:\test\proc.txt:19: 346</p><p>13</p><p>39576</p><p>44540</p><p>207</p><p>3.15</p><p>280 powershell</p><p>125</p><p>5</p><p>2820</p><p>744</p><p>70</p><p>2.61</p><p>908 splwow64</p><p>347</p><p>13</p><p>12180</p><p>804</p><p>183</p><p>2.40</p><p>4788 PopUp_DM</p><p>335</p><p>10</p><p>2576</p><p>1756</p><p>83</p><p>2.20</p><p>4636 AdobeARM</p><p>249</p><p>21</p><p>6628</p><p>540</p><p>129</p><p>1.44</p><p>5220 SRSPremiumPanel</p><p>387</p><p>11</p><p>3436</p><p>12280</p><p>83</p><p>0.94</p><p>3828 WSHost</p><p>Not the greatest of displays but you do get to see the data. It should be possible to do this through PowerShell"™s formatting system but that"™s a post for another day.</p><p>Bottom line &ldquo;“ the context parameter only displays unique lines so you won&rdquo;™t necessarily get what you expect if there are multiple matches in a file.</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2788/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2788/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2788&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>Windows PowerShell V3 Language Specification Posted</title><link>https://powershell.org/articles/2013-01-11-windows-powershell-v3-language-specification-posted/</link><guid>https://powershell.org/articles/2013-01-11-windows-powershell-v3-language-specification-posted/</guid><pubDate>Fri, 11 Jan 2013 15:52:14 +0000</pubDate><description>&lt;p&gt;You can download it &lt;a href="http://www.microsoft.com/en-us/download/details.aspx?id=36389"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feeds.wordpress.com/1.0/gocomments/rkeithhill.wordpress.com/275/"&gt;&lt;img src="http://feeds.wordpress.com/1.0/comments/rkeithhill.wordpress.com/275/" alt=""&gt;&lt;/a&gt;&lt;img src="http://stats.wordpress.com/b.gif?host=rkeithhill.wordpress.com&amp;amp;blog=18780344&amp;amp;%23038;post=275&amp;amp;%23038;subd=rkeithhill&amp;amp;%23038;ref=&amp;amp;%23038;feed=1" alt=""&gt;&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>You can download it<a href="http://www.microsoft.com/en-us/download/details.aspx?id=36389">here</a>.</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/rkeithhill.wordpress.com/275/"><img src="http://feeds.wordpress.com/1.0/comments/rkeithhill.wordpress.com/275/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=rkeithhill.wordpress.com&amp;blog=18780344&amp;%23038;post=275&amp;%23038;subd=rkeithhill&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>Writing 10961A: The Damn Variables</title><link>https://powershell.org/articles/2013-01-10-writing-10961a-the-damn-variables/</link><guid>https://powershell.org/articles/2013-01-10-writing-10961a-the-damn-variables/</guid><pubDate>Thu, 10 Jan 2013 17:51:07 +0000</pubDate><description>&lt;p&gt;When I wrote Microsoft course 10325A, their original 5-day Windows PowerShell course, I saved variables until Module 11. My thought at the time was to focus on teaching just what students needed for what they were about to do - and no more. &amp;ldquo;Just in time learning&amp;rdquo; can be effective, because it lets you immediately experiment with whatever you&amp;rsquo;ve just learned, and helps minimize the need to store up concepts for later use. I&amp;rsquo;d also had a lot of class experiences where bringing up variables too soon engaged a defensive mechanism in some students: &amp;ldquo;I&amp;rsquo;m not a programmer, variables are programming, and I&amp;rsquo;m shutting down right now.&amp;rdquo;&lt;br&gt;
The biggest piece of MCT feedback from 10325A was, &amp;ldquo;don&amp;rsquo;t do that.&amp;rdquo; Trainers told me they were often teaching module 11 much sooner. Jeff Hicks had what I think is the best explanation for why: Without variables, you&amp;rsquo;re locked into the one-liner approach in PowerShell. While one-liners are &lt;em&gt;neat,&lt;/em&gt; and effective, they aren&amp;rsquo;t always easy to read or to mentally de-construct. Using variables earlier in the course, Jeff argued, let you break things down into smaller logical chunks.&lt;br&gt;
Now, one thing I&amp;rsquo;ve had to accept in writing 10961A is that I can&amp;rsquo;t please everyone. The feedback on 10325A is incredibly contradictory. Some MCTs want more programming, others want none at all. Some want classes to run 9am-4pm; others want 8am-6pm. Some want less content on the slides (actually, most wanted that). So what I decided to do is try and provide the material to accommodate what it felt like everyone was asking for, and rely on MCT&amp;rsquo;s ability to mix things up as needed for their classes.&lt;br&gt;
(As an aside, I do think some MCTs jump into the &amp;ldquo;programming&amp;rdquo; aspect of PowerShell too quickly. It&amp;rsquo;s fine if you&amp;rsquo;ve got a room of people with programming experience, but it keeps students from learning some valuable fundamentals and turns the class into a &amp;ldquo;scripting&amp;rdquo; class awfully quickly. I&amp;rsquo;m not sure every MCT has done a really thorough cognitive analysis of their class results to determine if the programming-first approach is best; my experience with &lt;em&gt;Month of Lunches&lt;/em&gt; readers suggest it isn&amp;rsquo;t.)&lt;br&gt;
But I still didn&amp;rsquo;t want to do the full deep-dive on variables super-early in the course. So here&amp;rsquo;s what I think I&amp;rsquo;m doing: early in the course, you&amp;rsquo;ll be exposed to variables, in a very simplistic sense. They&amp;rsquo;re described as a named place to store objects, and used to de-construct a complex one-liner into a multi-line series of logical steps. Early in the course, I don&amp;rsquo;t go into naming rules, the double quotes tricks, or anything else. You learn exactly enough about variables for the task at hand - and no more.&lt;br&gt;
In module 7, which is right before the module where you turn a command-line into a parameterized script, I cover variables more formally. I cover their rules, usage, double quotes, all that stuff. So you learn a wee bit about variables early, and then learn the full details later - &lt;em&gt;just&lt;/em&gt; before you need to use variables more seriously in a script. So, keeping with the just-in-time learning.&lt;br&gt;
The variables material is broken out into its own lesson in module 7, so an MCT hell-bent on teaching everything about variables right up-front can do so.While the feedback from 10325A suggests that MCTs think every course should be designed for the way &lt;em&gt;they&lt;/em&gt; teach, I&amp;rsquo;m not sure they all realize how &lt;em&gt;differently&lt;/em&gt; they all teach. The best I can do is provide the material in standalone chunks that MCTs can rearrange as needed. After all, the whole point of having a live instructor, as opposed to a recording, is the instructor&amp;rsquo;s ability to teach to your specific needs. So MCTs will have to be happy rearranging the material a bit as-needed; my outline is the &lt;em&gt;recommnded&lt;/em&gt; approach that will work best across the broadest array of students, but it isn&amp;rsquo;t perfect for &lt;em&gt;everyone.&lt;/em&gt; Nothing could be.&lt;br&gt;
As a point of reference, 10961A doesn&amp;rsquo;t dive into scripting as deeply as 10325A did. PowerShell 3.0 has enough new, extra stuff that a 5-day course doesn&amp;rsquo;t allow for deep programming topics. You do take a command and walk it through to being a script module, so you &lt;em&gt;see&lt;/em&gt; the range of scripting options, but you don&amp;rsquo;t &lt;em&gt;practice&lt;/em&gt; them in depth. It&amp;rsquo;s inch-deep, mile-wide coverage of scripting, as opposed to something deeper and more focused. I&amp;rsquo;m hoping Microsoft can find budget for a full-on &amp;ldquo;scripting/toolmaking&amp;rdquo; class in the future, but 10961A ain&amp;rsquo;t it.&lt;br&gt;
So&amp;hellip; what do you think of this approach?&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>When I wrote Microsoft course 10325A, their original 5-day Windows PowerShell course, I saved variables until Module 11. My thought at the time was to focus on teaching just what students needed for what they were about to do - and no more. &ldquo;Just in time learning&rdquo; can be effective, because it lets you immediately experiment with whatever you&rsquo;ve just learned, and helps minimize the need to store up concepts for later use. I&rsquo;d also had a lot of class experiences where bringing up variables too soon engaged a defensive mechanism in some students: &ldquo;I&rsquo;m not a programmer, variables are programming, and I&rsquo;m shutting down right now.&rdquo;<br>
The biggest piece of MCT feedback from 10325A was, &ldquo;don&rsquo;t do that.&rdquo; Trainers told me they were often teaching module 11 much sooner. Jeff Hicks had what I think is the best explanation for why: Without variables, you&rsquo;re locked into the one-liner approach in PowerShell. While one-liners are<em>neat,</em> and effective, they aren&rsquo;t always easy to read or to mentally de-construct. Using variables earlier in the course, Jeff argued, let you break things down into smaller logical chunks.<br>
Now, one thing I&rsquo;ve had to accept in writing 10961A is that I can&rsquo;t please everyone. The feedback on 10325A is incredibly contradictory. Some MCTs want more programming, others want none at all. Some want classes to run 9am-4pm; others want 8am-6pm. Some want less content on the slides (actually, most wanted that). So what I decided to do is try and provide the material to accommodate what it felt like everyone was asking for, and rely on MCT&rsquo;s ability to mix things up as needed for their classes.<br>
(As an aside, I do think some MCTs jump into the &ldquo;programming&rdquo; aspect of PowerShell too quickly. It&rsquo;s fine if you&rsquo;ve got a room of people with programming experience, but it keeps students from learning some valuable fundamentals and turns the class into a &ldquo;scripting&rdquo; class awfully quickly. I&rsquo;m not sure every MCT has done a really thorough cognitive analysis of their class results to determine if the programming-first approach is best; my experience with<em>Month of Lunches</em> readers suggest it isn&rsquo;t.)<br>
But I still didn&rsquo;t want to do the full deep-dive on variables super-early in the course. So here&rsquo;s what I think I&rsquo;m doing: early in the course, you&rsquo;ll be exposed to variables, in a very simplistic sense. They&rsquo;re described as a named place to store objects, and used to de-construct a complex one-liner into a multi-line series of logical steps. Early in the course, I don&rsquo;t go into naming rules, the double quotes tricks, or anything else. You learn exactly enough about variables for the task at hand - and no more.<br>
In module 7, which is right before the module where you turn a command-line into a parameterized script, I cover variables more formally. I cover their rules, usage, double quotes, all that stuff. So you learn a wee bit about variables early, and then learn the full details later -<em>just</em> before you need to use variables more seriously in a script. So, keeping with the just-in-time learning.<br>
The variables material is broken out into its own lesson in module 7, so an MCT hell-bent on teaching everything about variables right up-front can do so.While the feedback from 10325A suggests that MCTs think every course should be designed for the way<em>they</em> teach, I&rsquo;m not sure they all realize how<em>differently</em> they all teach. The best I can do is provide the material in standalone chunks that MCTs can rearrange as needed. After all, the whole point of having a live instructor, as opposed to a recording, is the instructor&rsquo;s ability to teach to your specific needs. So MCTs will have to be happy rearranging the material a bit as-needed; my outline is the<em>recommnded</em> approach that will work best across the broadest array of students, but it isn&rsquo;t perfect for<em>everyone.</em> Nothing could be.<br>
As a point of reference, 10961A doesn&rsquo;t dive into scripting as deeply as 10325A did. PowerShell 3.0 has enough new, extra stuff that a 5-day course doesn&rsquo;t allow for deep programming topics. You do take a command and walk it through to being a script module, so you<em>see</em> the range of scripting options, but you don&rsquo;t<em>practice</em> them in depth. It&rsquo;s inch-deep, mile-wide coverage of scripting, as opposed to something deeper and more focused. I&rsquo;m hoping Microsoft can find budget for a full-on &ldquo;scripting/toolmaking&rdquo; class in the future, but 10961A ain&rsquo;t it.<br>
So&hellip; what do you think of this approach?</p>
]]></content:encoded></item><item><title>Select-String "“ finding the first and last matches</title><link>https://powershell.org/articles/2013-01-09-select-string-finding-the-first-and-last-matches/</link><guid>https://powershell.org/articles/2013-01-09-select-string-finding-the-first-and-last-matches/</guid><pubDate>Wed, 09 Jan 2013 17:55:40 +0000</pubDate><description>&lt;p&gt;Today&amp;rsquo;s question concerns finding the first and last matches in a file&lt;/p&gt;
&lt;p&gt;Sometimes, I need to make two passes at seeking content in this file, once for the first occurrence; and a second grep for obtaining the last occurrence of a phrase. After the second pass, I figure placing the values into an array is the best way, then need to combine first and last values onto one output line {somewhere else}.&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>Today&rsquo;s question concerns finding the first and last matches in a file</p><p>Sometimes, I need to make two passes at seeking content in this file, once for the first occurrence; and a second grep for obtaining the last occurrence of a phrase. After the second pass, I figure placing the values into an array is the best way, then need to combine first and last values onto one output line {somewhere else}.</p><p>Let&rsquo;s consider the file we used in the first article in the series –<a href="http://msmvps.com/blogs/richardsiddaway/archive/2013/01/07/select-string-scenarios-fixed-columns.aspx">http://msmvps.com/blogs/richardsiddaway/archive/2013/01/07/select-string-scenarios-fixed-columns.aspx</a></p><p>The file looks like this</p><p>12345ABCD123451234512345<br>
1234512345ABCD1234512345<br>
12345ABCD123451234512345<br>
12345abcd123451234512345<br>
123451234512345ABCD12345<br>
12345ABCD123451234512345<br>
123451234512345ABCD12345<br>
12345123451234512345ABCD<br>
1234512345ABCD1234512345</p><p>If you this select-string</p><p>Select-String -Path c:\test*.txt -Pattern &ldquo;\A\w{5}ABCD</p><p>you will get multiple matches</p><p>C:\test\fixedcol.txt:1:12345ABCD123451234512345<br>
C:\test\fixedcol.txt:3:12345ABCD123451234512345<br>
C:\test\fixedcol.txt:4:12345abcd123451234512345<br>
C:\test\fixedcol.txt:6:12345ABCD123451234512345</p><p>So, how can we find the first and last matches – preferably in one pass.</p><p>I think the easiest way is to use the trick from the last article</p><p>$finds = Select-String -Path c:\test*.txt -Pattern &ldquo;\A\w{5}ABCD&rdquo;</p><p>$finds[0]$finds[-1]</p><p>The $finds variable conatins a collection of the MatchInfo objects created by Select-String. The first match will always have the index of 0 and the last can always be referenecd by an index of -1. This information is returned:</p><p>C:\test\fixedcol.txt:1:12345ABCD123451234512345<br>
C:\test\fixedcol.txt:6:12345ABCD123451234512345</p><p>If you want this in an object for further processing – try something like this</p><p>Get-ChildItem -Path c:\test -Filter *.txt -Recurse |<br>
foreach {</p><p>$finds = $null<br>
$finds = Select-String -Path $_.Fullname -Pattern &ldquo;\A\w{5}ABCD&rdquo;</p><p>if ($finds){</p><p>$props = [ordered]@{<br>
Filename = $finds[0].Path<br>
FirstLine = $finds[0].LineNumber<br>
FirstData = $finds[0].Line<br>
LastLine = $finds[-1].LineNumber<br>
LastData = $finds[-1].Line<br>
}<br>
New-Object -TypeName PSObject -Property $props<br>
}<br>
}</p><p>Use Get-ChildItem to find the files. For each of them run Select-String with your pattern. If you get any matches create an object holding the file path and your required properties. In this case I&rsquo;m taking the first and last line numbers with the match data.</p><p>If you only have a single match in a file you will get the same data in the First* and Last* properties as the first and last match are the same. You could put another if statement to control this so the Last* properties aren&rsquo;t populated if you want.</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2787/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2787/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2787&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>Workflow article 3</title><link>https://powershell.org/articles/2013-01-09-workflow-article-3/</link><guid>https://powershell.org/articles/2013-01-09-workflow-article-3/</guid><pubDate>Wed, 09 Jan 2013 17:19:28 +0000</pubDate><description>&lt;p&gt;The next in the series of articles on PowerShell workflows that are appearing on the Scripting Guy blog has been published.&lt;/p&gt;
&lt;p&gt;The articles in the series that have been published are:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx"&gt;http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx&lt;/a&gt;&lt;br&gt;
&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx"&gt;http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx&lt;/a&gt;&lt;br&gt;
&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/09/powershell-workflows-nesting.aspx"&gt;http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/09/powershell-workflows-nesting.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Look for the next article in one weeks time.&lt;/p&gt;
&lt;p&gt;Until then Enjoy!&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2786/"&gt;&lt;img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2786/" alt=""&gt;&lt;/a&gt;&lt;img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;amp;blog=16267735&amp;amp;%23038;post=2786&amp;amp;%23038;subd=richardspowershellblog&amp;amp;%23038;ref=&amp;amp;%23038;feed=1" alt=""&gt;&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>The next in the series of articles on PowerShell workflows that are appearing on the Scripting Guy blog has been published.</p><p>The articles in the series that have been published are:</p><p><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx">http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx</a><br><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx">http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx</a><br><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/09/powershell-workflows-nesting.aspx">http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/09/powershell-workflows-nesting.aspx</a></p><p>Look for the next article in one weeks time.</p><p>Until then Enjoy!</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2786/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2786/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2786&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>Select-String"“information on matching files</title><link>https://powershell.org/articles/2013-01-08-select-string-information-on-matching-files/</link><guid>https://powershell.org/articles/2013-01-08-select-string-information-on-matching-files/</guid><pubDate>Tue, 08 Jan 2013 21:31:36 +0000</pubDate><description>&lt;p&gt;Following on from yesterday&amp;quot;™s post this is the second question:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Since I&amp;rsquo;m recursively searching thru files to find matching phrases, how can I obtain other directory service information about the matching files file(s) – this is more of a methodology technique question because I realize there are multiple ways of achieving this?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;You could do something like this&lt;/p&gt;
&lt;p&gt;foreach ($find in Select-String -Path c:\test*.txt -Pattern &amp;ldquo;\A\w{5}ABCD&amp;rdquo; -List){&lt;br&gt;
Get-ChildItem -Path $find.Path&lt;br&gt;
}&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>Following on from yesterday"™s post this is the second question:</p><p><em>Since I&rsquo;m recursively searching thru files to find matching phrases, how can I obtain other directory service information about the matching files file(s) – this is more of a methodology technique question because I realize there are multiple ways of achieving this?</em></p><p>You could do something like this</p><p>foreach ($find in Select-String -Path c:\test*.txt -Pattern &ldquo;\A\w{5}ABCD&rdquo; -List){<br>
Get-ChildItem -Path $find.Path<br>
}</p><p>Run the Select-String as before but only get the first match in each file. Use foreach to access the match information and use the Path property to feed into Get-ChildItem.</p><p>If you want things to be a bit simpler &ldquo;“ break it down to:</p><p>$finds = Select-String -Path c:\test*.txt -Pattern &ldquo;\A\w{5}ABCD&rdquo; -List<br>
foreach ($find in $finds){<br>
Get-ChildItem -Path $find.Path<br>
}</p><p>Alternatively if you want the PowerShell one-liner approach try</p><p>Get-ChildItem -Path (Select-String -Path c:\test*.txt -Pattern &ldquo;\A\w{5}ABCD&rdquo; -List).Path</p><p>Personally I would probably go for the simple approach</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2785/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2785/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2785&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>3 Updated Free PowerShell eBooks in January 2013!</title><link>https://powershell.org/articles/2013-01-08-3-updated-free-powershell-ebooks-in-january-2013/</link><guid>https://powershell.org/articles/2013-01-08-3-updated-free-powershell-ebooks-in-january-2013/</guid><pubDate>Tue, 08 Jan 2013 17:06:34 +0000</pubDate><description>&lt;p&gt;I&amp;rsquo;ve been working to update my three free PowerShell ebooks for this month:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Secrets of PowerShell Remoting&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Creating HTML Reports in PowerShell&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Making Historical and Trend Reports in PowerShell&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The updated versions will be made available to subscribers of the PowerShell.org TechLetter on January 15th. If you&amp;rsquo;re not already signed up to receive this, you can [sign up right now][1]. The January issue will also feature a walkthrough article of how I started creating a new, better ConvertTo-HTML command, which gets used in the ebook on HTML reporting. Going forward, I&amp;rsquo;ll be making updated ebooks available primarily through the TechLetter.&lt;br&gt;
If you&amp;rsquo;re not a subscriber and don&amp;rsquo;t want to be, well fine. I&amp;rsquo;ll just take my ball and go play in someone else&amp;rsquo;s sandbox. Kidding . I&amp;rsquo;ll post the updates at the end of January. However, right now access to the books still requires a subscription to the newsletter, although you can immediately unsubscribe if you want to. I had to put that &amp;ldquo;hurdle&amp;rdquo; in the way because we were losing a ton of bandwidth to people direct-linking the download files. Mostly from China, for some reason. You&amp;rsquo;re welcome to host the files on your own server, if you want to (they&amp;rsquo;re licensed for that), but bandwidth costs me money, so I&amp;rsquo;m trying to conserve a bit.&lt;br&gt;
Anyway, keep an eye out for the TechLetter in your inbox on Jan 15th. Check those spam filters, and make sure &lt;a href="mailto:newsletter@powershell.org"&gt;newsletter@powershell.org&lt;/a&gt; is in your address book, so that your mail server will know it&amp;rsquo;s a legitimate sender.&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>I&rsquo;ve been working to update my three free PowerShell ebooks for this month:</p><ul><li><em>Secrets of PowerShell Remoting</em></li><li><em>Creating HTML Reports in PowerShell</em></li><li><em>Making Historical and Trend Reports in PowerShell</em></li></ul><p>The updated versions will be made available to subscribers of the PowerShell.org TechLetter on January 15th. If you&rsquo;re not already signed up to receive this, you can [sign up right now][1]. The January issue will also feature a walkthrough article of how I started creating a new, better ConvertTo-HTML command, which gets used in the ebook on HTML reporting. Going forward, I&rsquo;ll be making updated ebooks available primarily through the TechLetter.<br>
If you&rsquo;re not a subscriber and don&rsquo;t want to be, well fine. I&rsquo;ll just take my ball and go play in someone else&rsquo;s sandbox. Kidding . I&rsquo;ll post the updates at the end of January. However, right now access to the books still requires a subscription to the newsletter, although you can immediately unsubscribe if you want to. I had to put that &ldquo;hurdle&rdquo; in the way because we were losing a ton of bandwidth to people direct-linking the download files. Mostly from China, for some reason. You&rsquo;re welcome to host the files on your own server, if you want to (they&rsquo;re licensed for that), but bandwidth costs me money, so I&rsquo;m trying to conserve a bit.<br>
Anyway, keep an eye out for the TechLetter in your inbox on Jan 15th. Check those spam filters, and make sure<a href="mailto:newsletter@powershell.org">newsletter@powershell.org</a> is in your address book, so that your mail server will know it&rsquo;s a legitimate sender.</p><p>[1]:<a href="https://powershell.org/newsletter">https://powershell.org/newsletter</a> &ldquo;Select-String scenarios &ldquo;“ fixed columns&rdquo;</p>
]]></content:encoded></item><item><title>Select-String scenarios "“ fixed columns</title><link>https://powershell.org/articles/2013-01-07-select-string-scenarios-fixed-columns/</link><guid>https://powershell.org/articles/2013-01-07-select-string-scenarios-fixed-columns/</guid><pubDate>Mon, 07 Jan 2013 22:43:53 +0000</pubDate><description>&lt;p&gt;I had some questions come in after mu recent post regarding select-string. I&amp;quot;™ll answer them as a series of posts. First off:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;I&amp;rsquo;m recursively searching thru many files, and want to pull out specific data in &amp;lsquo;fixed column&amp;rsquo; positions from the line(s) that match the phrase I&amp;rsquo;m seeking, i.e. position 10 thru 15 of the line or position 6 thru the end of the line (which might be unknown).&lt;br&gt;
What is your preferred method for handling this situation?&lt;/em&gt;&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>I had some questions come in after mu recent post regarding select-string. I"™ll answer them as a series of posts. First off:</p><p><em>I&rsquo;m recursively searching thru many files, and want to pull out specific data in &lsquo;fixed column&rsquo; positions from the line(s) that match the phrase I&rsquo;m seeking, i.e. position 10 thru 15 of the line or position 6 thru the end of the line (which might be unknown).<br>
What is your preferred method for handling this situation?</em></p><p>I started by creating a file</p><p>12345ABCD123451234512345<br>
1234512345ABCD1234512345<br>
12345ABCD123451234512345<br>
12345abcd123451234512345<br>
123451234512345ABCD12345<br>
12345ABCD123451234512345<br>
123451234512345ABCD12345<br>
12345123451234512345ABCD<br>
1234512345ABCD1234512345</p><p>I want to pick out the string ABCD but ONLY when its in columns6-9. A quick inspection shows I should get four lines returned.</p><p>If you go with a simple match you get all lines returned</p><p>PS&gt; Select-String -Path c:\test*.txt -Pattern &ldquo;ABCD&rdquo; -SimpleMatch</p><p>C:\test\fxedcol.txt:1:12345ABCD123451234512345<br>
C:\test\fxedcol.txt:2:1234512345ABCD1234512345<br>
C:\test\fxedcol.txt:3:12345ABCD123451234512345<br>
C:\test\fxedcol.txt:4:12345abcd123451234512345<br>
C:\test\fxedcol.txt:5:123451234512345ABCD12345<br>
C:\test\fxedcol.txt:6:12345ABCD123451234512345<br>
C:\test\fxedcol.txt:7:123451234512345ABCD12345<br>
C:\test\fxedcol.txt:8:12345123451234512345ABCD<br>
C:\test\fxedcol.txt:9:1234512345ABCD1234512345</p><p>Notice the match is case INSENSITIVE</p><p>This means we get into the world of regular expressions &ldquo;“ joy!</p><p>This will work</p><p>Select-String -Path c:\test*.txt -Pattern &ldquo;\A.{5}ABCD&rdquo;</p><p>The regular expression means match any 5 characters followed by ABCD starting at the beginning of the string.</p><p>Alternatively you could use</p><p>Select-String -Path c:\test*.txt -Pattern &ldquo;\A\w{5}ABCD&rdquo;</p><p>This is the same except its accepting any word character (letter, digit, math symbol and punctuation)</p><p>These two searches are case INSENSITIVE</p><p>if you need case sensitivity then compare</p><p>Select-String -Path c:\test*.txt -Pattern &ldquo;\A\w{5}ABCD&rdquo; -CaseSensitive<br>
Select-String -Path c:\test*.txt -Pattern &ldquo;\A\w{5}abcd&rdquo; -CaseSensitive</p><p>or</p><p>Select-String -Path c:\test*.txt -Pattern &ldquo;\A.{5}ABCD&rdquo; -CaseSensitive<br>
Select-String -Path c:\test*.txt -Pattern &ldquo;\A.{5}abcd&rdquo; -CaseSensitive</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2784/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2784/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2784&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>PhillyPoSH 01/03/2013 meeting summary and presentation materials</title><link>https://powershell.org/articles/2013-01-07-phillyposh-01032013-meeting-summary-and-presentation-materials/</link><guid>https://powershell.org/articles/2013-01-07-phillyposh-01032013-meeting-summary-and-presentation-materials/</guid><pubDate>Mon, 07 Jan 2013 18:23:39 +0000</pubDate><description>&lt;ol&gt;
&lt;li&gt;User group member &lt;a href="http://tiki.gmartin.org/" title="Greg's blog"&gt;Greg Martin&lt;/a&gt; gave a presentation on Active Directory and PowerShell. A copy of his presentation can be found &lt;a href="https://powershell.org/wp-content/uploads/2013/01/PhillyPosh_2013-01-03_Presentations.zip"&gt;here&lt;/a&gt; and included the following topics:
&lt;ol&gt;
&lt;li&gt;Building a copy of your production AD domain&lt;/li&gt;
&lt;li&gt;Notifying users of expiring passwords&lt;/li&gt;
&lt;li&gt;Dealing with expired computer accounts&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;User group member &lt;a href="http://tekout.wordpress.com/"&gt;Sunny Chakraborty&lt;/a&gt; gave a presentation on how to use the techniques of Prof &lt;a href="http://en.wikipedia.org/wiki/George_P%C3%B3lya"&gt;George Poyla&lt;/a&gt; and Chess Grandmasters in order to improve your scripting skills. A copy of his presentation materials can be found &lt;a href="https://powershell.org/wp-content/uploads/2013/01/PhillyPosh_2013-01-03_Presentations.zip"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Various other information worth mentioning
&lt;ol&gt;
&lt;li&gt;User group member &lt;a href="http://tekout.wordpress.com/"&gt;Sunny Chakraborty&lt;/a&gt; submitted a list of PowerShell commands to retrieve Dell specific WMI objects. A copy of that list can be found &lt;a href="https://powershell.org/wp-content/uploads/2013/01/PhillyPosh_2013-01-03_Extras.zip"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Another group member (Name forthcoming!) submitted a list of PowerShell commands to retrieve HP Insight manager WMI Objects. A copy of that list can be found &lt;a href="https://powershell.org/wp-content/uploads/2013/01/PhillyPosh_2013-01-03_Extras.zip"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blogs.msdn.com/b/powershell/archive/2012/12/20/windows-management-framework-3-0-compatibility-update.aspx"&gt;Do not install Windows Management Framework 3.0 (PowerShell 3.0) on the following systems&lt;/a&gt;, if you have please uninstall it so that you do not run into any issues with subsequent patches.
&lt;ol&gt;
&lt;li&gt;System Center 2012 Configuration Manager running on any Windows Server 2008 or 2008 R2 version&lt;/li&gt;
&lt;li&gt;System Center Virtual Machine Manager running on any Windows Server 2008 or 2008 R2 version&lt;/li&gt;
&lt;li&gt;Microsoft Exchange 2007 or 2010 running on any Windows Server 2008 or 2008 R2 version&lt;/li&gt;
&lt;li&gt;Microsoft SharePoint 2010 running on any Windows Server 2008 or 2008 R2 version&lt;/li&gt;
&lt;li&gt;Windows Small Business Server 2008 or 2011&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;On Twitter? Follow the &lt;a href="https://twitter.com/search?q=%23Powershell&amp;amp;src=typd"&gt;#PowerShell&lt;/a&gt; hashtag or check our &lt;a href="http://paglia.org/"&gt;Lido Paglia&amp;quot;™s&lt;/a&gt; &lt;a href="https://twitter.com/nicemarmot/powershellers"&gt;Powershell Twitter List&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;On Google+? Join the &lt;a href="https://plus.google.com/u/0/communities/114336958783305019912"&gt;PowerShell community&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Still haven&amp;quot;™t purchased a copy of &lt;a href="http://www.manning.com/jones3/"&gt;Learn PowerShell in a Month of Lunches&lt;/a&gt; or any other PowerShell book on &lt;a href="http://www.manning.com/"&gt;Manning Publications&lt;/a&gt;? Signup for their &lt;a href="http://www.manning.com/free/dotd.html"&gt;deal of the day&lt;/a&gt; newsletter or check the front page every day to see when it&amp;quot;™s on sale!&lt;/li&gt;
&lt;li&gt;If you&amp;quot;™re looking for .NET assembly browser and decomplier, take a look at &lt;a href="http://tekout.wordpress.com/"&gt;Sunny Chakraborty&amp;quot;™s&lt;/a&gt; favorite utility: &lt;a href="http://ilspy.net/"&gt;ILSpy&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Attachments:&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<ol><li>User group member <a href="http://tiki.gmartin.org/" title="Greg's blog">Greg Martin</a> gave a presentation on Active Directory and PowerShell. A copy of his presentation can be found<a href="https://powershell.org/wp-content/uploads/2013/01/PhillyPosh_2013-01-03_Presentations.zip">here</a> and included the following topics:<ol><li>Building a copy of your production AD domain</li><li>Notifying users of expiring passwords</li><li>Dealing with expired computer accounts</li></ol></li><li>User group member<a href="http://tekout.wordpress.com/">Sunny Chakraborty</a> gave a presentation on how to use the techniques of Prof<a href="http://en.wikipedia.org/wiki/George_P%C3%B3lya">George Poyla</a> and Chess Grandmasters in order to improve your scripting skills. A copy of his presentation materials can be found<a href="https://powershell.org/wp-content/uploads/2013/01/PhillyPosh_2013-01-03_Presentations.zip">here</a>.</li><li>Various other information worth mentioning<ol><li>User group member<a href="http://tekout.wordpress.com/">Sunny Chakraborty</a> submitted a list of PowerShell commands to retrieve Dell specific WMI objects. A copy of that list can be found<a href="https://powershell.org/wp-content/uploads/2013/01/PhillyPosh_2013-01-03_Extras.zip">here</a>.</li><li>Another group member (Name forthcoming!) submitted a list of PowerShell commands to retrieve HP Insight manager WMI Objects. A copy of that list can be found<a href="https://powershell.org/wp-content/uploads/2013/01/PhillyPosh_2013-01-03_Extras.zip">here</a>.</li><li><a href="http://blogs.msdn.com/b/powershell/archive/2012/12/20/windows-management-framework-3-0-compatibility-update.aspx">Do not install Windows Management Framework 3.0 (PowerShell 3.0) on the following systems</a>, if you have please uninstall it so that you do not run into any issues with subsequent patches.<ol><li>System Center 2012 Configuration Manager running on any Windows Server 2008 or 2008 R2 version</li><li>System Center Virtual Machine Manager running on any Windows Server 2008 or 2008 R2 version</li><li>Microsoft Exchange 2007 or 2010 running on any Windows Server 2008 or 2008 R2 version</li><li>Microsoft SharePoint 2010 running on any Windows Server 2008 or 2008 R2 version</li><li>Windows Small Business Server 2008 or 2011</li></ol></li><li>On Twitter? Follow the<a href="https://twitter.com/search?q=%23Powershell&amp;src=typd">#PowerShell</a> hashtag or check our<a href="http://paglia.org/">Lido Paglia"™s</a><a href="https://twitter.com/nicemarmot/powershellers">Powershell Twitter List</a>.</li><li>On Google+? Join the<a href="https://plus.google.com/u/0/communities/114336958783305019912">PowerShell community</a>.</li><li>Still haven"™t purchased a copy of<a href="http://www.manning.com/jones3/">Learn PowerShell in a Month of Lunches</a> or any other PowerShell book on<a href="http://www.manning.com/">Manning Publications</a>? Signup for their<a href="http://www.manning.com/free/dotd.html">deal of the day</a> newsletter or check the front page every day to see when it"™s on sale!</li><li>If you"™re looking for .NET assembly browser and decomplier, take a look at<a href="http://tekout.wordpress.com/">Sunny Chakraborty"™s</a> favorite utility:<a href="http://ilspy.net/">ILSpy</a>.</li></ol></li></ol><p>Attachments:</p><ul><li><a href="https://powershell.org/wp-content/uploads/2013/01/PhillyPosh_2013-01-03_Presentations.zip">PhillyPosh_2013-01-03_Presentations</a></li><li><a href="https://powershell.org/wp-content/uploads/2013/01/PhillyPosh_2013-01-03_Extras.zip">PhillyPosh_2013-01-03_Extras</a></li></ul>
]]></content:encoded></item><item><title>Select-String confusion</title><link>https://powershell.org/articles/2013-01-05-select-string-confusion/</link><guid>https://powershell.org/articles/2013-01-05-select-string-confusion/</guid><pubDate>Sat, 05 Jan 2013 13:08:59 +0000</pubDate><description>&lt;p&gt;I have seen a lot of confusion recently over the use of Select-String.&lt;/p&gt;
&lt;p&gt;One mis-conception is that you need to use Get-Content to pipe the file contents into Select-String. Not so. Select-String will read the file for you.&lt;/p&gt;
&lt;p&gt;If you just want to scan the files in a single folder to find a specific string then Select-String can do the work for you&lt;/p&gt;
&lt;p&gt;Select-String -Path C:\Test*.txt -Pattern &amp;ldquo;trial&amp;rdquo; &amp;ldquo;“SimpleMatch&lt;/p&gt;
&lt;p&gt;If you need to work through a folder structure add get-ChildItem to the pipeline&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>I have seen a lot of confusion recently over the use of Select-String.</p><p>One mis-conception is that you need to use Get-Content to pipe the file contents into Select-String. Not so. Select-String will read the file for you.</p><p>If you just want to scan the files in a single folder to find a specific string then Select-String can do the work for you</p><p>Select-String -Path C:\Test*.txt -Pattern &ldquo;trial&rdquo; &ldquo;“SimpleMatch</p><p>If you need to work through a folder structure add get-ChildItem to the pipeline</p><p>Get-ChildItem -Path C:\Test -Filter *.txt -Recurse |<br>
Select-String -Pattern &ldquo;trial&rdquo; &ldquo;“SimpleMatch</p><p>One line of PowerShell gives you a very powerful way of filtering the files recursively and testing their contents for a given string</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2783/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2783/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2783&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>Number of processors in a box</title><link>https://powershell.org/articles/2013-01-05-number-of-processors-in-a-box/</link><guid>https://powershell.org/articles/2013-01-05-number-of-processors-in-a-box/</guid><pubDate>Sat, 05 Jan 2013 12:21:23 +0000</pubDate><description>&lt;p&gt;WMI enables you find the number of processors in your system:&lt;/p&gt;
&lt;p&gt;PS&amp;gt; Get-WmiObject -Class Win32_ComputerSystem | fl Number*&lt;/p&gt;
&lt;p&gt;NumberOfLogicalProcessors : 2&lt;br&gt;
NumberOfProcessors : 1&lt;/p&gt;
&lt;p&gt;This works fine for Windows Vista/Windows 2008 and above.&lt;/p&gt;
&lt;p&gt;Earlier versions of Windows mis-report the number of processors &amp;ldquo;“ it counts the number of logical processors reports it as the number of physical processors.&lt;/p&gt;
&lt;p&gt;Win32_Processor has the same problem on Windows 2003 and below.&lt;/p&gt;
&lt;p&gt;There is a hotfix available from &lt;a href="http://support.microsoft.com/kb/932370" title="http://support.microsoft.com/kb/932370"&gt;http://support.microsoft.com/kb/932370&lt;/a&gt; that will correct the behaviour of these two WMI classes so that they report correctly&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>WMI enables you find the number of processors in your system:</p><p>PS&gt; Get-WmiObject -Class Win32_ComputerSystem | fl Number*</p><p>NumberOfLogicalProcessors : 2<br>
NumberOfProcessors : 1</p><p>This works fine for Windows Vista/Windows 2008 and above.</p><p>Earlier versions of Windows mis-report the number of processors &ldquo;“ it counts the number of logical processors reports it as the number of physical processors.</p><p>Win32_Processor has the same problem on Windows 2003 and below.</p><p>There is a hotfix available from<a href="http://support.microsoft.com/kb/932370" title="http://support.microsoft.com/kb/932370">http://support.microsoft.com/kb/932370</a> that will correct the behaviour of these two WMI classes so that they report correctly</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2782/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2782/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2782&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>Finding the domain controller that authenticated you</title><link>https://powershell.org/articles/2013-01-04-finding-the-domain-controller-that-authenticated-you/</link><guid>https://powershell.org/articles/2013-01-04-finding-the-domain-controller-that-authenticated-you/</guid><pubDate>Fri, 04 Jan 2013 17:57:56 +0000</pubDate><description>&lt;p&gt;A question on my blog asked how do you know which domain controller you are running against when you search Active Directory. Unless you explicitly instruct your script to use a specific domain controller it will use the one to which you authenticated.&lt;/p&gt;
&lt;p&gt;You can find the DC to which you authenticated with this simple function&lt;/p&gt;
&lt;p&gt;function get-logonserver{&lt;br&gt;
$env:LOGONSERVER -replace &amp;ldquo;\&amp;rdquo;, &amp;quot;&amp;quot;&lt;br&gt;
}&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2781/"&gt;&lt;img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2781/" alt=""&gt;&lt;/a&gt;&lt;img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;amp;blog=16267735&amp;amp;%23038;post=2781&amp;amp;%23038;subd=richardspowershellblog&amp;amp;%23038;ref=&amp;amp;%23038;feed=1" alt=""&gt;&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>A question on my blog asked how do you know which domain controller you are running against when you search Active Directory. Unless you explicitly instruct your script to use a specific domain controller it will use the one to which you authenticated.</p><p>You can find the DC to which you authenticated with this simple function</p><p>function get-logonserver{<br>
$env:LOGONSERVER -replace &ldquo;\&rdquo;, ""<br>
}</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2781/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2781/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2781&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>Writing 10961: Trademarks</title><link>https://powershell.org/articles/2013-01-04-writing-10961-trademarks/</link><guid>https://powershell.org/articles/2013-01-04-writing-10961-trademarks/</guid><pubDate>Fri, 04 Jan 2013 16:09:02 +0000</pubDate><description>&lt;p&gt;Microsoft&amp;rsquo;s a big company, and that makes it a big target for lawsuits. We all know that. But what doesn&amp;rsquo;t always sink in is how careful the company has to be.&lt;br&gt;
For example, in Microsoft Official Curriculum course 10961, Automating Administration with Windows PowerShell 3.0, I have to type &lt;em&gt;Windows PowerShell&lt;/em&gt; every single time. I&amp;rsquo;ve actually been using &amp;ldquo;the shell&amp;rdquo; a lot, just to break things up a bit. We all casually refer to the shell as &lt;em&gt;PowerShell,&lt;/em&gt; but Microsoft never does. Their trademark is on &lt;em&gt;Windows&lt;/em&gt; PowerShell, and believe it or not someone has a trademark on &lt;em&gt;PowerShell.&lt;/em&gt; I think it&amp;rsquo;s a sporting equipment manufacturer.&lt;br&gt;
As I&amp;rsquo;m writing the course, I started using &lt;em&gt;Windows PowerShell&lt;/em&gt; on first reference, and then naturally - for me, at least - used just &lt;em&gt;PowerShell&lt;/em&gt; from then on. Nope. Had to go fix &amp;rsquo;em all.&lt;br&gt;
Weird, huh?&lt;br&gt;
I mean, technically&amp;hellip; legally&amp;hellip; you don&amp;rsquo;t trademark an entire word. You trademark it for use in a particular field. So it&amp;rsquo;s theoretically possible for Microsoft to own the trademark &lt;em&gt;PowerShell&lt;/em&gt; in the world of computer software, and another company to own the same trademark for making backpacks or ski boots or whatever. But&amp;hellip; I get it. You gotta be careful, and it&amp;rsquo;s easier just to not overlap with someone else&amp;rsquo;s trademark.&lt;br&gt;
Maybe they should have named it FrabulouShellâ„¢ instead, just to be really sure.&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>Microsoft&rsquo;s a big company, and that makes it a big target for lawsuits. We all know that. But what doesn&rsquo;t always sink in is how careful the company has to be.<br>
For example, in Microsoft Official Curriculum course 10961, Automating Administration with Windows PowerShell 3.0, I have to type<em>Windows PowerShell</em> every single time. I&rsquo;ve actually been using &ldquo;the shell&rdquo; a lot, just to break things up a bit. We all casually refer to the shell as<em>PowerShell,</em> but Microsoft never does. Their trademark is on<em>Windows</em> PowerShell, and believe it or not someone has a trademark on<em>PowerShell.</em> I think it&rsquo;s a sporting equipment manufacturer.<br>
As I&rsquo;m writing the course, I started using<em>Windows PowerShell</em> on first reference, and then naturally - for me, at least - used just<em>PowerShell</em> from then on. Nope. Had to go fix &rsquo;em all.<br>
Weird, huh?<br>
I mean, technically&hellip; legally&hellip; you don&rsquo;t trademark an entire word. You trademark it for use in a particular field. So it&rsquo;s theoretically possible for Microsoft to own the trademark<em>PowerShell</em> in the world of computer software, and another company to own the same trademark for making backpacks or ski boots or whatever. But&hellip; I get it. You gotta be careful, and it&rsquo;s easier just to not overlap with someone else&rsquo;s trademark.<br>
Maybe they should have named it FrabulouShellâ„¢ instead, just to be really sure.</p>
]]></content:encoded></item><item><title>Displaying data from multiple servers as HTML</title><link>https://powershell.org/articles/2013-01-03-displaying-data-from-multiple-servers-as-html/</link><guid>https://powershell.org/articles/2013-01-03-displaying-data-from-multiple-servers-as-html/</guid><pubDate>Thu, 03 Jan 2013 19:12:53 +0000</pubDate><description>&lt;p&gt;A forum question regarding retrieving WMI based data from multiple servers and displaying it as HTML was interesting. I would approach it like this&lt;/p&gt;
&lt;p&gt;`$servers&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;Get-Content&lt;/p&gt;
&lt;p&gt;-Path&lt;/p&gt;
&lt;p&gt;C:\scripts\servers.txt&lt;/p&gt;
&lt;p&gt;$data&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;@(&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;foreach&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;$server&lt;/p&gt;
&lt;p&gt;in&lt;/p&gt;
&lt;p&gt;$servers&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;$compdata&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;New-Object&lt;/p&gt;
&lt;p&gt;-TypeName&lt;/p&gt;
&lt;p&gt;PSObject&lt;/p&gt;
&lt;p&gt;-Property&lt;/p&gt;
&lt;p&gt;@{&lt;/p&gt;
&lt;p&gt;Computer&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;$server&lt;/p&gt;
&lt;p&gt;Contactable&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;$false&lt;/p&gt;
&lt;p&gt;LastBootTime&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;&amp;quot;&amp;quot;&lt;/p&gt;
&lt;p&gt;AllowTSConnections&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;$false&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;if&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;Test-Connection&lt;/p&gt;
&lt;p&gt;-ComputerName&lt;/p&gt;
&lt;p&gt;$server&lt;/p&gt;
&lt;p&gt;-Quiet&lt;/p&gt;
&lt;p&gt;-Count&lt;/p&gt;
&lt;p&gt;1&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;$compdata&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;Contactable&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;$true&lt;/p&gt;
&lt;p&gt;$os&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;Get-WmiObject&lt;/p&gt;
&lt;p&gt;-Class&lt;/p&gt;
&lt;p&gt;Win32_OperatingSystem&lt;/p&gt;
&lt;p&gt;-ComputerName&lt;/p&gt;
&lt;p&gt;$server&lt;/p&gt;
&lt;p&gt;$compdata&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;LastBootTime&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;$os&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;ConvertToDateTime&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;$os&lt;/p&gt;
&lt;p&gt;.&lt;/p&gt;
&lt;p&gt;LastBootUpTime&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;$ts&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>A forum question regarding retrieving WMI based data from multiple servers and displaying it as HTML was interesting. I would approach it like this</p><p>`$servers</p><p>=</p><p>Get-Content</p><p>-Path</p><p>C:\scripts\servers.txt</p><p>$data</p><p>=</p><p>@(</p><p>)</p><p>foreach</p><p>(</p><p>$server</p><p>in</p><p>$servers</p><p>)</p><p>{</p><p>$compdata</p><p>=</p><p>New-Object</p><p>-TypeName</p><p>PSObject</p><p>-Property</p><p>@{</p><p>Computer</p><p>=</p><p>$server</p><p>Contactable</p><p>=</p><p>$false</p><p>LastBootTime</p><p>=</p><p>""</p><p>AllowTSConnections</p><p>=</p><p>$false</p><p>}</p><p>if</p><p>(</p><p>Test-Connection</p><p>-ComputerName</p><p>$server</p><p>-Quiet</p><p>-Count</p><p>1</p><p>)</p><p>{</p><p>$compdata</p><p>.</p><p>Contactable</p><p>=</p><p>$true</p><p>$os</p><p>=</p><p>Get-WmiObject</p><p>-Class</p><p>Win32_OperatingSystem</p><p>-ComputerName</p><p>$server</p><p>$compdata</p><p>.</p><p>LastBootTime</p><p>=</p><p>$os</p><p>.</p><p>ConvertToDateTime</p><p>(</p><p>$os</p><p>.</p><p>LastBootUpTime</p><p>)</p><p>$ts</p><p>=</p><p>Get-WmiObject</p><p>-Namespace</p><p>root\cimv2\terminalservices</p><p>-Class</p><p>Win32_TerminalServiceSetting</p><p>-ComputerName</p><p>$server</p><p>-Authentication</p><p>PacketPrivacy</p><p>if</p><p>(</p><p>$ts</p><p>.</p><p>AllowTSConnections</p><p>-eq</p><p>1</p><p>)</p><p>{</p><p>$compdata</p><p>.</p><p>AllowTSConnections</p><p>=</p><p>$true</p><p>}</p><p>}</p><p>$data</p><p>+=</p><p>$compdata</p><p>}</p><p>$data</p><p>$data</p><p>|</p><p>ConvertTo-Html</p><p>|</p><p>Out-File</p><p>-FilePath</p><p>c:\scripts\report.html</p><p>Invoke-Item</p><p>-Path</p><p>c:\scripts\report.html</p><p>`Put the list of servers in a text file &amp; read it in via get-content.</p><p>use foreach to iterate over the list of servers.</p><p>For each server create an object and then test if you can ping the server. Note that the default setting for Contactable is $false so don"™t need to deal with that case.</p><p>Get the WMI data and set the properties on the object.</p><p>Add the object to an array</p><p>After you"™ve hit all the servers use ConvertTo-Html and write to a file with out-file.</p><p>use Invoke-Item to view the report</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2780/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2780/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2780&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>Ensuring that parameter values are passed to your function</title><link>https://powershell.org/articles/2013-01-03-ensuring-that-parameter-values-are-passed-to-your-function/</link><guid>https://powershell.org/articles/2013-01-03-ensuring-that-parameter-values-are-passed-to-your-function/</guid><pubDate>Thu, 03 Jan 2013 18:46:59 +0000</pubDate><description>&lt;p&gt;A question on the forum about a function had me thinking. The user had defined two parameters for the function and then used Read-Host to get the values.&lt;/p&gt;
&lt;p&gt;NO&lt;/p&gt;
&lt;p&gt;Much better way is to use an advanced function and make the parameters mandatory&lt;/p&gt;
&lt;p&gt;`function&lt;/p&gt;
&lt;p&gt;Getuserdetails&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;[&lt;/p&gt;
&lt;p&gt;CmdletBinding&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;]&lt;/p&gt;
&lt;p&gt;param&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;[&lt;/p&gt;
&lt;p&gt;parameter&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;Mandatory&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;$true&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;]&lt;/p&gt;
&lt;p&gt;[string]&lt;/p&gt;
&lt;p&gt;$Givenname&lt;/p&gt;
&lt;p&gt;,&lt;/p&gt;
&lt;p&gt;[&lt;/p&gt;
&lt;p&gt;parameter&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;Mandatory&lt;/p&gt;
&lt;p&gt;=&lt;/p&gt;
&lt;p&gt;$true&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;]&lt;/p&gt;
&lt;p&gt;[string]&lt;/p&gt;
&lt;p&gt;$Surname&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;Get-ADUser&lt;/p&gt;
&lt;p&gt;-properties&lt;/p&gt;
&lt;p&gt;telephonenumber&lt;/p&gt;
&lt;p&gt;,&lt;/p&gt;
&lt;p&gt;office&lt;/p&gt;
&lt;p&gt;-Filter&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;GivenName&lt;/p&gt;
&lt;p&gt;-eq&lt;/p&gt;
&lt;p&gt;$Givenname&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;-and&lt;/p&gt;
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;Surname&lt;/p&gt;
&lt;p&gt;-eq&lt;/p&gt;
&lt;p&gt;$Surname&lt;/p&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;`If you call the function and don&amp;quot;™t give values for the parameters you will be prompted for them&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>A question on the forum about a function had me thinking. The user had defined two parameters for the function and then used Read-Host to get the values.</p><p>NO</p><p>Much better way is to use an advanced function and make the parameters mandatory</p><p>`function</p><p>Getuserdetails</p><p>{</p><p>[</p><p>CmdletBinding</p><p>(</p><p>)</p><p>]</p><p>param</p><p>(</p><p>[</p><p>parameter</p><p>(</p><p>Mandatory</p><p>=</p><p>$true</p><p>)</p><p>]</p><p>[string]</p><p>$Givenname</p><p>,</p><p>[</p><p>parameter</p><p>(</p><p>Mandatory</p><p>=</p><p>$true</p><p>)</p><p>]</p><p>[string]</p><p>$Surname</p><p>)</p><p>Get-ADUser</p><p>-properties</p><p>telephonenumber</p><p>,</p><p>office</p><p>-Filter</p><p>{</p><p>(</p><p>GivenName</p><p>-eq</p><p>$Givenname</p><p>)</p><p>-and</p><p>(</p><p>Surname</p><p>-eq</p><p>$Surname</p><p>)</p><p>}</p><p>}</p><p>`If you call the function and don"™t give values for the parameters you will be prompted for them</p><p>The other point is the &ldquo;“Filter property on get-aduser. Don&rdquo;™t put quotes round the variable</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2779/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2779/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2779&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item><item><title>PowerShell workflow articles</title><link>https://powershell.org/articles/2013-01-03-powershell-workflow-articles/</link><guid>https://powershell.org/articles/2013-01-03-powershell-workflow-articles/</guid><pubDate>Thu, 03 Jan 2013 12:01:51 +0000</pubDate><description>&lt;p&gt;I&amp;quot;™ve written a series of articles on PowerShell workflows that are appearing on the Scripting Guy blog. The first two in the series have been published at:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx" title="http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx"&gt;http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx" title="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx"&gt;http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Enjoy&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2778/"&gt;&lt;img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2778/" alt=""&gt;&lt;/a&gt;&lt;img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;amp;blog=16267735&amp;amp;%23038;post=2778&amp;amp;%23038;subd=richardspowershellblog&amp;amp;%23038;ref=&amp;amp;%23038;feed=1" alt=""&gt;&lt;/p&gt;</description><content:encoded>&lt;![CDATA[<p>I"™ve written a series of articles on PowerShell workflows that are appearing on the Scripting Guy blog. The first two in the series have been published at:</p><p><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx" title="http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx">http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx</a></p><p><a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx" title="http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx">http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx</a></p><p>Enjoy</p><p><a href="http://feeds.wordpress.com/1.0/gocomments/richardspowershellblog.wordpress.com/2778/"><img src="http://feeds.wordpress.com/1.0/comments/richardspowershellblog.wordpress.com/2778/" alt=""/><img src="http://stats.wordpress.com/b.gif?host=richardspowershellblog.wordpress.com&amp;blog=16267735&amp;%23038;post=2778&amp;%23038;subd=richardspowershellblog&amp;%23038;ref=&amp;%23038;feed=1" alt=""/>
]]></content:encoded></item></channel></rss>