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

Done!

12 comments:

  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.

    http://blog.feedspot.com/powershell_blogs/

    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.

    Best,
    Anuj

    ReplyDelete
  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.

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

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

    ReplyDelete
  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

    ReplyDelete
  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

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

    ReplyDelete
  8. 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

    ReplyDelete
  9. Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. Crave Healthiness (make 10 on this)

    ReplyDelete
  10. This particular papers fabulous, and My spouse and i enjoy each of the perform that you have placed into this. I’m sure that you will be making a really useful place. I has been additionally pleased. Good perform! Best energy supplements for chronic Fatigue

    ReplyDelete
  11. 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 300 Hours Yoga teacher training

    ReplyDelete
  12. Thanks for the nice blog. It was very useful for me. I'm happy I found this blog. Thank you for sharing with us,I too always learn something new from your post. Best Exercise Equipment For Over 60

    ReplyDelete