Divide by zero
 Monday, March 10, 2008
Windows Vista grievance

I just tried to install Microsoft PowerShell on a Windows Vista Home Basic installation. OK, so it is a power application, and on a home machine, but there are some scripts I really wanted to run here. But guess what, It wont install on Vista home basic. I checked the system requirements at the PowerShell home page and sure enough, no mention of Vista home basic.

But what I think is lousy about this is that when you go to the Choose an edition page of the Vista site, it doesn't say anywhere that you cannot run PowerShell on Vista Basic. I find this a little sneaky. I can understand their logic behind it, perhaps if I want to use a power application, I shouldn't run it on a home basic edition installation, however, lets be honest up front about it.

Well, lets play the game and upgrade to Ultimate or even Home Premium. That is a fairly simple option as the control panel explains, in fact it states You can learn more about editions of Windows Vista, or you can upgrade immediately. How cool is that! All I have to do is click the button, purchase my upgrade, and I will have a shiny new bells and whistles Vista edition, and now I can run PowerShell.

Unfortunately it's not that simple. The upgrade options fire up a Windows anytimeUpgrade web page to begin the process. Here I can select my billing location, and proceed. Unfortunately the only options are to bill to the United States, or Canada. Here in Australia we actually have the internet and are capable of online shopping. Why is it so difficult to provide an upgrade option online? So I can't really upgrade instantly as advertised.

It looks like I will have to put this off unless I feel like going to a shop to upgrade. I will be upgrading, but due to the experiences with various versions of Vista, I will be upgrading to Windows XP Service Pack 2.


Monday, March 10, 2008 9:28:08 PM (AUS Eastern Standard Time, UTC+10:00)   #    Comments [0]  PowerShell | Vista
link to del.icio.us link to reddit link to StumbleUpon link to Facebook Bookmark to Google
 Monday, December 17, 2007
Handy PowerShell commands

These are some PowerShell commands I have created that I find really handy. Some of the first ones are just helper methods for aiding more useful scripts. These are stored in my PowerShell profile located at:
%userprofile%\my documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1.  There is a special variable to point to this file, called $profile. It is easy to edit my PowerShell profile by typing: notepad $profile which will open up the profile in notepad. I actually use NotePad2 which I have renamed to n2 to make it easy to use from the run prompt, command line, or PowerShell. To use NotePad2, I type n2 $profile.

To make it easier later, I have set an alias to run Internet Explorer. I don’t use this alias in PowerShell usually, but it does get used in some cmdlet’s later. I call the alias ie

set-alias ie "${env:programfiles}\Internet Explorer\iexplore.exe".

Now the cmdlet I use a lot. This one just retrieves the latest item from a podcast feed, and plays it in the default Internet Explorer media player. Tjis cmdlet looks like this:

function play-Podcast($url) {

                ie ([xml](new-object net.webclient).DownloadString($url)).rss.channel.item[0].enclosure.url

}

This takes an URL and retrieves the contents as a string, turns it into an XML object, then performs the XPath rss/channel/item[0]/enclosure/url. It now passes that to the Internet Explorer alias set earlier, and the effect is to play the latest podcast entry.

My colleague David laughs at me for this, he thinks I should just use a podcast client, or just use a bookmark in a browser, but I find this handy. Now I can set other cmdlets so I can hear my favourite podcasts easily. I like a security podcast by Patrick Gray called Risky Business.  The cmdlet I have created is:

function risky-Business() {

                play-Podcast http://www.itradio.com.au/security/?feed=rss2

}

One other cmdlet that is handy is to save the podcast for offline listening. To achieve this I have a cmdlet called persist-Podcast , which makes use of another helper cmdlet called persist-Url. This takes a URL and a file name, and saves the resource to that file. Persist-Podacst just calls this cmdlet with the URL of the feed item. First is persist-Url:

function persist-Url($url, $file) {

                (new-object net.webclient).DownloadFile($url, $file)

}

This is straightforward, using the methods used earlier, in addition to the DownloadFile method of the webclient object. Now, to pass the URL of the podcast enclosure to this method, we get:

function persist-Podcast($url, $file) {

([xml](new-object net.webclient).DownloadString($url)).rss.channel.item[0].enclosure.url

                persist-Url ([xml](new-object net.webclient).DownloadString($url)).rss.channel.item[0].enclosure.url  $file

}

And to call this, the following can be entered into PowerShell:

persist-Podcast http://www.itradio.com.au/security/ m:\riskybusiness.mp3

 


Monday, December 17, 2007 8:11:24 AM (AUS Eastern Standard Time, UTC+10:00)   #    Comments [1]  PowerShell
link to del.icio.us link to reddit link to StumbleUpon link to Facebook Bookmark to Google