Skip to content

Instantly share code, notes, and snippets.

@totomz
Last active August 29, 2015 14:12
Show Gist options
  • Save totomz/4d033fa1b991504a4e31 to your computer and use it in GitHub Desktop.
Save totomz/4d033fa1b991504a4e31 to your computer and use it in GitHub Desktop.
[GCE] Download and execute a powershell startup script from Google Cloud Storage in Google Cloud Engine
$gscript = "test-script/startup.ps1";Invoke-Expression $(Invoke-RestMethod -Uri $("https://storage-download.googleapis.com/"+$gscript+"?access_token=" + $($(Invoke-RestMethod -Uri "http://metadata/computeMetadata/v1/instance/service-accounts/default/token" -Headers @{"Metadata-Flavor"="Google"}).access_token)));
@totomz
Copy link
Author

totomz commented Dec 23, 2014

Upload your .ps1 script, and add this gist as windows-startup-script-ps1 metadata. Edit $gcsript with /<script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment