Finding a URL For File Transfer Cmdlets

Finding a URL For File Transfer Cmdlets

  • Comments 3

I just posted a blog about our new File Transfer Cmdlets in which I artfully dodged a difficult question:  How do you get the URL to do the file transfer?  Sometimes you are going to have it but other times you’ll go to a website and it can be bloody impossible to find the URL that you need to download.  That was the case with the example I used.  Let me provide it.  Navigate HERE and tell me if you can find the URLs to download the kits? (If you find out how – let me know – I’d REALLY appreciate it.)

My new motto is Experiment, Enjoy, Engage (which means share).  Luckily, we have a great community of people already doing this.  One of them is Robbie Foust.  Robbie recently wrote a Packet Sniffer For PowerShell.  I picked it up over the holidays and thought it was wicked cool but I wasn’t sure when I would use it.  Well…. I didn’t have to wait to long for that question to be answered. 

Here is how I got the URL for to transfer the file.  I downloaded Robbie’s script from HERE.  I ran Get-Packet and it went displayed everything and caused a beep-storm on my PC.  I thought about a minute and came up with the one-liner below.  I navigated to the download page in my browser, ran the one-liner, clicked the download button, captured the packet, hit ESC to stop Get-packet and then stopped the file transfer.  Here is what it looked like:

PS> Get-Packet |where {$_.data -match "download"}
Using IPv4 Address: 192.168.1.195

Press ESC to stop the packet sniffer ...

Destination : 192.168.1.195
Source      : 207.46.19.254
Version     : 4
Protocol    : TCP
Sequence    : 3205106908
Window      : 65535
DestPort    : 57728
SourcePort  : 80
Flags       : {PSH, ACK}
Data        : HTTP/1.1 302 Found
              Cache-Control: private
              Content-Type: text/html; charset=utf-8
              Location:
http://download.microsoft.com/download/D/0/E/D0E6D2C1
              -2593-4017-B26D-7375BC9263D5/PowerShell_Setup_amd64.msi
              Server: Microsoft-IIS/7.0
              X-AspNet-Version: 2.0.50727
              P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TA
              I TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"
              X-Powered-By: ASP.NET
              Date: Sun, 11 Jan 2009 18:37:18 GMT
              Content-Length: 225

              <html><head><title>Object moved</title></head><body>
              <h2>Object moved to <a href="
http://download.microsoft.com/down
              load/D/0/E/D0E6D2C1-2593-4017-B26D-7375BC9263D5/PowerShell_Setu
              p_amd64.msi">here</a>.</h2>
              </body></html>

Time        : 1/11/2009 10:36:44 AM

Is that sweet or what?  10,000 thanks Robbie – you moved the ball forward.

Experiment, Enjoy, Engage!

Jeffrey Snover [MSFT]
Windows Management Partner Architect
Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

Leave a Comment
  • Please add 1 and 8 and type the answer here:
  • Post
  • Glad you like the script!  I had a lot of fun writing it!  It definitely increased my knowledge of Powershell and .NET.

    - Robbie

  • In this particular case finding URL can be  fairly easy. If you view HTML source of this page you will see something that looks like this in Download button script: http%3a%2f%2fdownload.microsoft.com%2fdownload%2fD%2f0%2fE%2fD0E6D2C1-2593-4017-B26D-7375BC9263D5%2fPowerShell_Setup_x86.msi. If you unescape it you will get the link: http://download.microsoft.com/download/D/0/E/D0E6D2C1-2593-4017-B26D-7375BC9263D5/PowerShell_Setup_x86.msi

    However, in many cases it will be much harder to do since the button can call some obscure javascript method and to find the actual script you will need to do a complete Web Page first and then go looking for the script text through half megabyte of HTML code.

    For these occasions, packet sniffers like Get-Packet are truly invaluable.

    Vladimir Averkin

    Windows PowerShell team

  • As someone who does a far amount of downloading of stuff – especially technical documents etc I was interested

Page 1 of 1 (3 items)