I can manually open up PowerShell and run
wsl
ip addr show eth0 | grep 'inet\b' | awk '{print $2}' | cut -d/ -f1
To get the IP address of the Ubuntu instance. But when I try to write a script for this (100 different ways) I always get some kind of error. This is an example
$command = "ip addr show eth0 | grep 'inet\b' | awk '{print $2}' | cut -d/ -f1"
$ip = Invoke-Expression "wsl $command"
Which gives an error about grep
.