Saturday, February 18, 2017

Changing Nano back to DHCP

I've been playing around some more with Nano server, but I didn't want to create yet another VM, so I decided to use one of my existing Nano servers. But it had an IP set already, and was set to an Internal switch (so no internet connectivity possible). So let's PowerShell-fix this!

First let's change the adapter of my VM called nano1:

Get-VM nano1 |Get-VMNetworkAdapter|Connect-VMNetworkAdapter -SwitchName external

There, that didn't hurt so much! Good, now let's change the settings inside the nano1 VM, to set the IP's back to DHCP. First, this very cool thing in Hyper-V called PowerShell Direct, allows me to enter the VM without needing any IP connectivity. All you need is the credentials of the VM, and to select the "-VMName" option with Enter-PSSession:

$cred = Get-Credential
Enter-PSSession -VMName nano1 -Credential $cred

This is what it looks like:

PS C:\> $cred = Get-Credential
Enter-PSSession -VMName nano1 -Credential $cred
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
[nano1]: PS C:\Users\administrator\Documents>

As Montgomery Burns says: "Excellent...": Did you notice the [nano1] in front of the last prompt? We're inside the VM! BTW, you don't need to add the credential, it will ask you for the credentials if you don't add them, but if you go in and out more than once, this is nicer.

Now that we're in a session, let's change the IP address and DNS back to DHCP enabled:

Get-NetIPAddress -InterfaceAlias "Ethernet" | Set-NetIPInterface -Dhcp Enabled
Set-DnsClientServerAddress -ResetServerAddresses -InterfaceAlias Ethernet



  1. Hi Akos,

    My name is Anuj Agarwal. I'm Founder of Feedspot.

    I would like to personally congratulate you as your blog Musings of a PowerShell Mad Man has been selected by our panelist as one of the Top 50 PowerShell Blogs on the web.

    I personally give you a high-five and want to thank you for your contribution to this world. This is the most comprehensive list of Top 50 PowerShell Blogs on the internet and I’m honored to have you as part of this!

    Also, you have the honor of displaying the badge on your blog.


  2. Health Is God is the main finish wellbeing and health site that you may portray as it yours. We made a site that presents the accumulation of wellbeing and way of life data bolstered by solid substance suppliers and certifiable client surveys. This is a true exertion on our part to deliver a client encounter which is drawing in, moving, and intuitive.

  3. I think this is a real great article post.Really looking forward to read more. Visit at
    Crazy Video Hub

  4. Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post.

  5. This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post. xtrazex

  6. Yes i am totally agreed with this article and i just want say that this article is very nice and very informative article.I will make sure to be reading your blog more. You made a good point but I can't help but wonder, what about the other side? !!!!!!Thanks titan gel italy

  7. You mention good points here in this post. But what about the opposite side. reply