VMware Cloud Community
mimo974
Contributor
Contributor

Execute script on esxi

Hello everyone,

I want in one order put down after up all vmnic of my esx (vmnic1,vmnic2 and vmnic3)

I know the command is : esxcli network nic down -n vmnicX

But can i do this :  esxcli network nic down -n vmnic1 vmnic2 vmnic3 for down and this for up : esxcli network nic up -n vmnic1 vmnic2 vmnic3 ?

If i create a folder at the root and put my script in this folder, do you think can work ?

What kind of script i need to create to use directly on esxi to start esxcli network nic down -n vmnic1 vmnic2 vmnic3 ?

The goal is my colleague just need connect on esxi i start the script.

Thank you for help.

0 Kudos
4 Replies
harry89
Enthusiast
Enthusiast

Hello ,

Please use below script

  • Create a script test.sh (vi test.sh)
  • Add the below lines in the script ( here I am marking vmnic6 and vmnic7 down at same time )

                       #!/bin/sh

                       esxcli network nic down -n vmnic6

                        esxcli network nic down -n vmnic7

  • Chmod +x test.sh       (give permissions)
  • ./test.sh     (execute the script)

Just did in my lab Smiley Happy

[root@esxi2:/var] cat test.sh

#!/bin/sh

esxcli network nic down -n vmnic6

esxcli network nic down -n vmnic7

  • Nics are marked as down

pastedImage_14.png

Cheers !!

Harry
VCIX-DCV6.5 ,VCIX-NV6 , VCAP-CMA7
Mark answer as correct/helpful if it solves your query
0 Kudos
scott28tt
VMware Employee
VMware Employee

Moderator: Please do not create duplicate threads on the same topic.

The other thread you created today has been locked and archived.


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
0 Kudos
mimo974
Contributor
Contributor

Thank you for your help but for me is not work.

I have this message : -sh: ./script_down_vmnic.sh: not found

Can you have an idea ?

0 Kudos
Lalegre
Virtuoso
Virtuoso

Please make sure you are in the correct path while running the script and also do not forget to add permissions with chmod to make it executable.

Regards!

0 Kudos