GitHub Git Repo

Another way to save a PowerShell script online is to save it in a GitHub Git Repo. In this example, I have created a GitHub Repo at this link

In this Repo, I have a script called Test-PSCloudScriptGit.ps1. The link below is not the Raw link, so I'll need to get that

Get the Raw URL

For a file in a GitHub Repo, pressing the Raw button will open a new webpage that contains the Raw URL that you can link to

If you have the OSD PowerShell Module 22.1.15+ then you can use the Get-GithubRawUrl function to resolve the proper Raw URL for you

Execution

Execution is simple. Perform an Invoke-RestMethod on the Raw URL and then perform an Invoke-Expression on the Raw URL content. The example below shows a few different ways you can do this and tests the function that was contained in the Script

OSDeploy is sponsored by Recast Softwarearrow-up-right and their Systems Management Tools

Sponsored by Recast Software

Last updated