The first function will work when on its own.
Function:
function Get-Search {
$find = Read-Host "Type of Git to search"
$url = 'https://github.com/search?q=' + $find
Write-Host ""
Write-Host "Here is a list of the top 10 results:"
$contributors = Invoke-WebRequest -Uri $url -UseBasicParsing
$contributors.Links| where class -EQ "v-align-middle" | select href
}
Get-Search
It prints correctly what I typed (Linux) into the search input.
Type of Git to search: Linux
Here is a list of the top 10 results:
href
----
/torvalds/linux
/raspberrypi/linux
/jaywcjlove/linux-command
/0xAX/linux-insides
/GameServerManagers/LinuxGSM
/judasn/Linux-Tutorial
/endlessm/linux
/beagleboard/linux
/linuxkit/linuxkit
/afaqurk/linux-dash
This is the correct output.
But when I add the following function:
function Get-Search {
$find = Read-Host "Type of Git to search"
$url = 'https://github.com/search?q=' + $find
Write-Host ""
Write-Host "Here is a list of the top 10 results:"
$contributors = Invoke-WebRequest -Uri $url -UseBasicParsing
$contributors.Links| where class -EQ "v-align-middle" | select href
}
Get-Search
function Get-Menu {
Write-Host
"
Options:
Want to explore a 'Git-README'? Type 1
Want to load a 'Git-Repo'? Type 2
Want to make a new search? Type 3
"
$choice = Read-Host "Type number here"
Write-Host ""
$pick1 = if ([string]1 -eq $choice )
{
$add = Read-Host "Add an above repo here"
$url2 = 'https://raw.githubusercontent.com/' + $add + '/master/README.md'
$contributors = Invoke-WebRequest -Uri $url2 -UseBasicParsing
$contributors.Links| where class "p" | select innerText
}
}
Get-Menu
The first function stops working:
Type of Git to search: Linux
Here is a list of the top 10 results:
Type number here:
The searched list is now missing.
Why?