none
Apply configuration to virtual machine each time it starts up

    Question

  • Hi people! I need your experience.

    I have a VM that I need to apply a configuration to in case it restarts. The problem is because HyperV Server 2012 R2 overwrites the configuration of my vNICs and I lose certain configurations.
    These are as follows:
    Get-VMNetworkAdapter -VMName firewall01 | Where-Object -Property MacAddress -eq "00155D08CD00" | Set-VMNetworkAdapterVlan -Trunk -AllowedVlanIdList 0-600 -NativeVlanId 0

    and another vNIC:

    Get-VMNetworkAdapter -VMName firewall01 | Where-Object -Property MacAddress -eq "00155D08CD01" | Set-VMNetworkAdapterVlan -Trunk -AllowedVlanIdList 0-600 -NativeVlanId 0

    That's why I'm looking for some way to apply these settings to my VM in case it restarts, otherwise I lose network connectivity. 
    If there is a better way to do this, I greatly appreciate your advice.

    Thank you very much for your help and experience.

    Best regards

    Gabriel

    Thursday, November 8, 2018 8:37 PM

All replies

  • Hi,

    I suppose you use Group Policy to Deploy a Windows PowerShell Logon Script.

    There is a article about it,please refer to it.

    https://blogs.technet.microsoft.com/heyscriptingguy/2010/08/14/using-group-policy-to-deploy-a-windows-powershell-logon-script/

    Note:Please change your execution policy via Set-ExecutionPolicy

    More info

    https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-6

    Best Regards,
    Frank

     


    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Friday, November 9, 2018 8:55 AM
    Moderator
  • I don't think a logon script in the VM will be able to make changes to the VM network configuration defined by the Hyper-V host.  The VM would have to communicate over the network to the Hyper-V host in order to make the changes, and the problem reported was a loss of network connectivity.  Catch-22.

    I would try to figure out why the settings are getting changed.  I have not heard of a restart of a VM to cause a change in the configuration defined by the Hyper-V host.  Something is not right there.


    tim

    Friday, November 9, 2018 2:03 PM
  • I really don't know what it's about. But every time I restart my VM (FreeBSD 11.1) I lose the network connectivity (I lose the Trunk although if I check it out it looks good):
    Get-VMNetworkAdapterVlan -VMName firewall01 -VMNetworkAdapterName Trunk_WAN -Verbose | select * 

    But until I reapply the configuration (I do it live) I don't have connectivity again:
    Set-VMNetworkAdapterVlan -VMName firewall01 -VMNetworkAdapterName Trunk_WAN -Trunk -AllowedVlanIdList 0-600 -NativeVlanId 0
    Any idea what you could try to solve this problem?

    Thank you for help
    Gabriel
    Friday, November 9, 2018 3:44 PM
  • Can you check from within the guest OS to see what it thinks it is seeing?  The only thing I can think of is that the guest is not detecting it properly and when you perform the Set-VMNetworkAdapterVlan command from the host, you are 'kicking' the guest in such a manner that it performs something that corrects itself.

    tim

    Monday, November 12, 2018 3:20 PM
  • Hi,

    I suppose you use Group Policy to Deploy a Windows PowerShell Logon Script.

    There is a article about it,please refer to it.

    https://blogs.technet.microsoft.com/heyscriptingguy/2010/08/14/using-group-policy-to-deploy-a-windows-powershell-logon-script/

    Note:Please change your execution policy via Set-ExecutionPolicy

    More info

    https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-6

    Best Regards,
    Frank

     


    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    This doesn't make any sense. I'm talking about the VM, not the guest OS.
    Monday, November 12, 2018 5:33 PM
  • Can you check from within the guest OS to see what it thinks it is seeing?  The only thing I can think of is that the guest is not detecting it properly and when you perform the Set-VMNetworkAdapterVlan command from the host, you are 'kicking' the guest in such a manner that it performs something that corrects itself.

    tim

    I don't see it possible. As far as I know from the guest OS I don't have the tools to view the virtual NIC configuration managed by the hypervisor (my guest OS is FreeBSD 11.1).
    What I do know is that this does not happen in HyperV Server 2016 according to what a pfSense user comments in a post I opened.

    https://forum.netgate.com/topic/137513/hyperv-vlans-inquiry/

    This sounds to me like some kind of limitation or bug in HyperV Server 2012 R2...


    • Edited by _neok Tuesday, November 13, 2018 4:15 PM
    Monday, November 12, 2018 5:49 PM
  • Hi,
    Based on the complexity and the specific situation, we need do more researches. If we have any updates or any thoughts about this issue, we will keep you posted as soon as possible. Your kind understanding is appreciated. 

    If the issue still occurs, a support call to our product service team is needed for the debugging service.

    We'd like to recommend that you contact Microsoft Customer Support Service (CSS) for assistance so that this problem can be resolved efficiently. To obtain the phone numbers for specific technology request please take a look at the web site listed below:

     https://support.microsoft.com/en-us/gp/customer-service-phone-numbers  

    Best Regards,

    Frank


    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, November 13, 2018 6:31 AM
    Moderator