Search code examples
azurepowershellnetworkinginterfaceportal

Not able to enable/disable network interface for VM through Powershell run command from Azure portal


We have a requirement to disable/enable the network interface of the azure VM. Not able to do it from the Run command

enter image description here

Tried this command from the internet but it is always showing a running script

" netsh interface set interface 'INTERFACE NAME' disable"

Is there any way we can enable/disable the network interface through the portal or powershell?

I know the other way that network reset in which new ip within the same network needs to be assigned but here the requirement is only to disable and then enable the network interface only.


Solution

  • No, we cannot disable/enable the network interface of the azure VM from the Run command.

    RunPowerShellScript command is used to run custom script on Azure VM not to enable/disable the network interface of azure VM and only the listed command parameters can be used while running the script.

    You can detach/attach(disable/enable) the Azure VM Network Interface when the VM is in stopped state by going to the Networking-->Attach/Detach Network Interface as shown in below Screenshot from the Azure portal:

    enter image description here