2

So I made a Confluence macro which executes a curl command in cmd.exe and gives me back a JSONObject as a string. The problem is, that he machine where our Confluence is doesn't recognize the curl command and the admins don't want to install the necessary files to make it work, so they told me to try and use a Powershell command.

The curl command is this: curl -u {user}:{pass} {url}. I need an equivalent for this in powershell 2.0.

0

1 Answer 1

6

Since you're using v2, you'll want to use System.Net.WebClient (v3 has invoke-webrequest which makes this much simpler).

$webclient = new-object system.net.webclient;
$User = "user";
$PWord = ConvertTo-SecureString –String "P@sSwOrd" –AsPlainText -Force
$Credential = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $User, $PWord;
$webclient.Credentials = $Credential;
$webclient.DownloadString('url');
Sign up to request clarification or add additional context in comments.

1 Comment

Yes, I've seen the v3 command which was 1000x easier to understand and use, but... Thanks for the v2 variant though :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.