Windows Server 2012 deployment via PowerShell

Now with the release of Windows Server 2012, Microsoft has added a huge huge huge improvement in PowerShell, there are about 2400 cmdlets available, and Microsoft have said that there are more to tome.
Just to display how easy it is, I thought Id give a walkthrough deployment of a simple Server 2012 farm.
Including
1x AD Domain Controller
1x RDS server session deployment with remoteapps.
1x File Server using data DE duplication and used for serving the user profile disks on the RDS server with NIC teaming. And Having 3 disks in a storage space and volumes using disk parity.

Now we are going to host all of these 3 servers on a WS2012 Hyper-V server. So first of we create a virtual network where these hosts are going to be.

First we create the switch

New-VMswitch –name vm-switch –switchtype internal

Then we create the first virtual machine and add it to that internal network.

New-VM -NewVHDPath e:\vm\ad.vhdx -NewVHDSizeBytes 20GB -BootDevice CD -MemoryStartupBytes 2GB -Name AD
Remove-VMNetworkAdapter –VMName AD –Name “Network Adapter”
Add-VMNetworkAdapter -VMName AD -Name «Network Adapter» -SwitchName vm-switch


After that we can boot the first computer. This is going to be our domain controller, and for the purpose of this demonstration we are going to install this as a Server Core server. (Server Core is a stripped down server which basically gives you an command prompt that you can work from.
IF you wish to manage the server you either need to use sconfig, PowerShell or Server Manager

If you wish to install full GUI on it afterwards you can do this using the commands

Install-WindowsFeature server-gui-mgmt-infra,server-gui-shell -source:wim:d:\sources\install.wim:4 –restart

If you look at the last command there you see that I needed to specify the source (Because when I install with Server Core it removes all the unnecessary binaries from the install so you need to insert the installation media and in my case it was ISO file on the D: drive.  And I also needed to specify the install WIM file and the WIM file contains the images for Datacenter and Standard Core and with GUI so the number 4 states Datacenter with GUI.

When the server is up and running we have to configure the network, domain name and such.

New-Netipaddress –ipaddress 192.168.0.1 –interfacealias «Ethernet» –Prefixlenght 24
Set-DnsClientServerAddress -InterfaceAlias «Ethernet» -ServerAddresses 192.168.0.1
Rename-computer adds
Restart-computer

This will add the IP address of 192.168.0.2 on the interface Ethernet with a subnet mask of 255.255.255.0 /24
And set the DNSclient to itself (since the ADDS installs DNS as well)
Renames the computer ADDS and does a restart.

After that we install ADDS. This is the simplest setup and uses most of the default values.

Install-WindowsFeature AD-Domain-Services -IncludeManagementTools
Install-ADDSForest –DomainName test.local
Restart-computer

This will install a ADDS domain service on this server (as well including DNS server) with the domain name of test.local
after that you have to restart the computer. When the server is finished booting, you have a fully functional domain server so now its time to install the RDS server.

New-VM -NewVHDPath e:\vm\rds.vhdx -NewVHDSizeBytes 20GB -BootDevice CD -MemoryStartupBytes 2GB -Name RDS
Remove-Vmnetworkadapter –Vmware RDS –name “network adapter”
Add-VMNetworkAdapter -VMName AD -Name «Network Adapter» -SwitchName vm-switch

So now we run the same create vm command as we ran before just change the name and file name.
We install a full server with GUI this time since we want the remote desktop users to get a full desktop Smile
After the server is finished installing we need to setup the basic stuff as we did before.

New-Netipaddress –ipaddress 192.168.0.2 –interfacealias «Ethernet» –Prefixlenght 24
Set-DnsClientServerAddress -InterfaceAlias «Ethernet» -ServerAddresses 192.168.0.1
Rename-computer rds
Add-Computer -Domainname test.local –Credential
Restart-computer

This time we set the DNS client to point to the AD server. And change its name and join it to the domain. After the restart we have to install the RDS server role.
As we are going to host all the server roles on the same server (not very secure or recommended but simple Smile 

New-RDSessionDeployment -ConnectionBroker test02.test.local -WebAccessServer test02.test.local -SessionHost test02.test.local

Restart-Computer

 

Remove-RDSessionCollection QuickSessionCollection

New-RDSessionCollection -Collectionname Statistikk -sessionhost test02.test.local -connectionbroker test02.test.local

New-RDremoteApp -Collectionname Statistikk -Alias Notepad -Filepath C:\windows\system32\notepad.exe -ShowInWebAccess 1 -ConnectionBroker test02.test.local -Displayname skriveskrive

Now what this does is to 1: Install the RDS server roles and point to where each server role is located, and then restart the computer.
After that is done it removes the QuickSessionCollection as is created by default when using Quick Deployment.

Creates a new collection and points to which sessionshost and connection broker is included in this collection.
Then it publishes the application Notepad and makes in available to users via the RDweb portal.  And note I didn’t set up user profile disk on the RDS server yet since we need to set up the file server before we do that.

Now we have to create the file server, now this server needs to have multiple network cards and multiple disks in order to have High-availability.
So we start by creating the VM with multiple nics and hdds.

New-VM -NewVHDPath e:\vm\rds.vhdx -NewVHDSizeBytes 20GB -BootDevice CD -MemoryStartupBytes 2GB -Name FS

New-Netipaddress –ipaddress 192.168.0.3 –interfacealias «Ethernet» –Prefixlenght 24
Set-DnsClientServerAddress -InterfaceAlias «Ethernet» -ServerAddresses 192.168.0.1
Rename-computer fs
Add-Computer -Domainname test.local –Credential
Restart-computer

So here we create a fileserver virtual machine with 2 NICs and 3 virtual harddrives.
Drive 2 and 3 will be used for a storage pool with mirrored setup. Now setting up two virtual drives in a mirrored setup doesn’t make much sense but this is just to show how easy and flexible the deployment is.
Now after the server is finished installign and has joined the domain we can start by setting up the NIC teaming.

New-lbfoteam –name Test –Teammembers «ethernet 2», «ethernet» -loadbalancingalgorithm Ipaddresses –teamingmode switchindependent –teamnicname SuperPowah

You can run the command

get-lbfoteam and get-lbfoteamnic

To see the status of the team and the NIC (If its up and down or not )
Now what this does is to create a new load balance and failover team called Test, and it includes the two interfaces ethernet 2 and ethernet and the load balancing algorithm is based on IP addresses, and I choose the teaming mode switch independent and the team nice is called SuperPowah. Now that we have done that the first NIC loses it’s IP address settings so now we have to setup an IP setting for the new NIC name SuperPowah

New-Netipaddress –ipaddress 192.168.0.3 –interfacealias «SuperPowah» –Prefixlenght 24
Set-DnsClientServerAddress -InterfaceAlias «SuperPowah» -ServerAddresses 192.168.0.1

Next we have to install the dedup features (Which is not installed by default. )

Install-windowsfeature FS-data-deduplication

By default the schedule for a dedup job is set to default 5 days, but that can be changed. You can also run it manually by running the command.

Start-dedupjob –volume e: –type optimization

You can view the status by running the command

Get-dedupjob
get-dedupstatus

If you wish to remove dedup from a disk you can run the command

Start-dedupjob –volume e: –type unoptimization

Next we create a new folder on the new share then we share the folder.

mkdir userdata on C:\
new-smbshare –path c:\userdata –name userdata

Now after that share is created. We have to update the RDS collection configuration

Set-RDSessionCollectionConfiguration –Collectionname statistikk –EnableUserProfileDisk –diskpath \\fs\userdata –MaxProfileDiskSizeGB 40

So there you go, I will try to update this with some other scenarios as well.

#data-deduplication, #nic-teaming, #powershell, #rds, #smb-3-0, #windows-server-2012

Windows Server 2012 Storage redefined part 1

With Windows Server 2012, Microsoft has added loads of new features and functionality and I’m going to take a walkthrough of the new stuff.

Data Deduplication
Is the technology that allows you to eliminating duplicate copies of repeating data, so instead of storing the data twice you would just have a flag which points to the other data.
But a picture says more then a thousand words. Lets say you have a file which consists of these blocks and block 5 has a repeating data.
image
So instead of repeating that data, we can just setup a flag pointing to the original data and remove the duplicated data block.
image

So if you have a LARGE file with much duplicate data you will be able to reduce the data significantly.
So lets finish up with an example using WS2012.
First of we need to install the Data Deduplication feature.

image

After it is installed head back to the server manager –> File and Storage Servers –> Disks
And if you have a VM add a new HD to the VM and create a new disk and a new volume.

image

So from here press Configure Data Deduplication.

image

And press for Enable Data Deduplication. By default it starts deduplicating files that are older then 5 days. Set that 0 days for the purpose of this demo.
We are going to leave it at that, and press Apply –> OK.
Now go back the Volumes View.

image

You can see that Deduplication is enabled for that volume but since there is nothing on the volume yet there is nothing to deduplicate.
So what we are going to do now for the purpose of this demo is to create multiple VHD files on that volume.
NOTE: This part is just to demonstrate how deduplication works
Open Disk Management and choose create VHD

image

Enter a name for it and place it on the deduplicated volume. (Make it 3GB)
Open Explorer to the volume and make a copy of that VHD file in the same folder.
So now you should have 2 VHD files with the same usage
image

IF you head back to server manager now you can see that the free space decreased by 6 GB.
Go back and create one more VHD file. So you have 3 duplicate files.

Now the schedule says it dedupliates files older then 0 days, so we need to run a PowerShell command to do a manual job to get instant results.
Run the command Start-dedupjob –Type Optimization –Volume E: (In my case it is E: change the letter with the one you have)
After that you can enter the command get-dedupjob to see the status.

image

Now after this is done, go back to the volumes view on Server Manager. You can now see that Windows has saved 6 GB which is the equivalent of the 2 VHD files.
image

You can also view the Event Log for Deduplication events if you get some sorts of errors.
If you wish to remove deduplication on a volume you can run the command
Start-Dedupjob –Type DeOptimization.

There are also other options when running from PowerShell, you can see all the deduplication cmdlets by running

get-command –module deduplication.

So when to use dedupliction in a production environment?
Remember that deduplication is most useful where you have a lot of duplicate data. But Microsoft does not recommend that you use this for files that are constantly changing and for virtual machines.
For instance an VMM Library ISO share could be a good choice, you can also specify which types of files the deduplication should optimize but use it for most static files (Files that undergo little change)

Great candidates for deduplication:

  • Folder redirection servers
  • Virtualization depot or provisioning library
  • Software deployment shares
  • SQL Server and Exchange Server backup volumes

Should be evaluated based on content:

  • Line-of-business servers
  • Static content providers
  • Web servers
  • High-performance computing (HPC)

Not good candidates for deduplication:

  • Hyper-V hosts
  • VDI VHDs
  • WSUS
  • Servers running SQL Server or Exchange Server
  • Files approaching or larger than, 1 TB in size

This has been part 1 of Windows Server Storage, stay tuned.

#data-deduplication, #winows-server-2012