Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to "Download" as a PowerShell verb?

I've got a PowerShell function Download-File, which uses WebClient.DownloadFile -- hence the name.

When I attempt to turn my .ps1 script into a .psm1 module, PowerShell warns me that "Download" is not in the list of recommended verbs.

What's a good alternative? Get- seems to be about getting properties, rather than contents (apart from Get-Content, oddly). Receive- seems a bit too passive for my liking (i.e. the script blocks until the information is sent) -- which doesn't fit well.

Ideas?

like image 746
Roger Lipscombe Avatar asked May 25 '12 09:05

Roger Lipscombe


People also ask

What is a PowerShell verb?

PowerShell verbs are assigned to a group based on their most common use. The groups are designed to make the verbs easy to find and compare, not to restrict their use. You can use any approved verb for any type of command. Each PowerShell verb is assigned to one of the following groups.

How do you obtain a list of approved verbs in PowerShell?

You may get a complete list of verbs using the Get-Verb cmdlet.

What is Commandlets in PowerShell?

A cmdlet is a lightweight command that is used in the PowerShell environment. The PowerShell runtime invokes these cmdlets within the context of automation scripts that are provided at the command line. The PowerShell runtime also invokes them programmatically through PowerShell APIs.

How do I get PowerShell Commandlets?

Get-Command gets the commands from PowerShell modules and commands that were imported from other sessions. To get only commands that have been imported into the current session, use the ListImported parameter. Without parameters, Get-Command gets all of the cmdlets, functions, and aliases installed on the computer.

How to download a file with PowerShell?

A file can be downloaded with Microsoft PowerShell via the Invoke-WebRequest command. The PowerShell offers three aliases of Invoke-WebRequest i.e., iwr, curl, and wget. This post demonstrates various methods to download a file using PowerShell.

How to download multiple files at the same time using PowerShell?

A faster and better way is to use the Start-BitsTransfer cmdlet in PowerShell. This cmdlet allows you to queue files, set priority (useful for bandwidth limitation), can run in the background and download multiple files asynchronous.

What version of PowerShell do I need for Windows 10?

Windows PowerShell 5.1 or PowerShell 7.1 (recommended). Windows 10 already includes Windows PowerShell 5.1. A web site that hosts the files to download. For non-authenticated file downloads, consider using the Tele2 Speedtest site, which is free.

What are the best PowerShell cmdlets for downloading links?

Perhaps the most used cmdlet in this article, Invoke-WebRequest, can download HTTP, HTTPS, and FTP links. Whether the source location requires users to log in, the Invoke-WebRequest cmdlet can handle requests with credentials as well.


2 Answers

For me, 'Get' is the most natural verb. It gets everthing, not just properties. For the noun I would use something like 'WebFile', you can easily guess what you get and where it is coming from.

like image 150
Shay Levy Avatar answered Oct 19 '22 14:10

Shay Levy


Wouldn't this work:

 Start-Download -Url http://blah/

Or use Invoke-Download, as per the recommendations for synchronous operations. Start is for asynchronous.

like image 29
manojlds Avatar answered Oct 19 '22 14:10

manojlds