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

<channel>
	<title>PowerShell.nu &#187; COM Object</title>
	<atom:link href="http://www.powershell.nu/category/com-object/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.powershell.nu</link>
	<description></description>
	<lastBuildDate>Wed, 14 Jul 2010 22:17:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Write-StickyNote</title>
		<link>http://www.powershell.nu/2009/06/05/write-stickynote/</link>
		<comments>http://www.powershell.nu/2009/06/05/write-stickynote/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 16:30:03 +0000</pubDate>
		<dc:creator>Niklas Goude</dc:creator>
				<category><![CDATA[COM Object]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://www.powershell.nu/?p=741</guid>
		<description><![CDATA[Here&#8217;s a fun script that uses the new &#8220;Sticky Notes&#8221; in WIndows 7. The script is based on a simple function that uses the SendKeys() method through the Wscript.Shell COM object. This is a nice example on how you can handle COM objects through PowerShell. I&#8217;ve also included an if statement that checks if StickyNotes [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a fun script that uses the new &#8220;Sticky Notes&#8221; in WIndows 7.</p>
<p />
The script is based on a simple function that uses the SendKeys() method through the Wscript.Shell COM object. This is a nice example on how you can handle COM objects through PowerShell.</p>
<p />
I&#8217;ve also included an if statement that checks if StickyNotes is active. If that&#8217;s the case, the text will be started in a new StickyNotes.. note..</p>
<p />
Anyway, here&#8217;s the function.</p>
<pre>
<strong>
function Write-StickyNote ([string]$Text) {

	if (gps | Where { $_.ProcessName -match "stikynot" }) {

		$StickyNote = $True
	}

	$Wscript = New-Object -Com Wscript.Shell
	[void]$Wscript.Run("stikynot.exe")
	start-sleep 1

	if ($StickyNote -eq $True) {

		$Wscript.SendKeys("^n")
	}

	$Wscript.SendKeys($Text)
}
</strong>
</pre>
<p>And here&#8217;s an example on running the function.</p>
<p />
<pre>
<strong>
PS > .\Write-StickyNote.ps1 "Hello from PowerShell.nu"
</strong>
</pre>
<p />
<a href="http://www.powershell.nu/wp-content/uploads/2009/06/stickynotes01.jpg"><img src="http://www.powershell.nu/wp-content/uploads/2009/06/stickynotes01.jpg" alt="stickynotes01" title="stickynotes01" width="201" height="183" class="alignnone size-full wp-image-742" /></a></p>
<p />
<a href="http://www.powershell.nu/wp-content/uploads/2009/06/write-stickynote.ps1">Click here to download the Script</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.powershell.nu/2009/06/05/write-stickynote/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RSS, Speech and PowerShell</title>
		<link>http://www.powershell.nu/2009/03/22/rss-speech-and-powershell/</link>
		<comments>http://www.powershell.nu/2009/03/22/rss-speech-and-powershell/#comments</comments>
		<pubDate>Sun, 22 Mar 2009 21:55:12 +0000</pubDate>
		<dc:creator>Niklas Goude</dc:creator>
				<category><![CDATA[COM Object]]></category>

		<guid isPermaLink="false">http://www.powershell.nu/?p=570</guid>
		<description><![CDATA[Rss Feeds are great ways of keeping track of updates and news on pages that you frequently visit. In this post we are going to look at an alternative way of examining Rss Feeds. We will use Net.WebClient .Net Class to access the Feed through PowerShell and store the information in a PsCustomObject. Finally we [...]]]></description>
			<content:encoded><![CDATA[<p>Rss Feeds are great ways of keeping track of updates and news on pages that you frequently visit. In this post we are going to look at an alternative way of examining Rss Feeds. We will use Net.WebClient .Net Class to access the Feed through PowerShell and store the information in a PsCustomObject. Finally we will use SPVoice Com object to read the HeadLines.</p>
<p />
We Connect to the Rss Feed through Net.WebClient</p>
<p />
<pre>
<strong>
PS > $WebClient = New-Object Net.WebClient
PS > $DownloadString = $WebClient.DownloadString("http://www.powershell.nu/feed/rss/")
</strong>
</pre>
<p />
Now that we have downloaded the information from the Feed we can start analyzing and modifying it. Starting off, we want to grab all Urls that link to the Posts. We can accomplish this through the Select-String CmdLet.</p>
<p />
<pre>
<strong>
PS > $rss = $DownloadString.Split() | select-string -case "&#60;link&#62;"
</strong>
</pre>
<p />
It might also be a good idea to remove unwanted data. We can use the -replace operator to do this.</p>
<p />
<pre>
<strong>
PS > $rss = $rss -replace ".*&#60;link&#62;",""
PS > $rss = $rss -replace "&#60;/link&#62;.*",""
</strong>
</pre>
<p />
If we look at the $rss object it contains the Urls to all recent blog posts.</p>
<p />
<pre>
<strong>
PS > $rss
</strong>

http://www.powershell.nu

http://www.powershell.nu/2009/03/15/insert-a-page-break-in-a-word-document-using-powershell/

http://www.powershell.nu/2009/03/15/sharepoint-and-powershell-in-real-life/

http://www.powershell.nu/2009/03/09/create-site-with-approval-workflow-using-powershell-part-2/

http://www.powershell.nu/2009/03/08/set-themeps1-set-theme-in-sharepoint-using-powershell/

http://www.powershell.nu/2009/03/08/the-scandinavia-powershell-user-group/
</pre>
<p />
Now that we have all the Urls, we can loop through each of them and get additional information from the posts. Im going to get retrieve the Title and som Text describing the Post. Im also adding a if statement to omit the default index page. you can <a href="http://www.powershell.nu/wp-content/uploads/2009/03/rss-read.ps1">check out the function in the Complete script.</a></p>
<p />
Now that we know how to retrieve information from Rss Feeds and Internet sites we can continue and check out the SAPI.SPVoice Com object.</p>
<p />
<pre>
<strong>
function Rss-Read ([string]$speechy) {

	$SPVoice = New-Object -Com SAPI.SPVoice
	$SPVoice.Speak($speechy) | Out-Null
}
</strong>
</pre>
<p />
typing Rss-Read followed by some text will trigger the Com object to read the argument.</p>
<p />
Last part is putting it all togheter. I do this through a third function that calls on the other functions.</p>
<p />
<pre>
<strong>
function Get-News {

	$Rss = Get-Rss

	$Rss | ForEach {

		$_ | Format-List

		Rss-Read $_.HeadLine
	}
}
</strong>
</pre>
<p />
<a href="http://www.powershell.nu/wp-content/uploads/2009/03/rss-read.ps1">And here&#8217;s a link to the complete Script</a></p>
<p />
Examples on Running the Script:</p>
<p />
<pre>
<strong>
PS > .\Rss-Read.ps1

PS > .\Rss-Read.ps1 -help
</strong>
</pre>
<p />
]]></content:encoded>
			<wfw:commentRss>http://www.powershell.nu/2009/03/22/rss-speech-and-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
