{"id":5373,"date":"2017-01-13T14:31:25","date_gmt":"2017-01-13T19:31:25","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=5373"},"modified":"2017-01-13T14:31:25","modified_gmt":"2017-01-13T19:31:25","slug":"creating-a-github-repository-from-powershell","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5373\/creating-a-github-repository-from-powershell\/","title":{"rendered":"Creating a GitHub Repository from PowerShell"},"content":{"rendered":"<p>I've been continuing to work with the <a href=\"https:\/\/developer.github.com\/v3\/\" target=\"_blank\">GitHub API<\/a> in PowerShell. Today I have a function you can use to create a new GitHub repository. Of course you will need to have a GitHub account and another piece of critical information, but after that it is quite easy to create new repositories. This makes it easier for you to automate provisioning new projects, which is something else I'm working on. But for now, let's create some repos!<\/p>\n<p><!--more--><\/p>\n<p>The first bit of information you are going to need is a GitHub personal access token. If you don't have one saved you'll need to create one. Go to your GitHub profile settings and click on the \"Personal access tokens\" link. You may see a list of existing tokens but you wont' be able to see the actual value. But you can easily create a new token to use with your PowerShell scripts.<\/p>\n<p>Click the \"Generate New Token\" link and confirm your password. Enter a description and then select the scopes. Because you might use this with other PowerShell scripts I'd choose all repo, gist, and user scopes. Click \"Generate token\" and copy the 40 digit string and save it someplace secure. This is the Git token you will need to authenticate. In my PowerShell profile I have it stored in a variable, $gitToken. You should protect this token.<\/p>\n<p>Now you're ready to start working with your GitHub account.<\/p>\n<p>Here's the PowerShell function I've been working on.<\/p>\n<pre class=\"lang:ps mark:0 decode:true \">Function New-GitHubRepository {\r\n[cmdletbinding(SupportsShouldProcess)]\r\n\r\nParam(\r\n[Parameter(Position = 0, Mandatory, HelpMessage = \"Enter the new repository name\")]\r\n[ValidateNotNullorEmpty()]\r\n[string]$Name,\r\n\r\n[string]$Description,\r\n\r\n[switch]$Private,\r\n[switch]$NoWiki,\r\n[switch]$NoIssues,\r\n[switch]$NoDownloads,\r\n[switch]$AutoInitialize,\r\n\r\n#license templates found at https:\/\/github.com\/github\/choosealicense.com\/tree\/gh-pages\/_licenses\r\n[ValidateSet(\"MIT\",\"apache-2.0\",\"gpl-3.0\",\"ms-pl\",\"unlicense\")]\r\n[string]$LicenseTemplate,\r\n\r\n[Alias(\"token\")]\r\n[ValidateNotNullorEmpty()]\r\n[string]$UserToken = $gitToken,\r\n\r\n#write full native response to the pipeline\r\n[switch]$Raw\r\n)\r\n\r\nWrite-Verbose \"[BEGIN  ] Starting: $($MyInvocation.Mycommand)\"\r\n#display PSBoundparameters formatted nicely for Verbose output  \r\n[string]$pb = ($PSBoundParameters | Format-Table -AutoSize | Out-String).TrimEnd()\r\nWrite-Verbose \"[BEGIN  ] PSBoundparameters: `n$($pb.split(\"`n\").Foreach({\"$(\"`t\"*2)$_\"}) | Out-String) `n\" \r\n\r\n#create the header\r\n$head = @{\r\nAuthorization = 'Basic ' + $UserToken\r\n}\r\n\r\n#create a hashtable from properties\r\n$hash = @{\r\n name = $Name\r\n description = $Description\r\n private = $Private -as [boolean]\r\n has_wiki = (-Not $NoWiki)\r\n has_issues = (-Not $NoIssues)\r\n has_downloads = (-Not $NoDownloads)\r\n auto_init = $AutoInitialize -as [boolean]\r\n}\r\n\r\nif ($LicenseTemplate) {\r\n    $hash.add(\"license_template\",$LicenseTemplate)\r\n}\r\n\r\n$body = $hash | ConvertTo-Json\r\n\r\nWrite-Verbose \"[PROCESS] Sending json\"\r\nWrite-Verbose $body\r\n\r\n#define parameter hashtable for Invoke-RestMethod\r\n$paramHash = @{\r\nUri = \"https:\/\/api.github.com\/user\/repos\" \r\nMethod = \"Post\"\r\nbody = $body \r\nContentType = \"application\/json\"\r\nHeaders = $head\r\nUseBasicParsing = $True\r\nDisableKeepAlive = $True\r\n}\r\n\r\n#should process\r\nif ($PSCmdlet.ShouldProcess(\"$name [$description]\")) {\r\n   $r = Invoke-RestMethod @paramHash\r\n\r\n    if ($r.id -AND $Raw) {\r\n        Write-Verbose \"[PROCESS] Raw result\"\r\n        $r\r\n\r\n    } elseif ($r.id) {\r\n        write-Verbose \"[PROCESS] Formatted results\"\r\n\r\n        $r | Select-Object @{Name = \"Name\";Expression = {$_.name}},\r\n        @{Name = \"Description\";Expression = {$_.description}},\r\n        @{Name = \"Private\";Expression = {$_.private}},\r\n        @{Name = \"Issues\";Expression = {$_.has_issues}},\r\n        @{Name = \"Wiki\";Expression = {$_.has_wiki}},\r\n        @{Name = \"URL\";Expression = {$_.html_url}},\r\n        @{Name = \"Clone\";Expression = {$_.clone_url}}\r\n    } else {\r\n        \r\n        Write-Warning \"Something went wrong with this process\"\r\n    }\r\n\r\n    if ($r.clone_url) {\r\n      $msg = @\"\r\n\r\nTo push an existing local repository to Github run these commands:\r\n-&gt; git remote add origin $($r.clone_url)\"\r\n-&gt; git push -u origin master\r\n\r\n\"@\r\n    Write-Host $msg -ForegroundColor Green\r\n\r\n    }\r\n}\r\n\r\nWrite-Verbose \"[END    ] Ending: $($MyInvocation.Mycommand)\"\r\n\r\n}\r\n<\/pre>\n<p>Let me point out a few things.<\/p>\n<p>The only truly required parameters are the Name and GitHub token. I've set the default value of the latter to the variable from my profile which is why the parameter is not marked as Mandatory. You can also specify a repository Description.<\/p>\n<p>When you create a new repository, by default it is public. But if you have a paid account, you can opt to make it Private. All repos also get a wiki, issues and the option to have downloads but you can create a repo without any of these things with the corresponding parameters.<\/p>\n<p>I tend to create repos after I've started a project locally so I handle things like a license and README.md on my own. When you create a new repo with my function you can choose to include a license (I've added a validation set for the more common choices I think you'd make), as well as a parameter to Autoinitialize. This will create a default README.md file.<\/p>\n<p>The magic in all of this is creating a body of directives formatted as json.<\/p>\n<pre class=\"lang:ps mark:0 decode:true \">#create a hashtable from properties\r\n$hash = @{\r\n name = $Name\r\n description = $Description\r\n private = $Private -as [boolean]\r\n has_wiki = (-Not $NoWiki)\r\n has_issues = (-Not $NoIssues)\r\n has_downloads = (-Not $NoDownloads)\r\n auto_init = $AutoInitialize -as [boolean]\r\n}\r\n\r\nif ($LicenseTemplate) {\r\n    $hash.add(\"license_template\",$LicenseTemplate)\r\n}\r\n\r\n$body = $hash | ConvertTo-Json\r\n<\/pre>\n<p>This body becomes part of the parameters I'll splat to <a title=\"Read online help for this command\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=217034\" target=\"_blank\">Invoke-Restmethod<\/a>.<\/p>\n<pre class=\"lang:ps mark:0 decode:true \">$paramHash = @{\r\nUri = \"https:\/\/api.github.com\/user\/repos\" \r\nMethod = \"Post\"\r\nbody = $body \r\nContentType = \"application\/json\"\r\nHeaders = $head\r\nUseBasicParsing = $True\r\nDisableKeepAlive = $True\r\n}\r\n<\/pre>\n<p>The header is constructed from your user token.<\/p>\n<pre class=\"lang:ps mark:0 decode:true \">$head = @{\r\nAuthorization = 'Basic ' + $UserToken\r\n}\r\n<\/pre>\n<p>The result from GitHub is a json document but Invoke-RestMethod turns it automatically into an object. Be default I build a custom output object from this data.<\/p>\n<pre class=\"lang:ps mark:0 decode:true \">$r | Select-Object @{Name = \"Name\";Expression = {$_.name}},\r\n        @{Name = \"Description\";Expression = {$_.description}},\r\n        @{Name = \"Private\";Expression = {$_.private}},\r\n        @{Name = \"Issues\";Expression = {$_.has_issues}},\r\n        @{Name = \"Wiki\";Expression = {$_.has_wiki}},\r\n        @{Name = \"URL\";Expression = {$_.html_url}},\r\n        @{Name = \"Clone\";Expression = {$_.clone_url}}\r\n<\/pre>\n<p>Or you can use -Raw to see everything.<\/p>\n<p>The last bit of the function is something you get in GitHub when you create an empty repository and that is a tip on how to configure a local repository.<\/p>\n<pre class=\"lang:ps mark:0 decode:true \">if ($r.clone_url) {\r\n      $msg = @\"\r\n\r\nTo push an existing local repository to Github run these commands:\r\n-&gt; git remote add origin $($r.clone_url)\"\r\n-&gt; git push -u origin master\r\n\r\n\"@\r\n    Write-Host $msg -ForegroundColor Green\r\n\r\n    }\r\n<\/pre>\n<p>I can never seem to remember the syntax so this is a nice touch for me.<\/p>\n<p>My function makes use of <a title=\"Read online help for this command\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113429\" target=\"_blank\">Write-Verbose<\/a> and supports -Whatif.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image-6.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image_thumb-6.png\" alt=\"image\" width=\"644\" height=\"300\" border=\"0\" \/><\/a><\/p>\n<p>Now for real and I'll drop -Verbose.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image-7.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image_thumb-7.png\" alt=\"image\" width=\"644\" height=\"227\" border=\"0\" \/><\/a><\/p>\n<p>Done! You can see the git commands at the end in green. Here's the repo on GitHub.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image-8.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image_thumb-8.png\" alt=\"image\" width=\"644\" height=\"182\" border=\"0\" \/><\/a><\/p>\n<p>It has nothing in it yet, and I'll delete it shortly but it works.<\/p>\n<p>This function will eventually, hopefully, become part of a larger toolkit. But feel free to use it now and let me know how it works for you.<\/p>\n<p>Enjoy and have a great weekend.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been continuing to work with the GitHub API in PowerShell. Today I have a function you can use to create a new GitHub repository. Of course you will need to have a GitHub account and another piece of critical information, but after that it is quite easy to create new repositories. This makes it&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"New from the blog: Creating a GitHub Repository from #PowerShell","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[499,4,8],"tags":[224,495,429,411,534],"class_list":["post-5373","post","type-post","status-publish","format-standard","hentry","category-github","category-powershell","category-scripting","tag-function","tag-github","tag-invoke-restmethod","tag-json","tag-powershell"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Creating a GitHub Repository from PowerShell &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/5373\/creating-a-github-repository-from-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Creating a GitHub Repository from PowerShell &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"I&#039;ve been continuing to work with the GitHub API in PowerShell. Today I have a function you can use to create a new GitHub repository. Of course you will need to have a GitHub account and another piece of critical information, but after that it is quite easy to create new repositories. This makes it...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/5373\/creating-a-github-repository-from-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2017-01-13T19:31:25+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image_thumb-6.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5373\\\/creating-a-github-repository-from-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5373\\\/creating-a-github-repository-from-powershell\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Creating a GitHub Repository from PowerShell\",\"datePublished\":\"2017-01-13T19:31:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5373\\\/creating-a-github-repository-from-powershell\\\/\"},\"wordCount\":632,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5373\\\/creating-a-github-repository-from-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/01\\\/image_thumb-6.png\",\"keywords\":[\"Function\",\"GitHub\",\"Invoke-RestMethod\",\"JSON\",\"PowerShell\"],\"articleSection\":[\"GitHub\",\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5373\\\/creating-a-github-repository-from-powershell\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5373\\\/creating-a-github-repository-from-powershell\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5373\\\/creating-a-github-repository-from-powershell\\\/\",\"name\":\"Creating a GitHub Repository from PowerShell &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5373\\\/creating-a-github-repository-from-powershell\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5373\\\/creating-a-github-repository-from-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/01\\\/image_thumb-6.png\",\"datePublished\":\"2017-01-13T19:31:25+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5373\\\/creating-a-github-repository-from-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5373\\\/creating-a-github-repository-from-powershell\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5373\\\/creating-a-github-repository-from-powershell\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/01\\\/image_thumb-6.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/01\\\/image_thumb-6.png\",\"width\":644,\"height\":300},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/5373\\\/creating-a-github-repository-from-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"GitHub\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/github\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Creating a GitHub Repository from PowerShell\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Creating a GitHub Repository from PowerShell &#8226; The Lonely Administrator","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5373\/creating-a-github-repository-from-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Creating a GitHub Repository from PowerShell &#8226; The Lonely Administrator","og_description":"I've been continuing to work with the GitHub API in PowerShell. Today I have a function you can use to create a new GitHub repository. Of course you will need to have a GitHub account and another piece of critical information, but after that it is quite easy to create new repositories. This makes it...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5373\/creating-a-github-repository-from-powershell\/","og_site_name":"The Lonely Administrator","article_published_time":"2017-01-13T19:31:25+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image_thumb-6.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5373\/creating-a-github-repository-from-powershell\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5373\/creating-a-github-repository-from-powershell\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Creating a GitHub Repository from PowerShell","datePublished":"2017-01-13T19:31:25+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5373\/creating-a-github-repository-from-powershell\/"},"wordCount":632,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5373\/creating-a-github-repository-from-powershell\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image_thumb-6.png","keywords":["Function","GitHub","Invoke-RestMethod","JSON","PowerShell"],"articleSection":["GitHub","PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/5373\/creating-a-github-repository-from-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5373\/creating-a-github-repository-from-powershell\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5373\/creating-a-github-repository-from-powershell\/","name":"Creating a GitHub Repository from PowerShell &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5373\/creating-a-github-repository-from-powershell\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5373\/creating-a-github-repository-from-powershell\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image_thumb-6.png","datePublished":"2017-01-13T19:31:25+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5373\/creating-a-github-repository-from-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/5373\/creating-a-github-repository-from-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5373\/creating-a-github-repository-from-powershell\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image_thumb-6.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image_thumb-6.png","width":644,"height":300},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5373\/creating-a-github-repository-from-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"GitHub","item":"https:\/\/jdhitsolutions.com\/blog\/category\/github\/"},{"@type":"ListItem","position":2,"name":"Creating a GitHub Repository from PowerShell"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":5410,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5410\/creating-a-github-gist-with-powershell\/","url_meta":{"origin":5373,"position":0},"title":"Creating a Github Gist with PowerShell","author":"Jeffery Hicks","date":"January 26, 2017","format":false,"excerpt":"Recently I posted a PowerShell tool for creating a GitHub repository. In continuing my exploration of the GitHub API I wrote another PowerShell tool to create a GitHub gist. A gist is simple way to store and share snippets or code samples. I use them to share simple PowerShell scripts\u2026","rel":"","context":"In &quot;GitHub&quot;","block_context":{"text":"GitHub","link":"https:\/\/jdhitsolutions.com\/blog\/category\/github\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image_thumb-18.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image_thumb-18.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image_thumb-18.png?resize=525%2C300 1.5x"},"classes":[]},{"id":9343,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9343\/github-scripting-challenge-solution\/","url_meta":{"origin":5373,"position":1},"title":"GitHub Scripting Challenge Solution","author":"Jeffery Hicks","date":"March 7, 2024","format":false,"excerpt":"Earlier this year I appeared on the PowerShell Podcast. I ended the interview with a scripting challenge. The Core Challenge Using whatever tools and techniques you want, write a PowerShell function that will query the Issues section of a GitHub repository and create output showing the number of open issues\u2026","rel":"","context":"In &quot;GitHub&quot;","block_context":{"text":"GitHub","link":"https:\/\/jdhitsolutions.com\/blog\/category\/github\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4533,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4533\/powershell-pivot-tables-revisited\/","url_meta":{"origin":5373,"position":2},"title":"PowerShell Pivot Tables Revisited","author":"Jeffery Hicks","date":"September 26, 2015","format":false,"excerpt":"A few years ago I wrote a PowerShell function to create an Excel-like pivot table in a PowerShell console. The other day I decided to revisit the function. I was surprised that it didn't really need too much updating but I did spend some time updating the documentation and adding\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5360,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5360\/powershell-6-0-release-tools\/","url_meta":{"origin":5373,"position":3},"title":"PowerShell 6.0 Release Tools","author":"Jeffery Hicks","date":"January 5, 2017","format":false,"excerpt":"As you should be aware, the next version of PowerShell is open source and cross-platform. You will be able to run PowerShell v6 on Windows, a Mac and select Linux distributions. All of the code is currently in alpha and hosted on the PowerShell GitHub repository. This is also where\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image_thumb.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image_thumb.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image_thumb.png?resize=525%2C300 1.5x"},"classes":[]},{"id":5833,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5833\/new-powershell-projects-published\/","url_meta":{"origin":5373,"position":4},"title":"New PowerShell Projects Published","author":"Jeffery Hicks","date":"December 18, 2017","format":false,"excerpt":"Last week I published a few of the recent PowerShell modules I've been working on to the PowerShell Gallery. These projects had been in a beta phase while I worked out some last minute features. I was also waiting to see if there were any issues reported by you that\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/12\/image_thumb-6.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/12\/image_thumb-6.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/12\/image_thumb-6.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":5132,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5132\/downloading-git-tips-with-powershell\/","url_meta":{"origin":5373,"position":5},"title":"Downloading Git Tips with PowerShell","author":"Jeffery Hicks","date":"June 27, 2016","format":false,"excerpt":"So I've been sharing a number of PowerShell tools I've created for working with Git, including a few for getting tips from the Git Tips project on GitHub. My initial work was based on the fact that I had a local clone of that repository and wanted to search the\u2026","rel":"","context":"In &quot;Git&quot;","block_context":{"text":"Git","link":"https:\/\/jdhitsolutions.com\/blog\/category\/git\/"},"img":{"alt_text":"getting all online git tips with PowerShell","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/06\/image_thumb-22.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/06\/image_thumb-22.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/06\/image_thumb-22.png?resize=525%2C300 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5373","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=5373"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5373\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=5373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=5373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=5373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}