Set-VMNetworkConfiguration: is not recognized as a name of a cmdlet

I am trying to automate some tasks for new VMs in Hyper-V. I came across an article talking about this commandlet to configure static IP to a VM even when It is off. I am using it as follows

Get-VMNetworkAdapter -VMName "myvm1" | Set-VMNetworkConfiguration -IPAddress "172.168.0.4" -Subnet "255.255.255.0" -DefaultGateway "172.168.0.1" -DNSServer "8.8.8.8"

when I run it I get
Set-VMNetworkConfiguration: The term ‘Set-VMNetworkConfiguration’ is not recognized as a name of a cmdlet,

however, I saw somewhere on MS site that this is a commandletand also I visited a couple of websites like

where it is indicated
Get-VMNetworkAdapter -VMName MaMachineVirtuelle | Set-VMNetworkConfiguration -IPAddress 192.168.1.2 00 ...............
Thanks for your help

Salam

When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

Guide to Posting Code - Redux <---- Click :point_up_2:t4: :wink:

( !! Sometimes the preformatted text button hides behind the settings gear symbol. :wink: )

The name of a command in PowerShell is “cmdlet” - no commandlet!!

The cmdlet Set-VMNetworkConfiguration is part of the Hyper-V PowerShell module. Do you have this module installed on the machine where you try to run this command?

And BTW: This site is in english. So there are probably very very few people speaking french. So the link you posted is not that helpful. :smirking_face:

Olaf, I have done for PS code but forgot for error messages I will do now. Regarding the french url, I just wanted to show the statement where he uses the cmdlet

When I run

Get-WindowsOptionalFeature -Online | Where-Object {$_.FeatureName -like "*Hyper-V*"}

It confirms that I have Hyper-V Modules

FeatureName : Microsoft-Hyper-V-All
State       : Enabled

FeatureName : Microsoft-Hyper-V
State       : Enabled

FeatureName : Microsoft-Hyper-V-Tools-All
State       : Enabled

FeatureName : Microsoft-Hyper-V-Management-PowerShell
State       : Enabled

FeatureName : Microsoft-Hyper-V-Hypervisor
State       : Enabled

FeatureName : Microsoft-Hyper-V-Services
State       : Enabled

FeatureName : Microsoft-Hyper-V-Management-Clients
State       : Enabled

I’ll take a wild guess … do you run this commands in an elevated console?

Yes sir, elevated console

Then I’m out of ideas. Sorry. :man_shrugging:

Maybe someone else has an idea. Let’s wait a little longer.

Set-VMNetworkConfiguration is a custom function written by Ravikanth Chaganti. It’s not native to the Hyper-V module.

The code for the function is no longer on the author’s blog (as far as I can tell), but it’'s been archived:

2 Likes

Wow … I totally missed that … I google it an the first hit was Set-VMNetworkAdapter. But I didn’t pay attention … :man_shrugging: :face_with_open_eyes_and_hand_over_mouth: … stupid me.

Thanks Matt, yes I copied it and it works fine, my bad I was stupide not really checking correctly