Forum Discussion

Dave Florek's avatar
Dave Florek
Copper Contributor
Jul 25, 2023
Solved

Issue running Powershell script to clone GitHub repositories

I'm running into a problem where my script is unable to clone private GitHub repositories into a destination folder using a GitHub API key. When I run the script, I receive the following error:   ...
  • LeonPavesic's avatar
    Jul 26, 2023

    Hi Dave Florek,

    The error message "Not Found" indicates that the API endpoint might not be valid or doesn't exist.

    To troubleshoot this, here are some steps you can take:

    1. Double-check the $url variable in your CloneGitHubRepo function to ensure it contains the correct organization name and repository name.

    2. Make sure the GitHub API token you're using has the necessary permissions to access the repository. It should have at least "repo" scope to clone private repositories.

    3. Test the API request separately using tools like Postman or cURL to see if you can successfully access the repository information. This will help you identify any issues with the API URL and headers.

    4. Consider using a personal access token instead of a GitHub API token for authentication. Personal access tokens are easier to manage and should provide sufficient permissions for cloning private repositories.

    Regarding using cURL, while it's an option, PowerShell's Invoke-RestMethod is a powerful cmdlet that can efficiently handle API requests. Once you resolve the authentication issue, it should work fine for cloning GitHub repositories.


    I suggest focusing on debugging the existing PowerShell script and fixing the API request problem. PowerShell's Invoke-RestMethod is quite flexible and should be suitable for this task once the authentication problem is resolved.



    Please click Mark as Best Response & Like if my post helped you to solve your issue.
    This will help others to find the correct solution easily. It also closes the item.


    If the post was useful in other ways, please consider giving it Like.


    Kindest regards,


    Leon Pavesic

Resources