GitHub Gist
22.1.16
An easy way to get a PowerShell script online is by saving it in a GitHub Gist
In this example, I'll create and save a Public Gist. You can save it as a Private Gist, all that matters is that anyone with the URL has access, so don't consider it an option for saving Secure content like passwords
Once it is saved you should have the Git Editor URL
Gist Editing in Visual Studio Code
There are several Visual Studio Code extensions that can help you manage your GitHub gists, but one that really stands out is GistPad. It will be much easier to edit in VSCode with this and the PowerShell extension. You can add this from the Marketplace at this link
You will need to sign into your GitHub account and authorize Visual Studio Code to access GitHub
Getting the Gist Raw URL
You need to keep in mind that the URL shown for your Gist is one for the Gist Editor with your script in it, so you need to get the Raw URL by pressing the Raw button
Gist Raw Commit URL
After pressing the Raw button on the Gist Editor page, you are redirected to the Raw Commit page. This URL for this page contains a commit string which means that it is static and the content will not reflect future changes that are made in the Gist Editor
Gist Raw URL (Latest)
To ensure you always have the latest content for your script, you need to remove the Commit string from the URL, so you will need to format your URL like this example. This is the URL you need to use for your PSCloudScript
Get-GithubRawUrl
This function is part of the OSD PowerShell Module (version 22.1.15+) and it will return a GitHub Gist Raw URL for you automatically
If your Gist has multiple files, those will be returned as well
I could have started with this function, but I to make sure you understand how to get the proper URL
Execute the Gist
Now that you have the proper Gist Raw URL, you can use execute the script using any of the following commands
Sponsor
OSDeploy is sponsored by Recast Software and their Systems Management Tools
Last updated