Skip to content

Instantly share code, notes, and snippets.

@Novack
Last active April 15, 2024 12:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Novack/2f93edb5636efcb535085ad19df69511 to your computer and use it in GitHub Desktop.
Save Novack/2f93edb5636efcb535085ad19df69511 to your computer and use it in GitHub Desktop.
PowerShell script for updating and deploying the Playfab cloudscript from command line.
# Project and Dev Info. Fill it!
$devPlayfabId = ""
$titleId = ""
$secretKey = ""
# Concats all .js files on directory. This script is expected to be placed on the directory containing the javascript files. Otherwise, add the path(s).
$scriptContent = Get-Content *.js | out-string
# Script content as Playfab expects it.
$file = @{
Filename = "revision.js"
FileContents = $scriptContent
}
# Request Data
$url = "https://" + $titleId + ".playfabapi.com/Admin/UpdateCloudScript"
$headers = @{ "X-SecretKey" = $secretKey;}
$body = @{
DeveloperPlayFabId = $devPlayfabId
Publish = "true"
Files = @( $file )
} | ConvertTo-Json
# Execute Rquest.
$R = Invoke-WebRequest -URI $url -Method "Post" -ContentType "application/json" -Headers $headers -Body $body
"Response Status: " + $R.StatusCode + " - " + $R.StatusDescription + "\n" + $R.Content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment