Reputation: 111
I have a Linux box running Ubuntu Server 16.04 with Powershell on it, from the Linux terminal if I run:
sudo powershell (Invoke-Webrequest http://ipinfo.io/json | ConvertFrom-Json).ip
I get an error saying it is formatted incorrectly and expected a ')'
at the end. if I remove the ()
and just try to convert from JSON it throws a could not find the command ConvertFrom-Json
.
That said if I actually go into powershell and run the original command it works perfectly.
Any help would be greatly appreciated.
Upvotes: 2
Views: 1990
Reputation: 111
I figured it out need to wrap the command like this
sudo powershell '(Invoke-Webrequest http://ipinfo.io/json | ConvertFrom-Json).ip'
thank you for your help!
Upvotes: 3
Reputation: 10799
I haven't used PowerShell on Linux (yet), but on Windows you'd need
powershell -Command { (Invoke-WebRequest http://ipinfo.io/json | ConvertFrom-JSON).ip }
Upvotes: 2