I have not been very clear about the requirement of your application, but from what I understood you are mixing 2 topics:
One is the ability to open a browser at a certain URL and the other can complete an input within a URL.
If you want to be able to open a browser with a search on YouTube, one way to do it is as follows:
$search = "powershell"
$search.Replace(" ","+")
$ie = new-object -com "InternetExplorer.Application"
$ie.navigate2("https://www.youtube.com/results?search_query=$search")
$ie.visible = $true
Where the variable search specifies the value to search. If you look at the second line, I used the Replace method because when doing the search with terms that contain spaces, they are replaced with plus signs (+).
The result of the above must open a new IE window with the search on YouTube of the term "powershell".
Edited:
With your comment, I reviewed a bit and I could get to this:
$searchBar = "masthead-search-term"
$buttonId = "search-btn"
$ie = new-object -com "InternetExplorer.Application"
$ie.navigate2("https://www.youtube.com/?hl=es&gl=ES")
$ie.visible = $true
while($ie.Busy) { Start-Sleep -Milliseconds 100 }
$doc = $ie.Document
$doc.getElementById($searchBar).value = "PowerShell"
$doc.getElementById($buttonId).click()
I added a wait while loading the page, and then filtered the search field and the search button. With the above you should be able to do what you have in mind.