Comment on page
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
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 youPS C:\> Get-GithubRawUrl https://github.com/OSDeploy/PSCloudScript/blob/main/Test-PSCloudScriptGit.ps1
https://raw.githubusercontent.com/OSDeploy/PSCloudScript/main/Test-PSCloudScriptGit.ps1
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


Home
Recast Software
Sponsored by Recast Software
Last modified 1yr ago