Join Mike Pfeiffer for an in-depth discussion in this video Downloading files from the Internet, part of Up and Running with Server Core for Windows Server 2012 R2.
- Downloading a file from a Server Core machine poses a challenge because there's no Internet Explorer browser running on the machine. You could download it on your workstation and then copy the file over the network, but what if you needed to initiate a file from the core server itself? Well, luckily, there is a PowerShell cmdlet for that. We have a set of cmdlets called the BITS Transfer cmdlets. So let's run Get-Command and we'll do a *-bits transfer. And you'll see here that we have the Start-BitsTransfer cmdlet that'll initiate a download. We can use the Get-BitsTransfer cmdlet to check the status of the download.
We can suspend it, we can remove them. It's a pretty powerful set of cmdlets. Let's see how we can kick off a download. So I'm going to do a Start-BitsTransfer and I'm going to specify a source here. And in this case, I'm going to paste in a URL for a Microsoft hotfix. I'm going to specify a destination and I'm going to specify the local C drive, just the root of the C drive. And I'm going to hit enter here. And you'll see that this about a 50 megabyte file and I've got a pretty good Internet connection so it downloads it pretty fast.
And now if I run dir, you can see that the last file on the list there is that hotfix for Microsoft. So let's remove that file real quick. I'm going to do a dir; I'm going to use a wildcard just searching for files with KB in them. So there's our file. We'll use the pipe line here. So we'll up-arrow to recall our previous command and we'll pipe that over to Remove-Item. And that will simply delete the item easily. We run dir again and you can see that the download is now gone. So let's clear the screen. Let's do another BITS Transfer.
Let's specify the same source and the same destination. This time I'm going to use a new switch parameter called Asynchronous. And what this will do is kick off the download in the background and it won't tie up my current session. I'll get my command prompt back and I'll be able to continue do work. So if I'm downloading a file that might be two, four, eight gigabytes in size, I don't have to sit there and wait for it to stop before I can continue working. So this is what the Asynchronous switch will do for you. So let's kick that off and you can see that it kicked off a background job.
I can run Get-BitsTransfer and we can see that it's currently in a transferring state. I can even pipe that over to Suspend-BitsTransfer. And if we run the get command again... you can see that the job state is Suspended. Now if we do a dir, you can see that the file is not yet there. So we're kind of in a half way point here. So I could resume the bits transfer and let that file finish downloading. So let's up-arrow back to our previous command and modify it a bit. I'm going to pull across all the bits transfers and I'm going to resume.
And we only have one obviously so this is easy to do. Now if we run dir, you can see that the file is there. The download is completed. So this is something that can be done interactively on the server core itself but when we get into Remote PowerShell this is something you'll be able to initiate from a work station, over the network using Remote PowerShell.
- Understanding the benefits of Server Cover
- Installing Server Core
- Adjusting server settings
- Configuring the Windows firewall
- Managing server roles and features
- Working with files, folders, users, and groups
- Managing services remotely with PowerShell or graphical tools
- Installing updates