web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :

PowerShell Snippets: Use Curl

Ian Grieve Profile Picture Ian Grieve 22,784
PowerShellThis post is part of the series on PowerShell Snippets.

The following PowerShell command will execute curl passing in the authorization token and json parameters defined above the curl statement.

The main difference between this and curl on a normal command line is that you need to do curl.exe which is a built in alias for the Invoke-WebRequest cmdlet:

$ghAuthorizationToken = "ghp_authorizationtoken"
$ghUser = "username"
$ghRepo = "repository name"

$json = "
{ \`"tag_name\`": \`"$ghTag\`", \`"target_commitish\`": \`"main\`", \`"name\`": \`"$ghTag\`", \`"body\`": \`"$ghTag release\`", \`"draft\`" :false, \`"prerelease\`": false, \`"generate_release_notes\`": false }
"

curl.exe -X POST -H "Accept: application/vnd.github+json" -H "Authorization: token $ghAuthorizationToken" https://api.github.com/repos/$ghUser/$ghRepo/releases -d "$json"

The variables at the top need to be changed to those for your GitHub account and repository.

Read original post PowerShell Snippets: Use Curl at azurecurve|Ramblings of an IT Professional


This was originally posted here.

Comments

*This post is locked for comments