Invoke-WebRequest alterative in PowerShell v5

1

1

In previous versions of PowerShell, I used Invoke-WebRequest to download files from HTTP. While using Server 2016 Nano with PowerShell 5.1, I found out that this command has been removed!

How am I supposed to download files from the internet in a virtually PowerShell only OS? Have I missed something? Why did Microsoft remove this?

I understand that I can use .NET commands, but that's a lot more effort than one command.

$PSVersionTable:

    Name                           Value
    ----                           -----
    PSEdition                      Core
    PSVersion                      5.1.14284.1000
    WSManStackVersion              3.0
    BuildVersion                   10.0.14284.1000
    SerializationVersion           1.1.0.1
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
    PSRemotingProtocolVersion      2.3
    CLRVersion                     4.0.30319.34011

mt025

Posted 2016-08-12T18:51:02.810

Reputation: 2 392

Answers

2

Invoke-WebRequest works fine in PowerShell 5.1.14393.0 on Windows 10 Pro.

PowerShell on a Nano Server is not the same as a Desktop/Full Server version, it's the PowerShell Core version, not the Desktop version. So certain commands/abilities will be missing when using a Nano Server.

From Microsoft's TechNet - "PowerShell on Nano Server":

Starting with version 5.1, PowerShell is available in different editions which denote varying feature sets and platform compatibility.

  • Desktop Edition: Built on .NET Framework and provides compatibility with scripts and modules targeting versions of PowerShell running on full footprint editions of Windows such as Server Core and Windows Desktop.
  • Core Edition: Built on .NET Core and provides compatibility with scripts and modules targeting versions of PowerShell running on reduced footprint editions of Windows such as Nano Server and Windows IoT.

And under "Windows PowerShell features not available in Nano Server" in the same article:

  • Web-related cmdlets { Invoke-WebRequest, Invoke-RestMethod, New-WebServiceProxy, Send-MailMessage, ConvertTo-Html }

Ƭᴇcʜιᴇ007

Posted 2016-08-12T18:51:02.810

Reputation: 103 763

Thanks. So there isn't a short way to do this I presume? I feel it would be a important feature in nano server. – mt025 – 2016-08-12T19:05:36.463