Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rename a Hyper-V VM Network Adapter using PowerShell

I'm trying to rename a Network Adapter on a virtual machine in Hyper-V. I've read through the documentation on MSDN and the Set-VMNetworkAdapter cmdlet has a parameter -Name<String> which reads:

Specifies the name for the virtual network adapter. The cmdlet changes the name to the value that you specify.

Which suggests to me that I should be able to name a Network Adapter as whatever I put in for the String.

Yet when I try the line:

Set-VMNetworkAdapter -VMName 'CENTOS' -VMNetworkAdapterName 'Network Adapter' -Name 'eth0'

I get an error:

Set-VMNetworkAdapter : Cannot bind parameter because parameter 'Name' is specified more than once. To provide multiple values to parameters that can accept multiple values, use the array syntax. For example, "-parameter value1,value2,value3".

Am I misunderstanding the use of the -Name parameter? Or am I simply misusing the CMDlet?

like image 681
Spellchamp Avatar asked Sep 05 '26 07:09

Spellchamp


2 Answers

Or you could use the "Rename-VMNetworkAdapter" cmdlet. :)

Rename-VMNetworkAdapter -VMName 'CENTOS' -Name 'Network Adapter' -NewName 'eth0' -WhatIf
like image 93
notjustme Avatar answered Sep 07 '26 03:09

notjustme


If you look lower down from the documentation you are quoting you would see that -Name is an alias for -VMNetworkAdapterName. Therefore you are already trying to name it 'Network Adapter' in your code sample.

So the error is indeed correct in stating that the parameter is specified more than once.

like image 27
Matt Avatar answered Sep 07 '26 02:09

Matt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!