Have you ever needed to download code or a repository from Github, but didn’t want to download and install Git on a machine, create an SSH key, etc. If so, I have something that you may like.
You can find the entire function here: https://github.com/MSAdministrator/GetGithubRepository
To use this function, you will need to know the path to the Github repository (of course) you want to download. Once you have that URL, you will need to pass each piece of the URL into a parameter on the function.
For example, let’s take a URL like https://github.com/MSAdministrator/WriteLogEntry. This URL can be broken down as follows
- MSAdministrator = Owner
- WriteLogEntry = Repository
We also know that we want to download the “master” branch of this repository. The next part is that we need to gather a list of files/paths that we need to download as well. These will be passed as an array of strings to the FilePath parameter.
- Branch = Master (unless you want a different branch)
- FilePath = (Files and paths you want to download)
By default this function will always get the master branch of the repository you are wanting to download, but you can specify a different branch if wanted. Additionally, this function will download the specified files to your user profiles Module Path (C:\users\some_user\Documents\WindowsPowerShell\Modules)
To use this function, you will need to pass the following values as parameters to the function. For example, to download my WriteLogEntry repository you will need to call the function like so:
Get-GithubRepository -Owner MSAdministrator -Repository WriteLogEntry -Verbose -FilePath `
I hope that this function helps some of you who want to quickly download a Github repository without installing or using Git. If you have issues or like this function, please submit issues or fork requests to my Github.
Original Image here: