0

I'm kind of just being lazy here but I'm sure I'm not the only person trying to do something like this.

I'm using bash on Windows to SSH into Linux VMs in hyper-v on my local machine and I'm not giving the VMs static IPs. I want to run the following powershell command from bash:

Get-VM | Select-Object -ExpandProperty NetworkAdapters | Select-Object VMName,IPAddresses

This works in powershell if I run it as admin and shows me the IPs hyper-v assigned to each VM. I can call powershell.exe from bash but I get an error saying I don't have the required permission to complete the task.

Anybody know how to run an elevated powershell command from bash? My ultimate goal is to do everything within the same bash window.

1 Answer 1

0

I do not understand how you can call powershell.exe if you are inside the linux machine, but I think there is a much easier way to do this: if you are already on the console of the linux VM, why don't you ask the linux machine itself for the IP address with ifconifg?

With a little grep and other bash magic, you can extract the IP address from the output.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.