News

 Subscribe Add to Technorati Favorites

 

 

 

 


 

 

Search My Blog:

 

 

My Stats

  • Posts - 472
  • Comments - 277
  • Trackbacks - 265

Twitter












Tag Cloud


Recent Comments


Recent Posts


Archives


Post Categories


Blogs


Miscellanous


Noteworthy Stuff


Popular Posts


February 2007 Entries

NetCmdlets Command Line Emailer saves ME time


Scott Hanselman has a little TODO batch file that he uses to quickly email himself notes from the command line. I have something similar, but mine is a PowerShell script that uses NetCmdlets. The cool thing about the send-email cmdlet in NetCmdlets is that it supports SSL as well as other email features like html mail and attachments. There are separate cmdlets for sending other types of messages like Usenet newsgroup articles, Jabber IMs (ie, Google Talk), SMS messages, SNMP traps, etc.

Here is my script:

param( [string] $target = "work",
[string] $msg )

switch ($target)
{
"work" { $target = "me@mydomain.com" }
"home" { $target = "mailto:%22%20%7B%20$target%20=%20%22@me@myotherdomain.com" }
}

send-email -from me@mydomain.com -to $target -subject ("Todo: " + $msg) -message $msg -server 10.0.1.1

And here's how I use it:

 

PS C:\> todo work "email James about AS2"                                                                               
                                                                                                                        
Server                          Recipient                                                               Success 
------                          ---------                                                               ------- 
10.0.1.1                        lancer@nsoftware.com                                                       True 
                                                                                                                        
PS C:\>                                                                            

 

If I wanted I could use the get-dns cmdlet to find out the appropriate mail server for the recipient address and send directly to that server rather than hard-coding my own.

posted @ Wednesday, February 28, 2007 9:04 AM | Feedback (1) |


PowerShell cmdlet for SNMP (part 2: sysUpTime)


Brandon updated his get-uptime script to output a custom object. Brandon's script works with the LastBootUpTime property returned from WMI Win32_OperatingSytem.

I already talked briefly about the get-snmp, set-snmp, get-trap, and send-trap cmdlets that are included in NetCmdlets. Here's how you can use get-snmp to get the sysUpTime from any SNMP-enabled device. Note: sysUpTime is defined as the time since the last re-initialization (ie, boot) of the device, in 100ths of a second.

get-snmp -agent [string] -oid sysUpTime.0

Here are my SNMP-versions of Brandon's examples:

This gets uptime on a Single Server:

PS C:\> get-snmp -agent 10.0.1.11 -oid sysUpTime.0                                                                      
                                                                                                                        
Host                          OID                           OIDValue                      OIDType                       
----                          ---                           --------                      -------                       
10.0.1.11                     1.3.6.1.2.1.1.3.0             155734659                     TimeTicks                     
                                                                                                                        
                                                                                                                        
PS C:\> get-bufferhtml | out-file sample.html                                                                           


This gets all servers up for more than 30 days: (the "magic number": there are 8640000 hundreths of a second in 1 day)

PS C:\> (get-snmp -agent 255.255.255.255 -oid sysUpTime.0) | ?{$_.OIDValue / (8640000) -gt 30}                          
                                                                                                                        
Host                          OID                           OIDValue                      OIDType                       
----                          ---                           --------                      -------                       
10.0.1.219                    1.3.6.1.2.1.1.3.0             296372079                     TimeTicks                     
                                                                                                                        
                                                                                                                        
PS C:\> get-bufferhtml | out-file sample.html                                                                           

This Displays the Last Reboot Time of a list of servers.

PS C:\> (get-snmp -agent 255.255.255.255 -oid sysUpTime.0) | %{([datetime]::Now).AddSeconds(-($_.OIDValue/100))}        
                                                                                                                        
Wednesday, January 24, 2007 8:56:18 AM                                                                                  
Friday, February 09, 2007 3:22:27 PM                                                                                    
Monday, February 19, 2007 1:15:43 AM                                                                                    
                                                                                                                        
                                                                                                                        
PS C:\> get-bufferhtml | out-file sample.html                                                                           

Technorati : , , ,

posted @ Tuesday, February 27, 2007 3:26 PM | Feedback (2) |


PowerShell book


Bruce Payette's Windows Powershell in Action is now available on Amazon.

posted @ Tuesday, February 27, 2007 11:46 AM | Feedback (3) |


Combine multiple feeds with RSSBus


Here's an RSSBus script that will create an RSS feed that is a combination of two feeds:

<rsb:call op="http://api.flickr.com/services/feeds/groups_pool.gne?id=27144182@N00&format=rss_200">
    <rsb:push title="Flickr Gnarley Trees: [title]" />
</rsb:call>
<rsb:call op="http://api.flickr.com/services/feeds/groups_pool.gne?id=13378274@N00&format=rss_200">
    <rsb:push title="Flickr Flowers: [title]" />
</rsb:call>

In this example I don't just combine the feeds, but I have altered the title of each item to indicate which source feed it came from. All I do in this script is call the first feed, and prepend "Trees: " to the title for each item before I push it out. Then I call the 2nd feed, and prepend the text "Flowers: " to the title of each item before I push it out.

Note that the resulting feed contains all the items from the Flickr gnarley trees group as well as all the items from the Flickr flowers group. Also the resulting feed contains ALL elements of each item, not just the standard rss elements (in this example, that means the yahoo media information is present for each item).

If you're not familiar with RSSBus scripts, which produce feeds, just take a look at this 3 minute screencast. About 2/5 of the way through, the script editor is shown, where you can create a new script, paste the script above in, and voila you have a feed.

Filtering

I can also filter this feed in many ways, such as by date.  Here is an example of the above feed where it only shows items from the last 24 hours.  The differences:

  • I define an attribute called date.now, and set it to todays date/time
  • Instead of pushing every item with the prepended title, I check the difference in the publish date of each item and todays date.  If the difference is less than 1 day, only then do I push the item.

 

<rsb:set attr="date.now" value="[null | date()]" /> <rsb:call op="http://api.flickr.com/services/feeds/groups_pool.gne?id=27144182@N00&format=rss_200">   <rsb:set attr="datediff" value="[rss:pubDate | datediff('Day','[date.now]')]" />   <rsb:equals attr="datediff" value="0">     <rsb:push title="Trees: [title]" />   </rsb:equals> </rsb:call> <rsb:call op="http://api.flickr.com/services/feeds/groups_pool.gne?id=13378274@N00&format=rss_200">   <rsb:set attr="datediff" value="[rss:pubDate | datediff('Day','[date.now]')]" />   <rsb:equals attr="datediff" value="0">     <rsb:push title="Flowers: [title]" />   </rsb:equals> </rsb:call>

Technorati :

posted @ Wednesday, February 21, 2007 1:28 PM | Feedback (2) |


How to prevent Outlook 2007 from blocking unsafe attachments


A lot of times I need to be able to look at .reg, .vbs, .vb, etc - attachments that people send me via email. I don't go haphazardly running them, but I need to at least be able to save them to disk and drag them into my text editor. Here's how to make the changes in Vista to prevent Outlook 2007 from blocking these files. Note that with these changes, you still won't be able to just double-click on the attachment and run it (this is good), you'll have to save it to disk first.

  1. Make sure you really want to do this, it could be dangerous. :)

  2. Pick up the Office 2007 Administrative Templates.

  3. From MMC, add the Local Computer Policy snap-in, and go to User Configuration->Administrative Templates. Right click and add the new Office 2007 administrative templates that you downloaded.

  4. From there, go to Classic Administrative Templates (ADM)->Microsoft Office Outlook 2007->Security->Security Form Settings. Edit the properties of Outlook Security Mode to enable and choose which type you want. In my example I am using Group Policy settings.

  5. Go to Security Form Settings->Attachment Security, there you can enable display of level 1 attachments.

posted @ Wednesday, February 21, 2007 1:28 PM | Feedback (2) |


Using PSCredentials without a prompt


You cannot use get-credential without some type of prompt (although you can do it without the pop-up dialog), however you can save your securestring password to a file, reload it for later, and manually create a credential without a prompt. Of course the problem with this is that your password will be exposed to anyone with access to the file, so do this at your own risk.

First, choose your password and write it to a file:

PS C:\> read-host -assecurestring | convertfrom-securestring | out-file C:\securestring.txt                                
*******                                                                                                                 
In the future, you won't have to enter your credentials over and over again, instead you can just read in your password from the file, and create a new PSCredential object from that. Then you can use that credential to perform various tasks like connecting to ftp servers and such, like so:
PS C:\> $pass = cat C:\securestring.txt | convertto-securestring                                                            
PS C:\> $mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist "test",$pass                
PS C:\> get-ftp -server 10.0.1.1 -cred $mycred -list *.vb                                                                             
                                                                                                                        
                                                                                                                        
DirEntry : -rw-------    1 1036     100          1044 Dec 07 17:39 AssemblyInfo.vb                                      
FileName : AssemblyInfo.vb                                                                                              
FileSize : 1044                                                                                                         
FileTime : Dec 07 17:39                                                                                                 
IsDir    : False                                                                                                        
                                                                                                                        
                                                                                                                        
PS C:\> get-bufferhtml | out-file sample.html                                                                           

Technorati : , , ,

posted @ Friday, February 16, 2007 1:21 PM | Feedback (5) |


Debugging classic ASP on IIS7


The first time you go debugging classic ASP scripts on IIS7 you'll just get errors that say "An error occurred on the server when processing the URL. Please contact the system administrator".

To see the real error, go to MMC and load the IIS Manager snap-in and go to your website. Double click on "ASP" in the Features View tab, drill down into Debugging Properties and change "Send Errors To Browser" to true.

posted @ Wednesday, February 14, 2007 2:49 PM | Feedback (9) |


Feeds with parameters and metadata


Dave Winer echoes my complaint about Yahoo Pipes:

in Pipes, there's no way to tell if items in two feeds are talking about the same thing. The best you can hope for is keyword serendipity, which all the demos so far do, and those make for unsatisfying demos, because you know you couldn't deploy a useful app out of the concepts they illustrate.

Then he goes on to unknowingly describe RSSBus:

Now it's possible that a company like Yahoo, with its diverse flows of information, and nearly universal support of RSS, could add enough metadata to their feeds to be sure two items in different feeds were talking about the same thing, and then we'd be somewhere interesting.

In the Read/WriteWeb post that Dave points to, Richard McManus points out:

For example, one can build a pipe that extracts the listings of all French restaurants in Chicago, along with their Flickr photos. 

... unlike in Relational Databases, the data is neither structured nor clean. For example, how can we ensure that Flickr pictures of restaurants in Chicago will be the right ones? We really cannot.

Well, we could at least be sure that those restaurants are in Chicago - Flickr feeds support geo location data in their feeds, its only Yahoo that is ripping that data out.

Technorati : ,

posted @ Wednesday, February 14, 2007 2:27 PM | Feedback (0) |


RSS emitting API


Jeremy Zawodny wants to see RSS-emitting APIs for every widget out there. Ding!

That's how my AmzWish widget (you can see an example on my blog or on the AmzWish generator page) was created: simply making calls to AmazonOps exposed by RSSBus (which outputs RSS feeds). Basically AmzWish is just some html mixed in with an RSS feed. You can make your own or view the source here.

The same thing could easily be done for Yahoo! Shopping - maybe I should put together some operations for the RSSBus yahooOps connector, though I'm dont think (but I'm not sure) Yahoo's wishlist feature is exposed through their Shopping API. I know that their existing Yahoo Shopping feeds are very limited - though I predict that will change in the not-too-distant future.

Technorati : , , , ,

posted @ Tuesday, February 13, 2007 2:02 PM | Feedback (2) |


Slicing and Dicing web data


Yesterday Jon Udell wrote about slicing and dicing, and then rewiring the web. Reusing websites as data sources is great - and Yahoo Pipes provides several such "sources" in Yahoo Search, Yahoo Local, Flickr, Google Base, and the basic URL Fetch. All these are great and provide interconnectivity and the ability to slice and dice certain parts of the web. But why stop there? The beauty of this annotating, slicing, and dicing, is in the reusability of this data - not just for reading blogs - but for transporting and exchanging real data that we can compute with. This is where Yahoo Pipes has missed the bus so far, but I have no doubt they will catch the next one.

Mark says that the power in Pipes is that it "gives you more structure and semantics to grab onto and use in the modules, building more value into standard components, rather than having to go and re-invent the wheel for each application". But does it really? It could, if it didn't rip valuable data out of the sources.

Yes, my biggest complaint about Yahoo Pipes right now is that it does things to my feed that I don't ask it to. If I source a Flickr feed and output it - I get a feed with a title, description, link, and pubDate. But I happen to know that there is a lot more rich data inside that original Flickr feed. There are so many great data feeds out there - Yahoo has some very useful ones - why rip out that useful data?

I have enjoyed playing with Yahoo Pipes, but right now I can't use it with my data feeds like the ones that RSSBus generates from my SQL Server, my QuickBooks installation, my bank account, etc. Well...I can use it, but I can't get at all the details of the feed - only what is exposed in title, description, link, and pubDate!

One of my favorite things about the RSSBus Desktop server is that it lets me slice and dice the web (feeds), but on top of that it also gives me the option of slicing and dicing it with my own private data. I know that may be extra nerdy, but it sure is cool to me.

Technorati : , , ,

posted @ Tuesday, February 13, 2007 11:55 AM | Feedback (0) |


Connecting sources of data, online or off


This post by Jeff Barr gives some interesting examples of things people might want to do with their data, and more specifically connecting their data to and from multiple sources. The kind of things Jeff mentions can be attained using RSSBus. It all boils down to flexibility, and how someday we should be able to take such flexibility for granted.

One of the examples Jeff gives is locating the Amazon wishlist of his top email correspondents, which is actually quite easily done with RSSBus. RSSBus comes with what we call "connectors" for email (pop, imap, smtp), amazon web services (including wishlist searching), and lots of other data sources. And since the RSSBus connector interface is open, new connectors for things like LinkedIn and Twitter can be created and shared. I can take the ImapOps connector and pipe its output to the AmazonOps connector and voila, I have a list of amazon wishlists for my top email correspondents. How? Check this out, here's the skinny:

  1. Call the RSSBus imapSearch operation and get a list of emails.
  2. Call the RSSBus rsbFeedUnion operation to consolidate mails from the same sender into one item per sender, with a count of how many emails from this sender were in the box.
  3. Sort this list by number of emails from each sender with the rsbSort operation.
  4. Use the amazonListSearch operation to Search for an Amazon wishlist for the top 10 most active senders in the my list of emailers.

Here's what the actual script looks like (download the full script):


<rsb:call save="mail" op="imapSearch?server=myserver&searchcriteria=ALL" />
<rsb:call save="union" op="rsbFeedUnion?feed=[_feeds.mail | urlencode]&filter=imap:fromemail" />
<rsb:call op="rsbSort?feed=[_feeds.union | urlencode]&sortby=rsb:count&type=numeric">
  <rsb:call op="amazonListSearch?email=[imap:fromemail]&type=wish" pagesize="10">
    <rsb:push />
  </rsb:call>
</rsb:call>

For those who want a more technical explanation, let me take you up close and personal with this RSSBus script:

  1. First, I call the imapSearch operation. I give it my IMAP server and login information and tell it I want a list of ALL my emails. I save this list in a cached RSS feed called "mail". Two sub-notes here: authentication info need not be specified here if I take advantage of the RSSBus profile, and searchcriteria is extremely flexible and follows the IMAP specification, so I could do something like searchcriteria=SENTSINCE 1-Feb-2007 to get a list of only the mails sent since Feb 1.
  2. Next, I call the rsbFeedUnion operation. I tell it to perform a union on the "mail" feed. Yes, I'm doing a union on one set of information, and the reason is so that I can take advantage of the filtering capabilities of the rsbFeedUnion operation to consolidate duplicate mails from the same sender. So the result of this call is a feed of information about emails, in which each sender only appears once in the list. I save this feed as "union". Note that rsbFeedUnion will increment a counter for me when a particular sender is encountered more than once. I could set the filter input to eliminate duplicate subjects, or any other attribute of the mail feed, but here I am interested in the sender.
  3. Now I want to sort this "union" feed of emails by the number of times each sender has mailed me, so I call rsbSort, give it my "union" feed, and tell it which attribute to sort by (rsb:count). Unlike the two previous operation calls, I won't save this feed, but instead, for each of the 10 (pagesize) individual items in the feed I'll call the amazonListSearch operation.
  4. Finally, the amazonListSearch operation returns a final feed of items containing information about the wish list(s) (if one exists) of each mail sender. Now I have an RSS feed of Amazon wishlists for my top email contacts!

Technorati : , , , , , ,

posted @ Thursday, February 08, 2007 10:43 AM | Feedback (0) |