Thank you for posting in Microsoft Q&A forum.
The way to switch from the box to either the icon or no icon altogether is to modify the registry key. We could simply add the registry key using GPO, we don't need a PS script for it.
According to the Show Search Box in win10 guide maybe we could show the search box on our task bar.we could change the reg which located:
"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Search"
SearchboxTaskbarMode DWORD
0 = Hidden
1 = Show search or Cortana icon
2 = Show search box
Here is the detailed guide for you to refer to:
https://www.tenforums.com/tutorials/2854-hide-show-search-box-search-icon-taskbar-windows-10-a.html
Note:This is non-official Microsoft article just for your reference.
Hope this could help you and have a good day!
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.