Luckily enough there is little work to do, just create another script that modify the host file and from the previous script run this other script changing the user. This happens only if you are using a user that is not administrator of the machine, but this should be the default right? :) If you run the entire script with the administrator user, you are not able to interact with the WSL instances, because they are bound to your actual user. This is where the script becomes tricky, because wsl runs as your actual user, and if you, like me, use a non admin user, you need to launch the above code without elevated permission, then you need to launch another script with the administrator user to be able to change hostfile. Now armed with the real ip of WSL machine I need to change the c:\windows\system32\drivers\etc\host file to update the ip of the ubuntuwsl entry. Write-Host "Ip of wsl ubuntu machine is $ip"
0 Comments
Leave a Reply. |