<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Use the PowerShell Grep Command to Parse the Command Line</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/08/01/use-the-powershell-grep-command-to-parse-the-command-line.aspx</link><description>Summary : In this article, Microsoft Scripting Guy Ed Wilson teaches how to use the Windows PowerShell version of grep to parse the command line.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Use the PowerShell Grep Command to Parse the Command Line</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/08/01/use-the-powershell-grep-command-to-parse-the-command-line.aspx#3553515</link><pubDate>Tue, 19 Feb 2013 13:07:10 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3553515</guid><dc:creator>saal.it</dc:creator><description>&lt;p&gt;@DJS &lt;/p&gt;
&lt;p&gt;Is Filter table a solution?&lt;/p&gt;
&lt;p&gt;Get-WmiObject -Class Win32_DiskDrive &amp;nbsp;|ft Caption&lt;/p&gt;
&lt;p&gt;Caption&lt;/p&gt;
&lt;p&gt;-------&lt;/p&gt;
&lt;p&gt;HITACHI HTS723232A7A364 ATA Device&lt;/p&gt;
&lt;p&gt;Ricoh SD Disk Device&lt;/p&gt;
&lt;p&gt;Kingston DataTraveler 150 USB Device&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3553515" width="1" height="1"&gt;</description></item><item><title>re: Use the PowerShell Grep Command to Parse the Command Line</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/08/01/use-the-powershell-grep-command-to-parse-the-command-line.aspx#3551139</link><pubDate>Thu, 07 Feb 2013 22:34:21 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3551139</guid><dc:creator>DJS</dc:creator><description>&lt;p&gt;This seems to work well when you&amp;#39;re selecting strings from non-PowerShell commands. But when you are, it&amp;#39;s not quite the same.&lt;/p&gt;
&lt;p&gt;Consider this. I&amp;#39;m trying to use the Get-WmiObject cmdlet to search Win32_DiskDrive and pluck out only the line that says Caption. I just want to be able to see what drive a machine may have. (Mostly I&amp;#39;m playing around.) What I *want* to do is Get-WmiObject -Class Win32_DiskDrive | grep &amp;quot;Caption&amp;quot;. That would give me what I&amp;#39;m looking for. But here I&amp;#39;m trying to do it in PowerShell, so in accordance with your suggestions here, I&amp;#39;ve tried things like:&lt;/p&gt;
&lt;p&gt;Get-WmiObject -Class Win32_DiskDrive | Select-String -Pattern &amp;quot;Caption&amp;quot; -SimpleMatch.&lt;/p&gt;
&lt;p&gt;This doesn&amp;#39;t work. I get nothing as a response - just another prompt. My guess is that what is being returned is technically not a string at all, but the actual object, so there&amp;#39;s really nothing to display. But I don&amp;#39;t know how to get what I want.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3551139" width="1" height="1"&gt;</description></item><item><title>re: Use the PowerShell Grep Command to Parse the Command Line</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/08/01/use-the-powershell-grep-command-to-parse-the-command-line.aspx#3445592</link><pubDate>Sun, 07 Aug 2011 21:24:06 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3445592</guid><dc:creator>Ed Wilson</dc:creator><description>&lt;p&gt;@BigTeddy you are right ... on some machines. On my laptop, I get an error about indexing into a match collections ... but the prolbem is that IPV4 only appears ONCE in my output. If I do this: (ipconfig /all | Select-String &amp;quot;dhcp&amp;quot;)[0] it works and allows me to index into the collection ... &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3445592" width="1" height="1"&gt;</description></item><item><title>re: Use the PowerShell Grep Command to Parse the Command Line</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/08/01/use-the-powershell-grep-command-to-parse-the-command-line.aspx#3445423</link><pubDate>Fri, 05 Aug 2011 19:53:15 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3445423</guid><dc:creator>Bigteddy</dc:creator><description>&lt;p&gt;Or this:&lt;/p&gt;
&lt;p&gt;(ipconfig | Select-String &amp;quot;IPv4&amp;quot;)[0]&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3445423" width="1" height="1"&gt;</description></item><item><title>re: Use the PowerShell Grep Command to Parse the Command Line</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/08/01/use-the-powershell-grep-command-to-parse-the-command-line.aspx#3444527</link><pubDate>Mon, 01 Aug 2011 16:35:17 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3444527</guid><dc:creator>Ed Wilson</dc:creator><description>&lt;p&gt;@jrv I have not written about the Script Control, and I do not believe that Sean has either. It is a great subject for an article, or two. I do have a small article, in the Library that talks about using the Script Control. It is a good suggestion ... Look for something in the next month or so. &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3444527" width="1" height="1"&gt;</description></item><item><title>re: Use the PowerShell Grep Command to Parse the Command Line</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/08/01/use-the-powershell-grep-command-to-parse-the-command-line.aspx#3444518</link><pubDate>Mon, 01 Aug 2011 15:35:09 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3444518</guid><dc:creator>jrv</dc:creator><description>&lt;p&gt;Thanks Ed. &amp;nbsp;I am enjoying how far you and Sen have gotten with scavenging all useful thngs from legacy commands and scripts.&lt;/p&gt;
&lt;p&gt;Yes. &amp;nbsp;PowerShell has so many ways to do everything. &lt;/p&gt;
&lt;p&gt;Do you have any articles on the Script Control?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3444518" width="1" height="1"&gt;</description></item><item><title>re: Use the PowerShell Grep Command to Parse the Command Line</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/08/01/use-the-powershell-grep-command-to-parse-the-command-line.aspx#3444490</link><pubDate>Mon, 01 Aug 2011 13:55:38 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3444490</guid><dc:creator>Ed Wilson</dc:creator><description>&lt;p&gt;@JRV Thank you. I am glad you liked the article. Your suggestion is a good one. That is one thing I LOVE about PowerShell is that there are dozens of ways of doing the same thing. I LOVE your alternative solutions ... &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3444490" width="1" height="1"&gt;</description></item><item><title>re: Use the PowerShell Grep Command to Parse the Command Line</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/08/01/use-the-powershell-grep-command-to-parse-the-command-line.aspx#3444466</link><pubDate>Mon, 01 Aug 2011 10:45:45 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3444466</guid><dc:creator>jrv</dc:creator><description>&lt;p&gt;Good artcle once again..&lt;/p&gt;
&lt;p&gt;Try this&lt;/p&gt;
&lt;p&gt;(ipconfig) -match &amp;#39;ipv4&amp;#39;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3444466" width="1" height="1"&gt;</description></item></channel></rss>