Hi,
I have few VMs in text file located in 'D:\VMware\vms.txt'
I am using Windows 10.
Is it possible to disconnect all the NICs of that VMs from vCenter by a script?
Thanks in advance!
You could do something like this
where{$_.Guest.OSFullName -match "Windows 10"} |
Get-NetworkAdapter |
Set-NetworkAdapter -Connected:$false -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You could do something like this
where{$_.Guest.OSFullName -match "Windows 10"} |
Get-NetworkAdapter |
Set-NetworkAdapter -Connected:$false -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello LucD,
Thanks for helping me.
NICs are not disconnecting. The script just ran and doing nothing. Not seeing any tasks in vCenter.
Did you check if any VMs are selected?
Are VMware Tools installed?
What does this return
Get-VM -Name (Get-Content -Path D:\VMware\vms.txt) |
where{$_.Guest.OSFullName -match "Windows 10"}
And this?
Get-VM -Name (Get-Content -Path D:\VMware\vms.txt) |
where{$_.Guest.OSFullName -match "Windows 10"} |
Get-NetworkAdapter
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
I guess I am getting something. If I use this command "where{$_.Guest.OSFullName -match "Windows 10"}" then I am not getting the VMs info. But if I # it then the NICs are disconnecting. But the script is working only for the powered on VMs. Is there anyway we can get it worked for power on/off VMs ?
That the VMs do not get through the Where-clause could be because the VMware Tools are not installed or not running.
Are the VMware Tools installed?
When a VM is powered off, you obviously can't connect/disconnect it from the network.
But you can use the StartConnected switch instead of the Connected switch.
In that case, the network will not be connected the next time the VM is powered on.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello LucD
These are test VMs. I didnt check the script on Prod VMs. Hence these test VMs doesnt have VMware tools installed in it.
But your suggestion worked.
Thank you again