<?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>Expert Solution for 2011 Scripting Games Advanced Event 7: Use PowerShell and Regex to Get Twitter IDs from a Web Page</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/04/26/expert-solution-for-2011-scripting-games-advanced-event-7-use-powershell-and-regex-to-get-twitter-ids-from-a-web-page.aspx</link><description>Summary : Microsoft Windows PowerShell MVP, Tome Tanasovski, uses regular expressions to get Twitter IDs from a web page while solving Advanced Event 7 in 2011 Scripting Games. 
 Microsoft Scripting Guy, Ed Wilson, here. Tome Tanasovski is the expert</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Expert Solution for 2011 Scripting Games Advanced Event 7: Use PowerShell and Regex to Get Twitter IDs from a Web Page</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/04/26/expert-solution-for-2011-scripting-games-advanced-event-7-use-powershell-and-regex-to-get-twitter-ids-from-a-web-page.aspx#3424984</link><pubDate>Thu, 28 Apr 2011 18:46:57 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3424984</guid><dc:creator>cseiter</dc:creator><description>&lt;p&gt;Tome, thanks for the explaination. &amp;nbsp;I attempted to create a custom object earlier but didn&amp;#39;t understand what it was completely doing, but by 10 I understood it more, and your directed explaination wraps the steak in bacon(icing on the cake is too over-used). &amp;nbsp;Creating custom objects is becoming a very import part of a self-imposed challenge &amp;quot;No GUI: PowerShell Only Day&amp;quot;.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3424984" width="1" height="1"&gt;</description></item><item><title>re: Expert Solution for 2011 Scripting Games Advanced Event 7: Use PowerShell and Regex to Get Twitter IDs from a Web Page</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/04/26/expert-solution-for-2011-scripting-games-advanced-event-7-use-powershell-and-regex-to-get-twitter-ids-from-a-web-page.aspx#3424704</link><pubDate>Wed, 27 Apr 2011 16:48:56 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3424704</guid><dc:creator>Robert</dc:creator><description>&lt;p&gt;“The truth is, my first stab at this completed the requirements in only a few lines of code…”&lt;/p&gt;
&lt;p&gt;I’m curious and would like to see your terse solution. I got a 233 char one-liner that solves the event’s requirements, except for the CSV, which to me is excessive.&lt;/p&gt;
&lt;p&gt;Nice RegEx by the way, I’m also a RegEx enthusiast; mine is 42 char long.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3424704" width="1" height="1"&gt;</description></item><item><title>re: Expert Solution for 2011 Scripting Games Advanced Event 7: Use PowerShell and Regex to Get Twitter IDs from a Web Page</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/04/26/expert-solution-for-2011-scripting-games-advanced-event-7-use-powershell-and-regex-to-get-twitter-ids-from-a-web-page.aspx#3424423</link><pubDate>Tue, 26 Apr 2011 21:32:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3424423</guid><dc:creator>Tome</dc:creator><description>&lt;p&gt;Chris,&lt;/p&gt;
&lt;p&gt;Looking at your entry: &lt;a rel="nofollow" target="_new" href="https://2011sg.poshcode.org/1676"&gt;2011sg.poshcode.org/1676&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Your problem is working with strings instead of objects. &amp;nbsp;Learn to use the following for everything - that includes output to screen, output to csv, etc. &amp;nbsp;With time this will become second nature. &amp;nbsp;Learning this technique is what turns a good scripter into a good PowerShell scripter.&lt;/p&gt;
&lt;p&gt;I personally started with this template, but there are other ways to do it - actually there are more efficient ways, but this is the best one to start with in my opinion.&lt;/p&gt;
&lt;p&gt;$objects = @()&lt;/p&gt;
&lt;p&gt;foreach ($number in (0..100)) { #Simulating a loop you would be doing for every line or something else&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; $object = new-object psobject &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; $object |Add-member noteproperty -name column1 -value $number&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; $object |Add-member noteproperty -name column2 -value &amp;quot;blah$number&amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; $object |Add-member noteproperty -name column3 -value ([int]$number/10)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; $objects += $object&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;#now you display with&lt;/p&gt;
&lt;p&gt;$objects&lt;/p&gt;
&lt;p&gt;#you turn to a csv with&lt;/p&gt;
&lt;p&gt;$objects |convertto-csv file.csv&lt;/p&gt;
&lt;p&gt;#you display to a grid with&lt;/p&gt;
&lt;p&gt;$objects |out-gridview&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3424423" width="1" height="1"&gt;</description></item><item><title>re: Expert Solution for 2011 Scripting Games Advanced Event 7: Use PowerShell and Regex to Get Twitter IDs from a Web Page</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/04/26/expert-solution-for-2011-scripting-games-advanced-event-7-use-powershell-and-regex-to-get-twitter-ids-from-a-web-page.aspx#3424306</link><pubDate>Tue, 26 Apr 2011 14:44:11 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3424306</guid><dc:creator>IamMred</dc:creator><description>&lt;p&gt;Thanks Klaus for added the uRL, I went back and added it to the appropriate place in the blog. &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3424306" width="1" height="1"&gt;</description></item><item><title>re: Expert Solution for 2011 Scripting Games Advanced Event 7: Use PowerShell and Regex to Get Twitter IDs from a Web Page</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/04/26/expert-solution-for-2011-scripting-games-advanced-event-7-use-powershell-and-regex-to-get-twitter-ids-from-a-web-page.aspx#3424281</link><pubDate>Tue, 26 Apr 2011 13:03:53 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3424281</guid><dc:creator>cseiter</dc:creator><description>&lt;p&gt;Stupid spelling mistakes. &amp;nbsp;Sorry, Klaus.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3424281" width="1" height="1"&gt;</description></item><item><title>re: Expert Solution for 2011 Scripting Games Advanced Event 7: Use PowerShell and Regex to Get Twitter IDs from a Web Page</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/04/26/expert-solution-for-2011-scripting-games-advanced-event-7-use-powershell-and-regex-to-get-twitter-ids-from-a-web-page.aspx#3424280</link><pubDate>Tue, 26 Apr 2011 13:03:18 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3424280</guid><dc:creator>cseiter</dc:creator><description>&lt;p&gt;right behind ya, klaue. &amp;nbsp;On my script every time I would export my array containing the username comma twittername to a csv it would just give me the length of teh objects and not the actual values. &amp;nbsp;I had to send it to a text file, import the text file as a csv, then export that back out as a csv to get it to work correctly. &amp;nbsp;Would you mind expanding on where I went wrong on that part?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3424280" width="1" height="1"&gt;</description></item><item><title>re: Expert Solution for 2011 Scripting Games Advanced Event 7: Use PowerShell and Regex to Get Twitter IDs from a Web Page</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2011/04/26/expert-solution-for-2011-scripting-games-advanced-event-7-use-powershell-and-regex-to-get-twitter-ids-from-a-web-page.aspx#3424267</link><pubDate>Tue, 26 Apr 2011 12:02:11 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3424267</guid><dc:creator>Klaus Schulte</dc:creator><description>&lt;p&gt;Thanks Tome,&lt;/p&gt;
&lt;p&gt;this a really advanced topic with an adequate solution!&lt;/p&gt;
&lt;p&gt;It is at least advanced enough for me because I don&amp;#39;t understand some aspects of it :-)&lt;/p&gt;
&lt;p&gt;Anyway:&lt;/p&gt;
&lt;p&gt;I saw that a try-catch-block is provided tp protect the download ... great!&lt;/p&gt;
&lt;p&gt;I saw some regexps with named groups ... a wonderful feature!&lt;/p&gt;
&lt;p&gt;I saw that it worked! &lt;/p&gt;
&lt;p&gt;Though I had to comment the call to powershell out (on the first line) because the ISE did &amp;quot;hang&amp;quot; otherwise.&lt;/p&gt;
&lt;p&gt;Well one last thing, I could do is to provide the URL to the solution here:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://gallery.technet.microsoft.com/scriptcenter/7e1a1991-be49-4e64-8198-3166fb6ac536"&gt;gallery.technet.microsoft.com/.../7e1a1991-be49-4e64-8198-3166fb6ac536&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;kind regards, Klaus&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3424267" width="1" height="1"&gt;</description></item></channel></rss>