Jak utworzyć nowe repozytorium w GitHub za pośrednictwem PowerShell
Function New-GitHubRepo{
<#
.SYNOPSIS
Creates a new remote repository in GitHub
.DESCRIPTION
Creates a new remote repository in GitHub
.PARAMETER UserName
GitHub Username
.PARAMETER ProjectName
Name for the new remote GitHub repository
.EXAMPLE
New-GitHubRepo -UserName GUser -ProjectName "MyRepo"
.NOTES
Author: Michael Heath
Date: 04/27/2019
#>
Param(
[Parameter(Mandatory = $true)][String]$UserName,
[Parameter(Mandatory = $true)][String]$ProjectName
)
# This works for entering password
# New output file
$OutFile = ".\ex.cmd"
# Var for Quote
$q = [char]34
# Create part of the command line with the project name
$t = "$q{\$q @@ name\$q @@ :\$q @@ $ProjectName\$q}$q"
# Remove the space and the @@ symbols
$t = $t.replace(" @@ ", "")
# Add the curl command and the project
$t = "curl -u $UserName https://api.github.com/user/repos -d " + $t
# put contents in the ex.cmd file
"@echo off" | out-file $OutFile -Encoding ascii
$t | Out-File $OutFile -Encoding ascii -Append
# Execute the ex.cmd file - you will be prompted for your password
cmd.exe /C ".\ex.cmd"
Energetic Elephant