I’ve currently been working on a PowerShell script to build a virtual server using DigitalOcean excellent RESTful API. So far this has gone extremely well and I have been impressed with both PowerShell and DigitalOcean’s API. Today however I tried running on another machine (an important part of development) only to find it doesn’t work. The first error that appears is:
The term ‘Invoke-WebRequest’ is not recognized as the name of a cmdlet, function, script file, or operable progr
am. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:18
+ Invoke-WebRequest <<<<
+ CategoryInfo : ObjectNotFound: (Invoke-WebRequest:String) , CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
In simple terms it’s saying it can’t find the ‘Invoke-WebRequest’ cmdlet. This should be a built-in cmdlet in PowerShell, so off I went to TechNet to find the details of the cmdlet –
The key bit of information was this line:
This cmdlet was introduced in Windows PowerShell 3.0.
The other way is at the top of such documents on TechNet it defaults to the most recent version of the, in this case, cmdlet and next to it gives you the option select a older version, clicking it reveals previous versions and does indeed confirm the above statement that it was not present in any version of PowerShell prior to 3.0.
Next question, is PowerShell 4.0 installed? Well for Windows 8.1 and Windows Server 2012 R2 it’s built-in, you can check by running (in PowerShell)
sure enough, the other machine (which is Windows 7 Enterprise x64) returns
Major Minor Build Revision
—– —– —– ——–
2 0 -1 -1
For help installing PowerShell 4.0 go to: http://social.technet.microsoft.com/wiki/contents/articles/21016.how-to-install-windows-powershell-4-0.aspx