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


January 2007 Entries

No Windows PowerShell Snap-ins are available for version 1


You'll get the error "No Windows PowerShell Snap-ins are available for version 1" if there are no snapins installed for PowerShell v1. But the tricky part is that more precisely you'll get this error if there are no snapins installed for v1 for the platform you're running on.

So you'll get this error if you are in a 32bit powershell console and you try to call add-pssnapin on some snapin that builds or installs itself only for x64 (like the Exchange Management Snap-in).  You'll get the same if the opposite is true and you try to add a snap-in that builds or installs itself as 32bit from the 64bit console. Even if the snap-in is built for the correct platform, it has to install itself to the correct place in the registry for PowerShell to locate it.


PS C:\> add-pssnapin asdfasdf                                                                                           
Add-PSSnapin : No Windows PowerShell Snap-ins are available for version 1.                                              
At line:1 char:13                                                                                                       
+ add-pssnapin  <<<< asdfasdf                                                                                           
PS C:\> get-bufferhtml | out-file sample.html                                                                           

Alternatively, if you do have some snap-ins installed for that platform, just not that specific snap-in, you'll get:

PS C:\> add-pssnapin Somesnapin                                                                                         
Add-PSSnapin : Windows PowerShell snap-in Somesnapin is not installed on the machine.                                   
At line:1 char:13                                                                                                       
+ add-pssnapin  <<<< Somesnapin                                                                                         


Technorati : ,

posted @ Tuesday, January 30, 2007 5:06 PM | Feedback (0) |


PowerShell and NNTP


Recently Marco Shaw posted a little nntp-stats script in the microsoft.public.windows.powershell newsgroup that I thought was pretty neato, and right up my alley since we were in the middle of adding get-nntp and send-nntp cmdlets to the /n software NetCmdlets product. So as a tip of the hat to Marco, here is my version.

Poster Stats:

Get-nntp returns a collection of objects containing the subject, articleid, sender, references, etc of articles posted in a particular newsgroup. I put together a few lines of code that uses get-nntp to create a hashtable of people who have posted in the PowerShell newsgroup and how many times.


  ## 
## usage: nntpstats [-server] <string> [-newsgroup] <string> [-count] <int> ## param( [int] $count = "100", [string] $server = "msnews.microsoft.com", [string] $newsgroup = "microsoft.public.windows.powershell" )
$articles = get-nntp -server $server -newsgroup $newsgroup -list $count $myhash = @{} for($counter = 0; $counter -lt $articles.Length; $counter++) { if (! $myhash.Contains($articles[$counter].FromName)) { $myhash.add($articles[$counter].FromName, 1) } else { $myhash[$articles[$counter].FromName] = $myhash[$articles[$counter].FromName] + 1 } }
$myhash.GetEnumerator() | sort Value -descending


I'll give this a run with a count parameter value of 2 so that I can easily show the actual article data returned by get-nntp itself. Below you can see the output of my call to the nntpstats script with count = 2, just two posters, each with 1 post.

PS C:\> . .\nntpstats -count 2                         
                                                                                                                        
Name                           Value                                                                                    
----                           -----                                                                                    
Marco Shaw                     1                                                                                        
Sung M Ki                      1                                                                                        

Now here is the $articles object that was returned by get-nntp:

PS C:\> $articles                                       
                                                                                                                        
                                                                                                                        
Number       : 7840                                                                                                     
Subject      : RE: adding function return to an array                                                                   
FromName     : Sung M Ki                                                                                                
FromEmail    : SungMKim@[DELETED]                                                                       
Date         : Wed, 24 Jan 2007 11:30:01 -0800                                                                          
Size         : 1184                                                                                                     
References   : <F91D95BB-5815-4BB5-AD05-FA6EDA241816@microsoft.com>                                                     
MessageID    : <5878669D-E0CB-42C0-B12D-80793CCB97FE@microsoft.com>                                                     
Otherheaders : Xref: TK2MSFTNGP01.phx.gbl microsoft.public.windows.powershell:7840                                      
                                                                                                                        
Number       : 7841                                                                                                     
Subject      : Info: 3rd party cmdlets updated                                                                          
FromName     : Marco Shaw                                                                                               
FromEmail    : marcoDOTshaw_@[DELETED]                                                                               
Date         : Wed, 24 Jan 2007 16:09:12 -0400                                                                          
Size         : 1118                                                                                                     
References   :                                                                                                          
MessageID    : <eJB0FO$PHHA.3268@TK2MSFTNGP03.phx.gbl>                                                                  
Otherheaders : Xref: TK2MSFTNGP01.phx.gbl microsoft.public.windows.powershell:7841                                      
                                                                                                                        

Incidentally, you could create a link to any of these articles in Google Groups by appending the url-encoded messageid (without the angle brackets) to http://groups.google.com/groups?threadm=.

Now here's the output of the nntpstats script after retrieving the last 100 articles from the PowerShell newsgroup:

PS C:\> . .\nntpstats -count 100                       
                                                                                                                        
Name                           Value                                                                                    
----                           -----                                                                                    
Brandon Shell                  11                                                                                       
/\\/\\o\\/\\/ [MVP]            10                                                                                       
jhicks[at]SAPIEN.com           9                                                                                        
Keith Hill [MVP]               8                                                                                        
Oisin Grehan                   8                                                                                        
Andrew Watt [MVP]              7                                                                                        
Ric                            6                                                                                        
$hay                           6                                                                                        
Marco Shaw                     4                                                                                        
IT Staff                       3                                                                                        
Sung M Ki                      3                                                                                        
/\/\o\/\/ [M                   3                                                                                        
joergH                         2                                                                                        
Rolf                           2                                                                                        
                               2                                                                                        
Krishna Vutukuri[MSFT]         2                                                                                        
Nit                            1                                                                                        
Bomber                         1                                                                                        
cthist                         1                                                                                        
Rom                            1                                                                                        
Adam Gera                      1                                                                                        
Paul Hinsber                   1                                                                                        
Bil                            1                                                                                        
Rob Campb                      1                                                                                        
Bombergio                      1                                                                                        
red_deer_hil                   1                                                                                        
                                                                                                                        
                                                                                                                        
PS C:\>

Search:

I can tweak this script to give me a list of messages that match a particular search criteria. Unfortunately most NNTP servers don't implement the search capabilities that are specified in the NNTP RFC's, so implementing such a search requires retrieving and searching article bodies manually:


##
## usage: nntpsearch [-server] <string> [-newsgroup] <string> [-count] <int> [-searchterm] <string> ## param( [int] $count = "100", [string] $server = "msnews.microsoft.com", [string] $newsgroup = "microsoft.public.windows.powershell", [string] $searchterm = "Lance" )
$articles = get-nntp -server $server -newsgroup $newsgroup -list $count for($counter = 0; $counter -lt $articles.Length; $counter++) { $article = get-nntp -server $server -newsgroup $newsgroup -view $articles[$counter].Number if ($article.Message.Contains($searchterm) -eq "true") { Write-Host $article.MessageID } }

posted @ Wednesday, January 24, 2007 5:56 PM | Feedback (0) |


PowerShell remote exec and secure shell


This is not a post about .Net remoting. And its not a post about accessing PowerShell through ssh. Here I'm talking about sending remote executions through rexec, rshell, and secure shell connections.

Rexec and Rshell (rsh.exe) already exist as command line applications, but they do not exists in the PowerShell world (that is, they do not return objects). NetCmdlets send-rexec and send-rshell cmdlets take care of this problem. Each remote execution returns a collection of objects that contain the text and whether or not an EOL was present for each line, like so:

PS C:\> send-rexec -server server -user user -password pass -command "C:\WINDOWS\system32\cmd exe /c dir c:\"
                                                                                                                        
Text                                                                                            EOL 
----                                                                                            --- 
 Volume in drive C has no label....                                                             True 
 Volume Serial Number is 6C32-6256...                                                           True 
...                                                                                             True 
 Directory of c:\...                                                                            True 
...                                                                                             True 
12/13/2006  05:41 PM    <DIR>          Documents and Set...                                     True 
12/17/2006  12:04 PM    <DIR>          Inetpub...                                               True 
01/09/2007  03:06 PM    <DIR>          Program Files...                                         True 
12/17/2006  12:54 PM    <DIR>          share...                                                 True 
12/17/2006  12:29 PM    <DIR>          Sun...                                                   True 
01/21/2007  02:10 PM    <DIR>          TFTP-Root...                                             True 
01/09/2007  03:08 PM    <DIR>          Virtual Machines...                                      True 
01/17/2007  03:02 PM    <DIR>          WINDOWS...                                               True 
               7 File(s)        851,124 bytes...                                                True 
              13 Dir(s)  15,440,244,736 bytes free...                                           True 
              13 Dir(s)  15,440,244,736 bytes free...                                           True 
                                                                                                                        
                                                                                                                        
PS C:\>

The send-rshell cmdlet gives the exact same output:

PS C:\> send-rexec -server server -user user -password pass -command "C:\WINDOWS\system32\cmd exe /c dir c:\"        

For secure shell connections, NetCmdlets provides the send-ssh cmdlet. In the first send-ssh example below I just specify my ssh server, user, password, and a command (ls). It gives similar output:


PS C:\> send-ssh -server myserver -user myuser -password mypassword -command ls                                                
                                                                                                                        
Do you want to trust the certificate presented?                                                                         
The server has presented the key below.                                                                                 
Fingerprint: 59:52:C8:DB:C8:3A:FE:CF:9D:02:E3:31:3A:2C:11:E4                                                            
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y                                                              
                                                                                                                        
Text                                                                                            EOL 
----                                                                                            --- 
AssemblyInfo.vb                                                                                 True 
Documents                                                                                       True 
EmptyFolder                                                                                     True 
Lance                                                                                           True 
test.exe                                                                                        True 
test.ps1                                                                                        True 
test.txt                                                                                        True 
v6tests                                                                                         True 
v8tests                                                                                         True 

You'll notice there that the cmdlet stops me to show me the fingerprint presented by the server and make sure I want to accept this host key and continue on. I say yes and the objects are returned. Alternatively I can tell the send-ssh cmdlet the host key fingerprint to accept in the first place, so that it will not require user interaction:

                                                                                                                       
PS C:\> send-ssh -server myserver -user myuser -password mypass -command ls -sshaccept 59:52:C8:DB:C8:3A:...
3A:2C:11:E4                                                                                                             
                                                                                                                        
Text                                                                                             EOL 
----                                                                                             --- 
AssemblyInfo.vb                                                                                  True 
Documents                                                                                        True 
EmptyFolder                                                                                      True 
Lance                                                                                            True 
test.exe                                                                                         True 
test.ps1                                                                                         True 
test.txt                                                                                         True 
v6tests                                                                                          True 
v8tests                                                                                          True 
                                                                                                                        
PS C:\>


posted @ Wednesday, January 24, 2007 1:46 PM | Feedback (2) |


PowerShell console buffer to html


Adrian at soapyfrog posted a function recently for grabbing the contents of the PowerShell console buffer and pushing them out as html. I saved it and finally got around to using it today. Very useful, added to my profile. Thanks Adrian!

 


PS C:\> (get-nntp -server msnews.microsoft.com -newsgroup microsoft.public.windows.powershell -list 5) | sort From      
                                                                                                                        
                                                                                                                        
Number       : 7804                                                                                                     
Subject      : Re: More.com?? Quirk                                                                                     
From         : "/\\/\\o\\/\\/ [MVP]"                                                          
Date         : Tue, 23 Jan 2007 19:53:16 +0100                                                                          
Size         : 2610                                                                                                     
References   : <9eo6r256msnc3cvm527hm6202kiv9dkq1l@4ax.com> <ur6Gy2rPHHA.1280@TK2MSFTNGP04.phx.gbl> <eLQ04sxPHHA.4172@T 
               K2MSFTNGP03.phx.gbl>                                                                                     
MessageID    : <529B5064-584A-4B5E-A14C-831F2638B7A8@microsoft.com>                                                     
Otherheaders : Xref: TK2MSFTNGP01.phx.gbl microsoft.public.windows.powershell:7804                                      
                                                                                                                        
Number       : 7802                                                                                                     
Subject      : Re: More.com?? Quirk                                                                                     
From         : "Keith Hill [MVP]"                                           
Date         : Tue, 23 Jan 2007 11:20:53 -0700                                                                          
Size         : 1157                                                                                                     
References   : <9eo6r256msnc3cvm527hm6202kiv9dkq1l@4ax.com> <ur6Gy2rPHHA.1280@TK2MSFTNGP04.phx.gbl>                     
MessageID    : <eLQ04sxPHHA.4172@TK2MSFTNGP03.phx.gbl>                                                                  
Otherheaders : Xref: TK2MSFTNGP01.phx.gbl microsoft.public.windows.powershell:7802                                      
                                                                                                                        
Number       : 7800                                                                                                     
Subject      : Re: Executing from \\127.0.0.1\C$ doesn&apos;t work                                                           
From         : "Keith Hill [MVP]"                                           
Date         : Tue, 23 Jan 2007 10:24:44 -0700                                                                          
Size         : 3874                                                                                                     
References   : <#FvgnfnPHHA.320@TK2MSFTNGP06.phx.gbl>   <1169507373.493197.256260@a75g2000cwd.googlegroups.com>   <O8#c 
               9eoPHHA.1252@TK2MSFTNGP02.phx.gbl> <1169566384.862507.111920@a34g2000cwb.googlegroups.com>               
MessageID    : <#Fq$gNxPHHA.4376@TK2MSFTNGP02.phx.gbl>                                                                  
Otherheaders : Xref: TK2MSFTNGP01.phx.gbl microsoft.public.windows.powershell:7800                                      
                                                                                                                        
Number       : 7801                                                                                                     
Subject      : Re: Set alias with parameter                                                                             
From         : "Keith Hill [MVP]"                                            
Date         : Tue, 23 Jan 2007 11:18:49 -0700                                                                          
Size         : 2017                                                                                                     
References   : <j2uj93ykcp7d.jgcs1ej55she.dlg@40tude.net> <7fbcr2h9d6n3rv85tpl151b5qbvacc3cit@4ax.com>                  
MessageID    : <OrVavrxPHHA.1552@TK2MSFTNGP05.phx.gbl>                                                                  
Otherheaders : Xref: TK2MSFTNGP01.phx.gbl microsoft.public.windows.powershell:7801                                      
                                                                                                                        
Number       : 7803                                                                                                     
Subject      : Re: Set alias with parameter                                                                             
From         : Jeffery Hicks                                                                  
Date         : Tue, 23 Jan 2007 13:54:27 -0500                                                                          
Size         : 2589                                                                                                     
References   : <j2uj93ykcp7d.jgcs1ej55she.dlg@40tude.net> <7fbcr2h9d6n3rv85tpl151b5qbvacc3cit@4ax.com> <OrVavrxPHHA.155 
               2@TK2MSFTNGP05.phx.gbl>                                                                                  
MessageID    : <h3r6xdni0857$.mkvtwmftypyk.dlg@40tude.net>                                                              
Otherheaders : Xref: TK2MSFTNGP01.phx.gbl microsoft.public.windows.powershell:7803                                      
                                                                                                                        
                                                                                                                        
                                                                                                                        
PS C:\> get-bufferhtml | out-file sample.html                                                                           

posted @ Tuesday, January 23, 2007 2:19 PM | Feedback (3) |


Religious leaders will lead Blu-ray to greatness


I saw this post over at Wired: No Sex, Please; We're Sony. To sum it up, apparently the porn industry is going with HD-DVD and not Blu-ray. Interesting.

And, just for laughs: take a look at the 6th comment down:

"Blu-ray still has better technology AND don't be so rash into thinking Sony made a bad choice. Once this is advertised strongly enough, religious leaders will prefer and support Sony's Blu-ray format over HD-DVD due to 'moral' reasons. I believe Sony knows what the market share really is - conservative America. It's business and they are doing the smart thing. Eventually, once this boils over, the porn industry will follow Sony and Sony will give in."

Posted by: DLeon

<sarcasm>All this time I didn't realize that religious leaders and conservative America were our technological leaders! Thank God for the tubes!</sarcasm>

The stupidity of this comment reminds me of a recent xkcd which showcases the stupid things people say on the tubes:

posted @ Friday, January 12, 2007 5:29 PM | Feedback (0) |


iPhone developers: go to hell


Mark Pilgrim highlights "every developers's worst fears about the iPhone". In the article, Jobs chooses his words carefully to be sure. But really they're just nice ways to say "screw you", and "give us more money":

"You don't want your phone to be like a PC". Oh, thanks, I didn't realize. I guess I misunderstood what you were doing with the iPhone in the first place. Oh...or were those words just a sneaky (yet brilliant) way to draw comparisons to Pocket PC phones and Smartphones?

Technorati :

posted @ Friday, January 12, 2007 5:17 PM | Feedback (0) |


iPhone: get real


Several people have made comments to me about the newly announced Apple iPhone because they know how I felt about the iPod when it first came out ( see my post, "Convert Your Pocket PC to an IPod"). I must say, it looks really nice. The tech specs are impressive. But can we all please get real for a second here?

Really, its about damn time the iPhone happened.

Really, this is not a new idea. One thing about the iPhone announcement that annoyed me is the way Steve Jobs and Apple make it seem like the iPhone is some fabulous new idea. I think Jobs feels like he's the second coming of Christ because he has this iPhone in his pocket. On the other hand, somebody please give their marketing guys a raise. From what I understand there are three iPhones in existance: one in Jesus' Steve's pocket, and two in glass cases as if they were the Hope Diamond.

Really, this "revolutionary" new phone is still a long way away from pocket pc phones or even most smart phones. It is a giant (huge, immense, awesome) leap forward, don't get me wrong, and I have no doubt that there will be plenty of happy iPhone users. If I needed a new $500 phone I might be tempted to get one myself.

Really, if you're a software development geek, let me know how much fun it is writing software for your new iPhone.

Really, when you get ready to put music on your iPhone, I hope you don't mind being forced to install iTunes, and worse being forced to go through iTunes just to put music on your phone. Apple should team up with Sony to see if they could make transfer and licensing a little more difficult.

Really, are you going to switch to Cingular so that you can use this phone? Keep in mind the contract cancellation fees you'll likely have to pay to switch anytime soon, which will probably add another couple hundred bucks to the $500 or so bucks you'll pay for the iPhone.

Really, is the iPhone exclusive to Cingular? Cingular??? The same wireless company with the lowest customer satisfaction rating in the business (according to J.D. Power and Associates)? That must be a reeeeeeeeeeeeeeeeally bad customer satisfaction rating since we all know the wireless industry as a whole has abysmally poor customer satisfaction.

posted @ Wednesday, January 10, 2007 6:01 PM | Feedback (0) |


Regular Expressions on XKCD


xkcd.com

posted @ Wednesday, January 10, 2007 8:19 AM | Feedback (0) |


Using AmzWish on Geekswithblogs.net


  1. Visit the AmzWish home.
  2. Find your Amazon Wishlist Id, and paste it in the "My Wishlist Id" textbox on the AmzWish home page.
  3. Click the Generate HTML button and copy the selected code.
  4. Login to your GeeksWithBlogs admin page, and go to Options->Configure. Paste the html into the "Static News/Announcement" box.

Secret tips for geeks with blogs and Amazon Associates accounts:

In the generated HTML, you'll find a link to http://www.textbox1.com/apps/amzwish/AmazonWishlist.rst. By default, it contains wishlistid and maxitems querystring variables. You can add an associatesid querystring variable who's value is your amazon associates id. That way if somebody buys you something - you get paid. Hehe.

Full parameter list.

Technorati : , , , , , ,

posted @ Tuesday, January 09, 2007 3:00 PM | Feedback (1) |


Replace notepad in Vista


notepad.exe, *cough*sucks*cough*. But what do you expect? Its obviously supposed to be very limited, but its a little too limited for the year 2007 IMO. Fortunately Matt Berther showed me how to replace notepad on Vista with Notepad2, which rocks. Now when I view source in IE I actually get something I can read.

Technorati : , ,

posted @ Tuesday, January 09, 2007 2:59 PM | Feedback (1) |


/n software announced IP*Works! V8 beta!


112, count 'em, three new product announcements from the land of /n software today:

  1. IP*Works! V8 Beta - The must-have internet communications toolkit for software developers.
  2. IBiz FDMS Integrator v1 - For credit card processing through the First Data Merchant Services network.
  3. IBiz Paymentech Integrator v4 - For credit card processing through the Paymentech processor.

/n software news feed: subscribe.

Technorati : , , , , , ,

posted @ Monday, January 08, 2007 1:46 PM | Feedback (2) |


AmzWish is Amazon's ECS App of the Week


For the last few weeks, AmzWish (digg it), my little widget that displays your Amazon wishlist and lets people buy things for you while letting you make money from their purchases at the same time, has been one of the featured widgets at Widgetbox.

Now, AmzWish is Amazon's ECS App of the week! Thanks to Amazon ECS and RSSBus, AmzWish was created in just a few minutes by doing nothing by combining a few RSSBus calls to RSSBus' AmazonOps with simple HTML.

Technorati : , , , , ,

posted @ Monday, January 08, 2007 12:31 PM | Feedback (1) |


Sony: NOT a software company


Sony, let's face it, you're not a software company. We all loved your VCR's back in the day...but the software on them sucked. We all love your DVD players, but the software on them sucked for years. Then at some point presumably you hired a software usability guy and things slowly improved. Sort of, at least. I don't want to get out of control with compliments about it though, because it still sucks.

I'm pretty sure that Sony knows they're not a software company. We all know where their expertise lies. So, with that in mind, I have a simple question. Why is it so freaking hard to find an mp3 player (not just Sony, but any brand) that doesn't suck?

The intelligent side of my brain said to me, "Woah woah woah, don't buy that Sony mp3 player...don't you remember the whole rootkit fiasko?". But...the stronger, more childlike and excitable fun side of my brain said, "Ah, they suffered enough embarassment, this one is probably a good product. After all, Sony used to be a respected name." So...I took the plunge...into a big cesspool of stinky Sony sewage.

All I ask for is an mp3 player that:
1. Is light, so I can run with it 2. Is reliable, so it doesn't break down after 2 months 3. Respects my privacy, and doesn't install viruses on my computer 4. Is smart, so I don't to have to install 8000 software applications on my PC just to be able to put songs on it. 5. Plays mp3-s.

Sony now has strugged over the hill to get past criterion number 3. Unfortunately they haven't figured out number 4 yet, apparently. Even more incredibly, this product didn't even give me number 5. Can you believe that? Yes, you read correctly. This is an mp3 player that doesn't play mp3 files. Yes, you can give an mp3 file to their required music player and transfer it to the mp3 player device itself, but in that process they transform the mp3 into another format. So I can't just manually copy mp3's onto my device. Ugh! Get real!

To Sony: I already have a media player application, thank you very much. I don't need yours. I don't want yours. But you, in your infinite wisdom, have decided to force me to. Well, at least I don't have your widespread rootkit crap hiding on my machine. As for forcing me to use your crappy music player on my desktop just so I can use your mp3 players when I run - screw you. Thats one more Sony product back on the shelf.

posted @ Sunday, January 07, 2007 3:57 PM | Feedback (1) |