Wednesday, April 25, 2012

Setting custom DNS settings with PowerShell in Server 2012

Okay, the time has come, I can finally say; “Server 2012”
I frequently use custom DNS settings in my lab environments to override the provided DHCP settings and use my own personal domain controllers.
For Server 2008 I used the following commands:
netsh interface ipv4 add dnsserver "local area connection" x.x.x.x 1
netsh interface ipv4 add dnsserver "local area connection" x.x.x.x 2
For the Windows 8 Preview I simply adapted this:
netsh interface ipv4 add dnsserver "Wired Ethernet Connection" x.x.x.x 1
netsh interface ipv4 add dnsserver "Wired Ethernet Connection" x.x.x.x 2
*Note the change to the interface name
Being an embracer of PowerShell and all the 2000+ new cmdlets in Windows Server I decided to figure out how to do this the PowerShell way.
Well, I have to say it took a while just to find the right cmdlets because I began at IPAddress or IPAdapter.  Not thinking that there would be a DnsClientServerAddress.
Get-DnsClientServerAddress
Now, to set, just turn this around to the Set-
Set-DnsClientServerAddress -InterfaceAlias vEthernet* -ServerAddresses "x.x.x.x","x.x.x.x"
Note how I feed in the multiple addresses, as list of individual comma separated strings.

Then, there is the one-liner (I discuss finding the proper NetAdapter is other posts).

Get-NetAdapter | Set-DnsClientServerAddress -ServerAddresses "x.x.x.x","x.x.x.x"

Monday, April 16, 2012

Windows 8 in a VM on 2008 R2 Hyper-V

Update:  As of October 9, 2012, the update has been superseded by 2744129. Go to http://support.microsoft.com/kb/2744129 to find that update, where it states the supersedence in the documentation.

This is an interesting patch that someone recently pointed me to:  http://support.microsoft.com/kb/2526776
Apply this patch to your Server 2008 R2 Hyper-V Server so that you can install Windows 8 in a VM.
If you do not apply this patch and you attempt to run Windows 8 within a VM: note the symptoms in the KB article:
  • The Windows Developer Preview or Windows Server Developer Preview virtual machine stops responding.
  • The Windows Server 2008 R2 host computer displays a stop error message and restarts automatically. This behavior brings down all other running virtual machines together with the host computer.
That does not sound good.
So, if you have a Hyper-V server that suddenly crashes and reboots, and you know that someone has downloaded the Windows 8 beta and might be installing it into a VM…  Well, you suddenly have an idea what might be going on.

Tuesday, April 10, 2012

PowerShell is about doing things not writing scripts

With PowerShell finally going cross-platform with Windows 8 I keep hearing the same comments over and over – “just write a script for that”

You know what?  Not everything needs a script.  A few commands maybe, but not a script.

Why do I bring this up?  Because script writing is intimidating.  You have to understand loops, arrays, object types, schemas, properties, and other developer-type things.

But if you only have a make a couple modifications to settings, every so often or discover something.  You don’t need a script for that, you need some commands.

And this is where the lingo and the action are becoming disconnected. 

If you look at it one way, PowerShell is to Windows what BASH is to Linux and what Command was to DOS.  A way to get things done.  A place to find things and do things.

Did everything that you did in DOS have to turn into a BATCH script?  No.  But back in the day we did write some pretty complex user logon and logoff scripts.  Why?

Because certain tasks needed to be repeated over and over.  That is where we need a script over a few captured commands.

My other big gripe is script or command examples.  Folks that blog some long and highly complex one-liner that is very difficult to comprehend because you get lost in the pipeline.  The big disservice being that they never do it long hand.

Most folks that I encounter these days are either at the 100 level of using PowerShell or at the 300 – 400 level.  You just straight through the 200 level when you write a script or suddenly grok objects.

Thursday, March 29, 2012

Windows 8 Hyper-V objects are aLive

For those folks new to PowerShell you need to wrap your brain around the object concept.  It is fundamental to understanding (grok-ing actually) tons of stuff.

In the Hyper-V cmdlet set in Windows 8 if you ‘get’ a VM object  (  $vm = Get-VM –Name Foo) you can simply type of object out and see its properties ( $vm ).

PS C:\Users\Administrator> $vm

Name                    State CPUUsage(%) MemoryAssigned(M)

----                    ----- ----------- -----------------
BrianEhDC.BrianEh.local Off   0           0

  

Now, lets say that Admin Joe or XenDesktop brokering  just turned on that VM that you have captured as your object.  Type its properties again.

PS C:\Users\Administrator> $vm

Name                    State   CPUUsage(%) MemoryAssigned(M)
----                    -----   ----------- -----------------
BrianEhDC.BrianEh.local Running 4           512

Notice that it is now running.  And you didn’t have to re-query to get that.

As stated by the Feature lead for the Hyper-V cmdlets:  “You get it for free” – In other words you didn’t have to do extra work to see that a property changed.  You did not have to do Get-VM again.

Cool!

Friday, March 23, 2012

Server 2012 on the Acer PDC Laptop with Hyper-V

This is all about getting Hyper-V working on a laptop when SLAT is not available on your hardware.  Because not all of us can afford a new shiny laptop to support Client Hyper-V.

Now, here is the big warning;

This is Server, not Client – In the end, the experience is nearly identical.

This is a computer with Hyper-V running (it has –V or –VT on the chipset).  It works, but if you want the fancy Windows 8 Client experience, you will not get it here.

There is also an order to adding the Roles and Features.  This is not rocket science, just proper ordering.

Now, I did add an SSD to my PDC laptop and I am incredibly happy I did.

  1. Install Windows Server 8
  2. Get the needed drivers from the Acer website (the display will be horrible, the disk will be slow) - http://support.acer.com/drivers_download.aspx
    1. Intel Chipset driver
    2. Intel VGA driver (this is the only driver that is necessary)
    3. and you might need the wireless LAN driver (the wired NIC is definitely in the installer)
    4. I also grabbed the audio driver
  3. Get that all working and patch the machine.
  4. Add the following Features:
    1. Wireless LAN Service
    2. Media Foundation
    3. User Interfaces and Infrastructure
      1. Desktop Experience
    4. reboot
  5. Now you can add the Hyper-V Role
  6. If you need sound, be sure to enable the Windows Audio service (set it to automatic and start it if you need it right away)

Now you have your PDC Laptop – still useful – running Server 8 Hyper-V.

You can fully play with all the new PowerShell commands.  (well, isn’t that why you would want to do this!)

If you want the Marketplace, then you need to create a user account as you cannot use the built-in local administrator to access the marketplace.  Otherwise, it is all there – touchscreen, Metro experience, etc..