January 11th, 2009

Finding a URL For File Transfer Cmdlets

PowerShell Team
PowerShell Team

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

Author

PowerShell Team
PowerShell Team

PowerShell is a task-based command-line shell and scripting language built on .NET. PowerShell helps system administrators and power-users rapidly automate tasks that manage operating systems (Linux, macOS, and Windows) and processes.

0 comments

Discussion are closed.