Month: December 2009

PowerTask – Shortcut to all your favorite PowerShell programs

This is my last post for this year and I am excited about this new application — PowerTask — I am writing as an exercise while learning C# / .NET programming. I use quite a few PowerShell related programs for my script development, testing and learning purpose. They are way too many and what I currently do is pin them to taskbar for quick access. However, as I install more and more, it is hard to manage all of them using the taskbar icons. This is a set of PS related icons I have on my taskbar.   So, I decided to simplify access to these programs and still don’t lose the taskbar real estate.  One best way to achieve this is to consolidate all these programs in to a jump list and that is what I did. I wrote a simple .NET application that looks for all PowerShell related programs and then adds them to the jumplist for this .NET application. All I need to do is pin this new tool to the taskbar. …

Bye bye 2009

This year started — for me — with the birth of my son, Kaustubh. He is now 11 months old, started to walk and talk. It is a pleasure watching the kid grow. While being busy with him all the time, I did quite a things on professional front too. BITPro user community I became an active member of BITPro user community and started contributing at user group meets and other events. In total, I delivered thse four sessions. Introduction to Windows Server 2008 R2 at Windows 7 install fest Windows Server 2008 R2 – A technical overview at Microsoft TechEd on the road, Bangalore Introduction to Virtual Desktop Infrastructure in R2 SharePoint 2010 beta 2 Technical overview And, yes — I was the BITPro community star for 2009. I am looking forward to increase my contributions to BITPro community. Blogging / Writing First, I changed the look of my blog some N number of times and ended up purchasing Thesis theme. I am sure I won’t change this now since I paid money for this 🙂 …

Handling System.Net.WebRequest GetResponse() timeout in PowerShell

In the latest release of BITS file transfer power pack, I added a new feature called import URL. This features takes a web URL as input as returns a list of “possible” download links available on the web page. This should take care of URL redirects too. For example, Script Center page of this blog has a few download links that are not direct links to “real” files. Instead, you get redirected to the real file when you click on one of those links. I came across a nice little script — to find the URL redirects — on James O’Neill’s blog. I had implemented the this code with a few changes Function Get-trueURL {                Param ([parameter(ValueFromPipeLine= $true, mandatory=$true)]$URL )     $req = [System.Net.WebRequest]::Create($url)                 $req.AllowAutoRedirect=$false     $req.Method=”GET”     if ($bitsProxyCred) {         $req.Proxy.Credentials = $bitsProxyCred     }     $resp=$req.GetResponse()     If ($resp.StatusCode -eq “Found” )        {            Return $resp.GetResponseHeader(“Location”)         }                else        {           return $resp.responseURI        } } However, I kept on hitting a Timeout issue at $resp=$req.GetResponse(). This code works fine …

BITS File Transfer Power Pack 1.0.0.10 released

I just made an updated release of BITS file transfer PowerPack. In this release, I re-organized the node tree and added a few new features. Since the node tree is re-orgnized, you will see issues when performing auto update of this powerpack. Instead, you can remove the old version of this powerpack and import the update. Here are the changes to node tree Node Tree I have added List Active BITS Jobs – All users option to enable taking ownership of other user’s job. This is possible only if you have administrator previleges.   Start File transfer has been renamed to Start Web downloads and this option is meant only for starting web downloads. You will see an error if you try to perform local file transfers using this.     Import URL feature is a completely new feature. @Dmitry asked me about this here. Not just that, he also provided a starting point for that here. This new option takes a web URL as input and gets back with all the “possible” downloads available …

Programming Windows 7 taskbar using Windows API code pack and PowerShell

Windows® API Code Pack for Microsoft® .NET Framework provides a source code library that can be used to access some features of Windows 7 and Windows Vista from managed code. These Windows features are not available to developers today in the .NET Framework. Windows 7 Taskbar Jump Lists, Icon Overlay, Progress Bar, Tabbed Thumbnails, and Thumbnail Toolbars Windows Shell Windows 7 Libraries Windows Shell Search API support Explorer Browser Control A hierarchy of Shell Namespace entities Windows Shell property system Drag and Drop for Shell Objects Windows Vista and Windows 7 Common File Dialogs, including custom controls Known Folders and non-file system containers DirectX Direct3D 11.0, Direct3D 10.1/10.0, DXGI 1.0/1.1, Direct2D 1.0, DirectWrite, Windows Imaging Component (WIC) APIs Windows Vista and Windows 7 Task Dialogs Sensor Platform APIs Extended Linguistic Services APIs Power Management APIs Application Restart and Recovery APIs Network List Manager APIs Command Link control and System defined Shell icons That is quite a bit. Being able to access these features from .NET makes it the best candidate for PowerShell too. When I …

Send Twitter updates with Geo tags using PowerShell

Update: I fixed an issue with $webClient.UploadString usage and added ByPass-Proxy to make sure that this script works with proxy authentication. Sending Twitter updates using PowerShell isn’t a new thing. There is a Twitter Powerpack too. Twitter recently introduced geotags feature. Here is how they describe this feature. Twitter’s Geotagging feature allows users who opt-in to the service to selectively Geotag their tweets with their exact location and provide more context to users about their surroundings. This great new functionality allows you to join into a local conversation and annotate the world around you as you travel from one place to another. But geotagging isn’t available when you Tweet using Twitter’s web interface. You need to use a client software that supports Geotagging API when sending status updates. I use TweetDeck as my Twitter client. However, TweetDeck does not yet support Geo tags while sending tweets. It can — however — recognize if incoming tweets have the geotags. Now, in this post, I will show you how to combine Google Geo-coding API with Twitter API to send Twitter …

Update: Internet explorer plugin to complement BITS File Transfer PowerPack

I got a few questions around the IE Plugin for BITS based downloads. One of them was what Wayne mentioned here. So, I decided write a bit around the issue Wayne is facing. Like I mentioned in the reply there, it could be potentially because of two reasons. 1. You are using x64 OS Windows x64 OS has got two versions of IE — both 32bit and 64bit. The 64bit one is named Internet Explorer – 64bit. So, if you copy the IE plugin files to C:\windows\System32 and use 32bit IE, you won’t be able to run this plugin. You need to copy these files to C:\windows\SysWow64 too. So, the safe method would be to extract the files to both the locations. 2. You have not enabled PowerShell script execution Since this plugin uses .PS1 script, you need to enable PowerShell script execution. To do this, run the following cmdlet at PowerShell prompt Set-ExecutionPolicy -executionPolicy Unrestricted or Set-ExecutionPolicy -executionPolicy ByPass If you have taken care of these two, you should not have any issues running …

Using PowerShell to detect if a web URI requires proxy authentication

Couple of days back @Dmitry reported an issue with my BITS file transfer powerpack and the issue is that it fails to transfer files when access to the source URL requires proxy authentication. This was a known issue and I provided “Set-ProxyCredential” action as a work around. However — this issue requires a fix. The challenge here was to determine if access to a given source URL requires proxy authentication or not. One way to achieve that is to first find out if the access to URL requires proxy server itself or not. This is the key to fix the issue with BITS powerpack. Here is how we can determine if web URI access requires proxy server authentication or not. 1. Create an instance of System.Net.WebClient namespace $webClient = New-Object System.Net.WebClient 2. Use the IsBypassed() method of $webClient.Proxy $webClient.Proxy.IsBypassed($url) This returns true if proxy server is not required and false otherwise. So, the quick fix to the proxy issue was to use the IsBypassed() method and prompt for proxy credentials if the method returns false. That is it. So, if we put it all …