I'm trying to automate the creating of remote repos using powershell and gh repo create
and the first thing that happens after running that command is an option to create a new repo on GitHub or push an existing local repo up. I want to select the former, which should just require hitting enter since this is the option that is highlighted by default. I'm trying to use this in my ps1 script:
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}");
When I try that without the gh repo create
command, it works as expected, creating a new line in the powershell console. But when following gh repo create
, it appears to do nothing. The console just sits on the following text which is output from the gh repo create
command:
What would you like to do? [Use arrows to move, type to filter]
> Create a new repository on GitHub from scratch
Push an existing local repository to GitHub
I have tried countless combinations of the following commands
gh repo create
[Microsoft.VisualBasic.Interaction]::AppActivate("Administrator: Microsoft Powershell")
Add-Type -AssemblyName System.Windows.Forms
Start-Sleep 3
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
and
$wshell = New-Object -ComObject wscript.shell;
$wshell.SendKeys("{ENTER}")
I'm new to powershell and can't tell if I'm doing something wrong or if sendkeys just doesn't work with gh commands for some reason, seems to be the latter. Any ideas would be appreciated.