Habibalby_083114

updated

11 years ago

0

420945

January 12th, 2016 02:00

PowerShell to disable VMNet-Adapter

Hi,

I'm trying to find a way to disable a network adapter for particular VDI machines and I'm thinking to use Powershell to do that activity. But unfortuantly, the Powershell module to download the powershell is not available...

http://en.community.dell.com/techcenter/virtualization/vworkspace/w/vworkspace-wiki/5750.quest-vworkspace-powershell-module-download

Highly appreciate your help.

  • 1951

    0

    Posted January 12th, 2016 04:00

    Hi All,

    I think I have to live with this script since it does the job.

    1. Untagged existing vLAN from the physical interface where the Hyper-V host connected to serves the exisiting VDI Network.
    2. Tagged the new vLAN.
    3. Run the below script to make sure VDI Machines obtain new IP from the DHCP Scope.

    $VMs = Get-Content C:\Scripts\VMs.txt

    Foreach ($VM In $VMs)

    {

    Get-VM -Name $VMs | Get-VMNetworkAdapter | Disconnect-VMNetworkAdapter

    Write-Host $VMS "Network Interface Has been disconnected"

    Get-VM -Name $VMs | Get-VMNetworkAdapter | Connect-VMNetworkAdapter -SwitchName "VDI Networks"

    Write-Host $VMs "Network Interface has been reconnected"

    }

    Hope it helps someone else...

     

  • lwhitelock

    11 Posts

    1951

    0

    Posted January 12th, 2016 02:00

    What version of vWorkspace are you running?

  • 1951

    0

    Posted January 12th, 2016 02:00

    Hi,

    I'm running version 8.5..

    This method on the Hyper-V will do, but I'm afraid that when the VMs disconnected and connected back, they will be connected with the old IP and they won't obtain IP from the new vLAN...

    Get-VM "v-Win10-Template" | Get-VMNetworkAdapter | Disconnect-VMNetworkAdapter

    Get-VM -Name "v-Win10-Template" | Get-VMNetworkAdapter | Connect-VMNetworkAdapter -SwitchName "VDI Networks"

    I'm thinking of a way to renew the VMs IP without disconnecting the session from the end user..

    Regards,

  • Hilbert_nl

    17 Posts

    1951

    0

    Posted January 12th, 2016 04:00

    You're looking for a situation to refresh the DHCP lease for those VM's ?

  • Hilbert_nl

    17 Posts

    1951

    0

    Posted January 12th, 2016 04:00

    Don't you have to loose the 's' from $VMs in the loop? Like this:

    $VMs = Get-Content C:\Scripts\VMs.txt

    Foreach ($VM In $VMs)

    {

    Get-VM -Name $VM | Get-VMNetworkAdapter | Disconnect-VMNetworkAdapter

    Write-Host $VM "Network Interface Has been disconnected"

    Get-VM -Name $VM | Get-VMNetworkAdapter | Connect-VMNetworkAdapter -SwitchName "VDI Networks"

    Write-Host $VM "Network Interface has been reconnected"

    }

  • 1951

    0

    Posted January 12th, 2016 05:00

    Hi,

    yes, that's right.. I'm looking for a way to refresh the DHCP lease for those VMs.

    Regards,