Adding 2016 subnets to AD Sites and Services

In a recent post I showed how to configure the DHCP server with multiple scopes of subnets with PowerShell and how blazing fast that could be done in the Windows 2012 compared to Windows 2008 R2.

One thing we might forget is to populate the Active Directory Sites and Services subnets with this information to get the clients to access the domain controllers that is nearest. As you can read in this technet post the reason for populating this:

“Domain controllers register service (SRV) resource records in Domain Name System (DNS) that identify their site names. Domain controllers also register host (A) resource records in DNS that identify their IP addresses. When a client requests a domain controller, it provides its site name to DNS. DNS uses the site name to locate a domain controller in that site (or in the next closest site to the client). DNS then provides the IP address of the domain controller to the client for the purpose of connecting to the domain controller. For this reason, it is important to ensure that the IP address that you assign to a domain controller maps to a subnet that is associated with the site of the respective server object. Otherwise, when a client requests a domain controller, the IP address that is returned might be the IP address of a domain controller in a distant site. When a client connects to a distant site, the result can be slow performance and unnecessary traffic on expensive WAN links.”

So as we do not want to update 2016 subnets manually we do this with PowerShell instead, and as you can see with the Windows 2012 it goes quite fast (I have tested on Win 2008 R2 and it works there also).

sitesps

and here is the small PowerShell bits that do the magic

# Populate Subnets in AD Sites and Services
#
# Niklas Akerlund 2013-05-14 

for($b=1;$b -le 63 ; $b++){
    for($i=0;$i -le 255){ 
        $Name = "10.10.$b.$i" + "/29"
        $Description = "10.10.$b.$i" + "/255.255.255.248"
        New-ADObject -Name $Name -Type subnet -Description $Description -OtherAttributes @{location="RemoteVPN";siteObject="CN=HQ,CN=Sites,CN=Configuration,DC=lumademo,DC=local"} -Path "CN=Subnets,CN=Sites,CN=Configuration,DC=lumademo,DC=local"     
        $i = $i +8
    }
}

And then when you look in the Active Directory Sites and Services you will find all the subnets and that they correlate to the right site.

sitesservice

Upgrading to WMF 3.0 on Win 2008 R2 SP1 Hyper-V Core

If you still have some Windows 2008 R2 SP1 Core Hyper-V hosts running and thinking of upgrading to WMF 3.0 there has been some problems with the VMM 2012.

I have a Win 2008 R2 Core SP1 Hyper-V  in my VMM 2012 SP1 UR2 and wanted to test if this was still an issue. The main reason for upgrading to the WMF 3.0 is the rebuild of the vmm refresh that is described in this blog post.

First I just tried to run the install file for WMF 3.0 and got the following dialog, and after reading a bit more realizing that it was because I need the .Net 4 as a prerequisite.

notapplicablewmf3

I installed the .Net 4 and there are some things that need to be configured on the Core server before and that is explained on the download page for .Net for Win 2008 R2 SP1 Core

After that It worked to install,

install1wmf3

And after rebooting the host I looked in VMM and also tried some refresh and start/stop on VM´s and setting the host in maintenance mode, everything worked without any issues 🙂

hoststatuswmf3

Adding 2016 DHCP Scopes with PowerShell in Windows 2012

I have had a lot to do and that is why I have not done so much updating on the blog, soon my third article will be published on Petri IT Knowledge 🙂 I have also attended the MMS in Las Vegas where I got loads of good information and meet lots of people!

In this post I want to show you the improvements in Windows 2012 and with the PowerShell native cmdlets in this version.

The task was to automatically create 2016 DHCP Scopes for clients on a DCHP server and every scope was a /29 net with 3 lease addresses and one router for each.

I tested this on a Windows 2008 R2 with the community powershell module  and with the following script it took, and I am not kidding, almost 5 hours!! the module utilise the net sh commands with dhcp and probably there could be a lot of improvements for performance, and seriously, just creating one or two scopes can be done in the gui but doing over 2000 will demand a scripted way!

Screen Shot 2013-04-24 at 19.28.45
# Massive DHCP Scope 2016
#
# Niklas Akerlund 2013-04-24

write-host (get-date)
for($b=1;$b -le 63 ; $b++){
    for($i=0;$i -le 255){ 
        New-DHCPScope -Server localhost -Name 10.10.$b.$i -Address 10.10.$b.$i -SubnetMask 255.255.255.248 | Out-Null
        $startip = $i+2
        $endip = $i+4
        $router = $i+1
        Add-DHCPIPRange -Server localhost -Scope 10.10.$b.$i -StartAddress 10.10.$b.$startip -EndAddress 10.10.$b.$endip | Out-Null
        Get-DHCPScope -Server localhost -Scope 10.10.$b.$i | Set-DHCPOption -OptionID  003 -DataType IPADDRESS -Value 10.10.$b.$router | Out-Null
        $i = $i +8
    }
}
write-host (get-date)

With the PowerShell DHCP module for WIndows 2012 I have created the following script for creating the same amount of scopes and configuration and running it took only about 1 minute!!

Screen Shot 2013-04-24 at 20.02.35
# Massive DHCP Scope 2016
#
# Niklas Akerlund 2013-04-24

write-host (get-date)
for($b=1;$b -le 63 ; $b++){
    for($i=0;$i -le 255){ 
        $startip = $i+2
        $endip = $i+4
        $router = $i+1
        Add-DhcpServerv4Scope -Name 10.10.$b.$i -StartRange 10.10.$b.$startip -EndRange 10.10.$b.$endip -SubnetMask 255.255.255.248
        Set-DhcpServerv4OptionValue -ScopeId 10.10.$b.$i -Router  10.10.$b.$router
        $i = $i +8
    }
}
write-host (get-date)

As you can see, handling lots of changes and configurations can easily be done in the new Windows 2012 and it´s native cmdlets!

Manage your Clouds with PowerShell ppt and demofiles

Today I was presenting on the Technet Sweden Live meeting:System Center Sp1 Springtime series and my session was about:

manageclouds


The presentation can be downloaded on the following link -> SC2012SP1VarenPSClouds and I have also added it to slideshare

I also promised that the powershell files I have created for the demonstrations would be downloadable and here they are, I have made one file for each of the cloud management parts

You can also read some of my other posts about App controller and how to add clouds to it, also the post about how to extend your VMM console with custom properties and also how to download and update help in SCVMM.

I will try to get some time to make some demo movies and publish them in a near future 🙂

 

Not able to set HA on a running VM with SC VMM 2012 SP1

I have described before in blog posts about how to add a running VM to a Hyper-V failover cluster with the PowerShell cmdlets without moving it or turning it off, asuming it already was on a highly available storage such as a CVFS volume or smb 3.0 file share

In my exploration of the virtual machine manager PowerShell module I wanted to test and see if this was also possible in there but I do not succeed, or more correctly maybe should be noted that the SCVMM team has not implemented that for this release 🙁 what has been implemented is the possibility to make a VM highly available when moving between datastores on a cluster node or from a single hyper-v host to a cluster node. As there is some copying of data it will also take longer time than the below command.

In Hyper-V with failover cluster PowerShell module I can add a VM to the cluster with the following cmdlets without stopping the VM.

sethighavailpshv
Hyper-V\Get-VM vmtest -ComputerName HV02 | Add-VMToCluster -Cluster HVCL30

As you see, the reason why I have added the Hyper-V to the cmdlet is that because in the VMM PowerShell cmdlet there is an alias that is called Get-VM and refers to the Get-SCVirtualMachine and that conflicts with the Hyper-V PowerShell module´s Get-VM and I have imported both modules in the same console. I have also imported the failover cluster module in the same console.

If I try to use the Set-SCVirtualmachine vmtest -HighlyAvailable $true I get the following error.

sethighavailvmm

In the VMM Console this option is also greyed out and cannot be set.

isavailablegui

Here is the command to move the VM from one datastore to another and in the same time making it highly available,

movevmworks

I have made a blog post about the issue with Move-SCVirtualMachine not updating the cluster resource and this can be a way to handle this but in my opinion a far more complicated way as you have to move the VM to a new datastore and removing the high availability and then moving it again to another datastore and making it high available again, with a large virtual machine this can take some considerable time when it otherwise just is to run the cluster cmdlet.

Adding Clouds to SC App Controller 2012 SP1 with PowerShell

Last post I did was about how to get the connection to an remote SC App Controller Server with the SCAC PowerShell module.

Now I will show you how to add your Private and Public Cloud to your App Controller with the PowerShell cmdlets.

First off I will add my SC VMM server, and as you can see I first connect to the App Controller and then add the VMM server.

AddVMM

I do not know if it is my silverlight that has some issues or, but the web console did not reflect the addition of the VMM Server until I logged of and then on the App Controller portal

VMMingui
PS C:\> Add-SCACCloudSystem -VMM -Name VMM2012 -ServerName vmm2012.lumademo.local -Port 8100

Then I will add my Azure account and that is done by adding an subscription, here you will need the certificate with the private key for the management certificate that you uploaded to your Azure subscription. And yes I have cluttered out the password and subscription Id in the screendump so it is not your monitor that broke 😉

AddAzure
Azuregui
PS C:\> Add-SCACAzureSubscription -Name vNiklas -Id your-azure-subscription-id -ManagementCertificatePath C:\temp\certazure.pfx -ManagementCertificatePassword (ConvertTo-SecureString -AsPlainText "YourCertPassword" -Force)

Pretty easy and now I have two clouds in my App Controller, I can also add a SPF cloud connection from a third party vendor to get a truly hybrid cloud, that I have not set up yet though so it will have to be in another post.

Using SC App Controller 2012 SP1 PowerShell module remote

Today I have been exploring the System Center App Controller 2012 SP1 and the PowerShell module that it has.

There is not so many cmdlets in this but maybe it is enough… will find out soon 🙂

Screen Shot 2013-03-26 at 20.55.51

One cmdlet that is necessary is the Get-SCACServer if you are running the powershell module remote. Here comes the small problem when like me not using a certificate from a trusted CA like the AD CS or bought by a small amount of $$$ from verisign or other vendor of certs. As you can see on the next screendump I get a small error that the cmdlet does not like the certificate, well as there is no -force parameter on the cmdlet I went for another aproach and I added the self-signed cerificate from the App Controller server that was used in the IIS to the trusted root certificate authorities certificate store in the cert manager on the Management machine where I wanted to run the appcontroller PowerShell module. And now the cmdlet did not complain and I could get the App Controller server 🙂

Screen Shot 2013-03-26 at 21.43.22

Here you can see where I added the cerificate,

Screen Shot 2013-03-26 at 21.59.48

When using the App Controller PowerShell module locally on the same server as the App Controller Server resides this trust of the cert is already taken care of 🙂

A good post on how to create your own certificates for example using in management of your Azure or your IIS SSL you can find here on this link.

Downloading help for SC VMM 2012 SP1 PowerShell module

Today I wanted to use the help in SC Virtual Machine Manager PowerShell console and found that I had to download the updated help before I could see the whole, and of course I tried to do that but encountered the little error that follows in the screendump as you see,

Screen Shot 2013-03-25 at 10.35.55

I had used the PowerShell shortcut in the VMM Console, and was using my own login account, It is part of administrators/domain admins but still had not proper rights on the VMM server.

Screen Shot 2013-03-25 at 19.59.53

I opened a new PowerShell console by right click on the shortcut on the taskbar and chose Run-As Administrator and typed:

Screen Shot 2013-03-25 at 20.03.07
Import-Module virtualmachinemanager
Update-Help -Module virtualmachinemanager

And now I can see the full help 🙂

Screen Shot 2013-03-25 at 19.56.52

New book : Windows 2012 Hyper-V Install and Configuration Guide

HypVConfgInstallgd

Today I bought this book that is written by

  • Aidan Finn
  • Patrick Lownds
  • Michel Luescher
  • Damian Flynn

And in part one I found that Aidan had referred to one of my scripts for moving virtual machine storage without leaving anything behind,

cleaningvNiklas

since the book got into production I have made an update to do some checking and not deleting to much that could happend in the first version!

I feel really honored to be included within a such complete and thorough book about Hyper-V in Windows 2012!

It takes som extra days before it is going to start being delivered in Europe but You can as I by it directly from the Amazon US Kindle store and get it delivered to your App on a chosen device.

Failover Cluster not updated after vm storage migration in VMM 2012 SP1

I was talking to a customer today about an issue they had with their SC VMM 2012 SP1 and when they where doing some storage migrations between their CSV SAN volumes in the Hyper-V cluster.

Screen Shot 2013-03-19 at 22.24.56
Move-SCVirtualMachine -VM (Get-SCVirtualMachine VMtest) -VMHost (Get-VMHost HV02) -Path "C:\ClusterStorage\Volume2" -UseLAN

Everything looks good inside VMM and also the VM works nicely but when looking at the failover cluster manager the resource is not updated which resulted in failure in backup with DPM and probably more issues.

Here is a screendump of the VM in failover cluster manager and also an screendump of the VM in VMM after the migration, as you can see these values does not match

Screen Shot 2013-03-19 at 20.24.47
Screen Shot 2013-03-19 at 20.57.09

There is a way to solve this but that will mean that we have to use the failover cluster and Hyper-V cmdlets. Also should be noted that if we use the failover cluster manager it works so it is a bug in VMM.

So I opened a new PowerShell console and typed the following:

Get-VM VMtest -ComputerName HV02 | Update-ClusterVirtualMachineConfiguration -Cluster HVCL30

And here you can now see that the cluster resource reflects the right data

Screen Shot 2013-03-19 at 22.40.42

There is actually one more solution and that is to remove the VM from the cluster and then add it again but it is easier to just update the cluster virtual machine configuration 🙂

On the management computer I always install the RSAT tools for Hyper-V and also Failover Cluster along with the VMM console to be able to do all management from one place even if I cannot do it all in VMM.