Tuesday, November 26, 2013

How to build a System Center Virtual Machine Manager 2012 R2 lab - part 6

Welcome again to this series of posts on configuring a Microsoft System Center Virtual Machine Manager 2012 R2 lab. In the previous post you configured an ISCSI Target Server on the virtual machine named LAB2013ISCSI01. The next step is to configure the ISCSI initiators (which are your two Hyper-V servers).

Open a remote desktop connection to  the first Hyper-V server (LAB2013HV01) and use Powershell to connect to the ISCSI Target Server (whose IP is 192.168.134.15):
New-IscsiTargetPortal -TargetPortalAddress 192.168.134.15
InitiatorInstanceName  :
InitiatorPortalAddress :
IsDataDigest           : False
IsHeaderDigest         : False
TargetPortalAddress    : 192.168.134.15
TargetPortalPortNumber : 3260
PSComputerName         :
In my case when I ran Connect-ISCSITarget it returned an error:
Connect-ISCSITarget -NodeAddress "iqn.1991-05.com.microsoft:lab2013hv01.lab2013.local"
connect-ISCSITarget : The target name is not found or is marked as hidden from login.
At line:1 char:1
That’s because I had made a typo entering the IP address of the Target server. To solve this I removed the wrong entry with:
Get-IscsiTargetPortal | ? targetportaladdress -like "192.168.1.15” | Remove-IscsiTargetPortal
and after re-adding it I was able to succesfully connect, as you can see here:
Get-iSCSITarget | Connect-iSCSITarget

AuthenticationType      : NONE
InitiatorInstanceName   : ROOT\ISCSIPRT\0000_0
InitiatorNodeAddress    : iqn.1991-05.com.microsoft:lab2013hv01.lab2013.local
InitiatorPortalAddress  : 0.0.0.0
InitiatorSideIdentifier : 400001370000
IsConnected             : True
IsDataDigest            : False
IsDiscovered            : True
IsHeaderDigest          : False
IsPersistent            : False
NumberOfConnections     : 1
SessionIdentifier       : ffffe00002584430-400001370000000b
TargetNodeAddress       : iqn.1991-05.com.microsoft:lab2013iscsi01-target01-tar
                          get
TargetSideIdentifier    : 0200
PSComputerName          :

AuthenticationType      : NONE
InitiatorInstanceName   : ROOT\ISCSIPRT\0000_0
InitiatorNodeAddress    : iqn.1991-05.com.microsoft:lab2013hv01.lab2013.local
InitiatorPortalAddress  : 0.0.0.0
InitiatorSideIdentifier : 400001370000
IsConnected             : True
IsDataDigest            : False
IsDiscovered            : True
IsHeaderDigest          : False
IsPersistent            : False
NumberOfConnections     : 1
SessionIdentifier       : ffffe00002584430-400001370000000a
TargetNodeAddress       : iqn.1991-05.com.microsoft:lab2013iscsi01-target03-tar
                          get
TargetSideIdentifier    : 0100
PSComputerName          :

AuthenticationType      : NONE
InitiatorInstanceName   : ROOT\ISCSIPRT\0000_0
InitiatorNodeAddress    : iqn.1991-05.com.microsoft:lab2013hv01.lab2013.local
InitiatorPortalAddress  : 0.0.0.0
InitiatorSideIdentifier : 400001370000
IsConnected             : True
IsDataDigest            : False
IsDiscovered            : True
IsHeaderDigest          : False
IsPersistent            : False
NumberOfConnections     : 1
SessionIdentifier       : ffffe00002584430-4000013700000009
TargetNodeAddress       : iqn.1991-05.com.microsoft:lab2013iscsi01-target02-tar
                          get
TargetSideIdentifier    : 0300
PSComputerName          :
Then you have to make these session persistent across reboots:
Get-iSCSISession | Register-iSCSISession
Repeat the same steps on the other Hyper-V host.
A check with Get-Disk should show you the newly mounted RAW partitions:
Get-Disk

Number Friendly Name                            Operationa Total Size Partition
                                                lStatus                Style
------ -------------                            ---------- ---------- ---------
0      VMware, VMware Virtual S SCSI Disk De... Online          60 GB MBR
1      MSFT Virtual HD SCSI Disk Device         Offline        120 GB RAW
2      MSFT Virtual HD SCSI Disk Device         Offline         10 GB RAW
3      MSFT Virtual HD SCSI Disk Device         Offline        120 GB RAW
At this point these disks must be brought online, initialized and partitioned but only on the first Hyper-V server (LAB2013HV01):
Get-disk –number 1 | % {
  $_ | Set-disk  –isreadonly 0
  $_ | Set-disk –isoffline 0
  $_ | initialize-disk –partitionstyle GPT
  $_ | new-partition –driveletter “F” –usemaximumsize
  Initialize-volume –driveletter “F” –filesystem NTFS –confirm:$false
}
Get-disk –number 2 | % {
  $_ | Set-disk  –isreadonly 0
  $_ | Set-disk –isoffline 0
  $_ | initialize-disk –partitionstyle GPT
  $_ | new-partition –driveletter “G” –usemaximumsize
  Initialize-volume –driveletter “G” –filesystem NTFS –confirm:$false
}
Get-disk –number 3 | % {
  $_ | Set-disk  –isreadonly 0
  $_ | Set-disk –isoffline 0
  $_ | initialize-disk –partitionstyle GPT
  $_ | new-partition –driveletter “H” –usemaximumsize
  Initialize-volume –driveletter “H” –filesystem NTFS –confirm:$false
}
Now your partitions should be ready:
Get-Disk

Number Friendly Name                            Operationa Total Size Partition
                                                lStatus                Style
------ -------------                            ---------- ---------- ---------
0      VMware, VMware Virtual S SCSI Disk De... Online          60 GB MBR
1      MSFT Virtual HD SCSI Disk Device         Online         120 GB GPT
2      MSFT Virtual HD SCSI Disk Device         Online          10 GB GPT
3      MSFT Virtual HD SCSI Disk Device         Online         120 GB GPT
On the other Hyper-V host run Update-Disk to make it aware of the existence of these new partitions. These three new iSCSI volume on LAB2013HV01 and LAB2013HV02 will behave just like directly-attached disk even though they are actually located elsewhere on the network. So, from the perspective of Hyper-V, the volume F:, G: and H: are just local volumes.
That's all for the moment concerning the configuration of the ISCSI back-end storage. Stay tuned for the next post on configuring a SCVMM lab!

Thursday, November 21, 2013

Powershell one-liner to check log files

Today I want to show you how Powershell can be used to search log files for specific strings of text and wait for updates (similarly to tail -f in the old unix world). Before the arrival of Powershell this was a pretty tedious activity involving lot of log file opening and closing. With the arrival of Powershell this task has become both easier and quicker than ever.

Let's suppose (this was my case today) that you have just joined a computer to a WSUS server and that you have some issue downloading the required patches. What you would do is to look for the Windows Update log file inside your Windows folder on your client computer.

In Powershell that's accomplished in a basic one-liner:
Get-ChildItem -Path C:\Windows *update*.log -Recurse | Get-Content -Wait | Select-String 'warning'
As you can see, I don't even know the exact name of the log file, nor the subfolder it resides in, but, with a little guessing, I can tell Powershell to look inside any subdirectory of c:\Windows for any log file contaning the word 'update' in its name, then pipe the result to Get-Content, which keeps the stream open and passes any update to the Select-String cmdlets. Select-string retrieves any line containing the 'warning' word and output it to the screen.

The result is stunning:
2013-11-20    16:01:10:783     832    160    AU      # WARNING: Failed to find updates with error code 800B0001
2013-11-20    16:01:12:346     832    8b4    Misc    WARNING: Digital Signatures on file C:\Windows\SoftwareDistribution\SelfUpdate\wuident.cab are not trusted: Error 0x800b0001
2013-11-20    16:01:12:346     832    8b4    Setup    WARNING: SelfUpdate check failed to download package information, error = 0x800B0001
2013-11-20    16:01:12:346     832    8b4    Agent      * WARNING: Skipping scan, self-update check returned 0x800B0001
2013-11-20    16:01:12:346     832    8b4    Agent      * WARNING: Exit code = 0x800B0001
There I have my error! Of course, if you're less lucky, you may need to try with different log file names, or with different words in the content, but the fact is that it's anyway easier than ever before.

Note that you can replace 'warning' with a regular expression if you want to do complicated inclusion or exclusion of log messages.

For instance, to search for the keyword 'error' or 'warning' use the following regex:
Get-ChildItem -Path C:\Windows *update*.log -Recurse | Get-Content -Wait | Select-String "warning|error"
On Powershell 2.0 (which is the Powershell version of the computer I had a problem with) this can be shortened to:
gci C:\Windows *update*.log -rec | gc -Wai | Select-String "warning|error"
Not bad, isn't it? Stay tuned for more fun with Powershell.

Wednesday, November 20, 2013

How to build a System Center Virtual Machine Manager 2012 R2 lab - part 5

In the previous post we setup two Hyper-V servers. Time has come to setup the storage back-end for your System Center Virtual Machine Manager 2012 R2 lab. No need for an alternative solution like FreeNas or OpenFiler because nowadays Windows Server 2012 R2 and Hyper-V Server 2012 R2 have some really cost-effective new storage options, such as Storage Spaces and Hyper-V over SMB 3.0. And of course you definitively want to take advantage of these features for your lab, so, “Winology”, here we come! Before you get started on this I suggest that you take a deep look at this Microsoft document that explains what’s new in the ISCSI Target Server in this last release: http://blogs.technet.com/b/filecab/archive/2013/07/31/iscsi-target-server-in-windows-server-2012-r2.aspx


Very well. Create a fourth virtual machine named LAB2013ISCSI01. This virtual machine will be installed as Server Core, and you will give it 192.168.134.15 as IP address. The steps to perform are the same you did for the three other VMs (the DC and the two Hyper-V servers), so start configuring networking:
Get-NetAdapter -Name Ethernet0 | % {
 $_ | Set-NetIPInterface -Dhcp Disabled
 $_ | New-NetIPAddress -IPAddress 192.168.134.15 -PrefixLength 24 -DefaultGateway 192.168.134.2
 $_ | Set-DnsClientServerAddress -ServerAddresses 192.168.134.10
}
then proceed to configure Remote Desktop and Windows Firewall. Concerning Windows Firewall, I invite you to use a function I wrote a few months back to disable it (you can check it out at http://www.happysysadm.com/2013/03/disabling-windows-firewall-in-powershell.html). This will be a good learning experience for any Powershell novice:


You have now to create the ISCSI targets. Let’s see which one of the available roles can help you:
Get-WindowsFeature | ? name -like *iscsi*

Display Name                                            Name
------------                                            ----
        [ ] iSCSI Target Server                         FS-iSCSITarget-Server
        [ ] iSCSI Target Storage Provider (VDS and V... iSCSITarget-VSS-VDS
Cool there you have it! A small tip: you don’t need the second listed role because providers are for remote Target management only, so you have to add the first role. Open Powershell, and run the following cmdlet:
Add-WindowsFeature FS-iSCSITarget-Server

Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
True    No             Success        {File and iSCSI Services, File Server,...
WARNING: Windows automatic updating is not enabled. To ensure that your newly-installed role or feature is automatically updated, turn on Windows Update.
To put in place the back-end storage, you will take advantage of the feature of Windows 2012 named Storage Spaces. Start to add three disks to the LAB2013ISCSI01 virtual machine:


Use Get-PhysicalDisk to check that these three physical disks are seen from Windows (this should happen straight away):
Get-PhysicalDisk

FriendlyName  CanPool       OperationalS HealthStatus Usage                Size
                            tatus
------------  -------       ------------ ------------ -----                ----
PhysicalDisk0 False         OK           Healthy      Auto-Select         60 GB
PhysicalDisk1 True          OK           Healthy      Auto-Select        100 GB
PhysicalDisk2 True          OK           Healthy      Auto-Select        100 GB
PhysicalDisk3 True          OK           Healthy      Auto-Select        100 GB
That’s very good. Now filter down only the disks that are available to be added to a Storage Pool:
Get-PhysicalDisk -CanPool $true

FriendlyName  CanPool       OperationalS HealthStatus Usage                Size
                            tatus
------------  -------       ------------ ------------ -----                ----
PhysicalDisk1 True          OK           Healthy      Auto-Select        100 GB
PhysicalDisk2 True          OK           Healthy      Auto-Select        100 GB
PhysicalDisk3 True          OK           Healthy      Auto-Select        100 GB
Notice that the switch that you find in many online documents –ispooled is wrong. This parameter do not exist. "Get-PhysicalDisk -CanPool $True" must be used instead.
Then we have to create the Storage Pool:
New-StoragePool -FriendlyName "LAB2013SPOOL01" -PhysicalDisks (Get-PhysicalDisk –CanPool $True) -StorageSubSystemFriendlyName ((Get-StorageSubSystem).Friendlyname)
FriendlyName    OperationalStat HealthStatus    IsPrimordial    IsReadOnly
                us
------------    --------------- ------------    ------------    ----------
LAB2013SPOOL01  OK              Healthy         False           False
Once the pool is ready, you have to set up a new virtual hard-disk on it. That’s done with the New-VirtualDisk cmdlet. This cmdlet has three possible storage layout:
  • simple (similar to RAID0, insecure but fast) 
  • mirror (similar to RAID1, increased reliability but reduced capacity) 
  • parity (similar to RAID5, protect against single disk failure)
Parity is the best possible layout in this scenario so go for it:
New-VirtualDisk -StoragePoolFriendlyName "LAB2013SPOOL01" -FriendlyName
LibraryDisk -ResiliencySettingName Parity -Size 250GB -ProvisioningType Thin
FriendlyName  ResiliencySet OperationalS HealthStatus IsManualAtta         Size
              tingName      tatus                     ch
------------  ------------- ------------ ------------ ------------         ----
LibraryDisk   Parity        OK           Healthy      False              250 GB
Proceed to the initialization of this disk and assign all the space to a X: partition with the help of the -UseMamimumSize switch:
Get-VirtualDisk -FriendlyName "LibraryDisk" | % {
 $_ | get-disk | Initialize-Disk -PartitionStyle "GPT"
 $_ | get-disk | New-Partition -DriveLetter X -UseMaximumSize
}
PartitionNumber  DriveLetter Offset                    Size Type
---------------  ----------- ------                    ---- ----
2                X           135266304            249.87 GB Basic
Format-Volume -DriveLetter X -FileSystem NTFS -NewFileSystemLabel "LibraryPartition”
DriveLetter FileSystemL FileSystem  DriveType  HealthStat SizeRemain       Size
            abel                               us                ing
----------- ----------- ----------  ---------  ---------- ----------       ----
X           LibraryP... NTFS        Fixed      Healthy     249.75 GB  249.87 GB
Now, since you are in a lab and you want to test as many cmdlets as possible, why not to enable the Deduplication mechanism we have already explored in past posts:
Add-WindowsFeature FS-Data-Deduplication
Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
True    No             Success        {Data Deduplication}
WARNING: Windows automatic updating is not enabled. To ensure that your newly-installed role or feature is automatically updated, turn on Windows
Update.
Import-Module Deduplication
Enable-DedupVolume -Volume X:

Enabled            UsageType          SavedSpace           SavingsRate
-------            ---------          ----------           -----------
True               Default            0 B                  0 %
It’s time now to create a Logical Unit (LU) in the form of a VHDX file on that partition.

Note how the extension has changed from VHD under Windows 2012 to VHDX under Windows 2012 R2. The main difference is that a VHD can be as large as 2TB where VHDX can go up to 64TB. Also VHDX are more resilient to VM hard shutdown.

The next cmdlet to use is New-IscsiVirtualDisk: what it actually does is to create a new iSCSI Virtual Hard Disk (VHDX) object with the specified file path and size. After the iSCSI VHDX object has been created, the virtual disk will be assigned to an iSCSI target. Then, once any allowed initiator connects to that target, it will have access to the virtual disk.
New-IscsiVirtualDisk -Path x:\LUN01.vhdx -size 10GB

ClusterGroupName   :
ComputerName       : LAB2013ISCSI01.lab2013.local
Description        :
DiskType           : Dynamic
HostVolumeId       : {C79A68FA-24D7-455A-907A-59E33B9DFA76}
LocalMountDeviceId :
OriginalPath       :
ParentPath         :
Path               : x:\LUN01.vhdx
SerialNumber       : FED7206D-8E1B-46B5-A495-9FB6B59CFE26
Size               : 10737418240
SnapshotIds        :
Status             : NotConnected
VirtualDiskIndex   : 286335802
New-IscsiVirtualDisk -Path x:\LUN02.vhdx -size 120GB

ClusterGroupName   :
ComputerName       : LAB2013ISCSI01.lab2013.local
Description        :
DiskType           : Dynamic
HostVolumeId       : {C79A68FA-24D7-455A-907A-59E33B9DFA76}
LocalMountDeviceId :
OriginalPath       :
ParentPath         :
Path               : x:\LUN02.vhdx
SerialNumber       : A369C59D-EAFE-462A-8645-5B8A33BA2A69
Size               : 128849018880
SnapshotIds        :
Status             : NotConnected
VirtualDiskIndex   : 232699603
New-IscsiVirtualDisk -Path x:\LUN03.vhdx -size 120GB

ClusterGroupName   :
ComputerName       : LAB2013ISCSI01.lab2013.local
Description        :
DiskType           : Dynamic
HostVolumeId       : {C79A68FA-24D7-455A-907A-59E33B9DFA76}
LocalMountDeviceId :
OriginalPath       :
ParentPath         :
Path               : x:\LUN03.vhdx
SerialNumber       : 25AA6011-239E-468D-9DB4-DD53EE7ED5B6
Size               : 128849018880
SnapshotIds        :
Status             : NotConnected
VirtualDiskIndex   : 673788947
You have just created three virtual disks (two bigger and one smaller, you'll see later why). Create now a new ISCSI target (pay attention to the type definition prefix IQN before the actual iqn and to the use of the array syntax @() to pass more than one IQN at the time):
New-IscsiServerTarget -TargetName Target01 -InitiatorIds @("IQN: iqn.1991-05.com.microsoft:lab2013hv01.lab2013.local","IQN: iqn.1991-05.com.microsoft:lab2013hv02.lab2013.local")
ChapUserName                :
ClusterGroupName            :
ComputerName                : LAB2013ISCSI01.lab2013.local
Description                 :
EnableChap                  : False
EnableReverseChap           : False
EnforceIdleTimeoutDetection : True
FirstBurstLength            : 65536
IdleDuration                : 00:00:00
InitiatorIds                : {Iqn:-iqn.1991-05.com.microsoft:lab2013hv01.lab2013.local,
                              Iqn:-iqn.1991-05.com.microsoft:lab2013hv02.lab2013.local}
LastLogin                   :
LunMappings                 : {}
MaxBurstLength              : 262144
MaxReceiveDataSegmentLength : 65536
ReceiveBufferCount          : 10
ReverseChapUserName         :
Sessions                    : {}
Status                      : NotConnected
TargetIqn                   : iqn.1991-05.com.microsoft:lab2013iscsi01-target01-target
TargetName                  : Target01
Repeat that step twice for the other VHDX:
New-IscsiServerTarget -TargetName Target02 -InitiatorIds @("IQN: iqn.1991-05.com.microsoft:lab2013hv01.lab2013.local","IQN: iqn.1991-05.com.microsoft:lab2013hv02.lab2013.local")
New-IscsiServerTarget -TargetName Target03 -InitiatorIds @("IQN: iqn.1991-05.com.microsoft:lab2013hv01.lab2013.local","IQN: iqn.1991-05.com.microsoft:lab2013hv02.lab2013.local")
Or (if you prefer to use the IP address, which I must admit it’s simpler):
New-IscsiServerTarget -TargetName Target01 -InitiatorIds ipaddress:192.168.134.20,ipaddress:192.168.134.21
New-IscsiServerTarget -TargetName Target02 -InitiatorIds ipaddress:192.168.134.20,ipaddress:192.168.134.21
New-IscsiServerTarget -TargetName Target03 -InitiatorIds ipaddress:192.168.134.20,ipaddress:192.168.134.21
Then assign each target to a specific VHDX:
Add-IscsiVirtualDiskTargetMapping Target01 X:\LUN01.vhdx
Add-IscsiVirtualDiskTargetMapping Target02 X:\LUN02.vhdx
Add-IscsiVirtualDiskTargetMapping Target03 X:\LUN03.vhdx
Ok, that’s all for the ISCSI Target Server configuration. Just note the Target IQN for reference:
Get-IscsiServerTarget | select targetIqn

TargetIqn
---------
iqn.1991-05.com.microsoft:lab2013iscsi01-target03-target
iqn.1991-05.com.microsoft:lab2013iscsi01-target02-target
iqn.1991-05.com.microsoft:lab2013iscsi01-target01-target
Time to configure the ISCSI initiators on the Hyper-V servers, which I will explain in the next post!

Wednesday, November 13, 2013

How to build a System Center Virtual Machine Manager 2012 R2 lab - part 4

In the previous post you saw how to setup your Active Directory Forest. Now you'll see how to deploy two Hyper-V hosts in that security context.



Set-up a new virtual machine using the Hyper-V 2012 R2 iso image: en_microsoft_hyper-v_server_2012_r2_x64_dvd_2708236.iso
When asked for the guest operating system choose Microsoft Windows / Hyper-V (unsupported). The fact that even VMWare Workstation 10 (which has just been released) says 'unsupported' means that our lab should work but VMWare does not endorse any responsibility for failure. Who cares, since we are just beta-testing this for the moment.

In VMWare Workstation 10, when configuring a virtual machine, you have the choice between four mode for running guest code:
  • Automatic: Workstation chooses the execution mode based on the guest operating system and the host CPU. 
  • Binary translation: Workstation uses a mix of directly executing guest code and binary translation to run the guest operating system. Guest memory mapping is performed by using shadow page tables. 
  • Intel VT-x or AMD-V: Workstation uses hardware extensions to run and isolate guest code. Guest memory mapping is performed by using shadow page tables. 
  • Intel VT-x/EPT or AMD-V/RVI: Workstation uses hardware extensions to run and isolate guest code. Guest memory mapping is performed by using hardware paging.
Choose Intel VT. Obviously this is not a supported configuration and probably not the ideal way to test out Hyper-V, but, as I said, who cares, we are here only to learn and test.
The virtual machine boots on the installation of Hyper-V and once you have chosen your regional options just use ALT+I to start the installation. This process will be quite quick. I am still impressed by the effort Microsoft has done to improve the ease of installation, which, just a few years back (I am talking about Windows 2003) was still long and asked for too much interaction. Also Microsoft has removed all that dull advertising about built-in functionality that nobody read:

What you will notice at this time is that the installation interface does not ask for a licence. That’s because Microsoft has put in place a very aggressive strategy to demote VMWare from their position of leader of the virtualization market. Microsoft propose a totally free of charge hypervisor and you’ll pay just the licences for your guest virtual machines (which probably you already have). Moving from VMWare ESXi to Microsoft Hyper-V represents today a wise economical move. Regarding this I deeply suggest that your read the last article published on Technet by Andrew Fryer (@deepfat) explaining this point inside-out: http://blogs.technet.com/b/uktechnet/archive/2013/10/24/is-it-time-to-upgrade-your-hypervisor.aspx

Another thing you will notice is that the installation process does not ask wheter you want to setup your system with a GUI or in Core mode. That’s because Server Core is the only possible option for an hypervisor in order to minimize the overhead.
Once the installation has completed, choose your local administrator password and log in. The usual boring sconfig blue window will appear. Interestingly enough, the number of options has changed compared to what we had in a standard full blown Windows 2012 R2 installation: the option ‘Windows Activation’ is missing since unneeded, as we have just discussed. So choose option 14 and then launch Windows Powershell.

Install the VMWare Tools:

Then, after the system has rebooted, proceed with a configuration of the network interface. For sake of simplicity you should have just one network interface at the moment on this virtual machine. Pay attention to the use of the cmdlet Set-DnsClientServerAddress, which is used to specify the IP address of the DNS server. If you omit this, your VM won’t be able to find the Domain name LAB2013 when joining it.
Get-NetAdapter -Name Ethernet0 | % {
  $_ | Set-NetIPInterface -Dhcp Disabled
  $_ | New-NetIPAddress -IPAddress 192.168.134.20 -PrefixLength 24 -DefaultGateway 192.168.134.2
  $_ | Set-DnsClientServerAddress -ServerAddresses 192.168.134.10
  }

IPAddress         : 192.168.134.20
InterfaceIndex    : 13
InterfaceAlias    : Ethernet0
AddressFamily     : IPv4
Type              : Unicast
PrefixLength      : 24
PrefixOrigin      : Manual
SuffixOrigin      : Manual
AddressState      : Tentative
ValidLifetime     : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource      : False
PolicyStore       : ActiveStore

IPAddress         : 192.168.134.20
InterfaceIndex    : 13
InterfaceAlias    : Ethernet0
AddressFamily     : IPv4
Type              : Unicast
PrefixLength      : 24
PrefixOrigin      : Manual
SuffixOrigin      : Manual
AddressState      : Invalid
ValidLifetime     : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource      : False
PolicyStore       : PersistentStore
The next thing to do is to rename this virtual machine to a meaningful name (LAB2013HV01 for this first Hyper-V machine):
Rename-Computer –NewName LAB2013HV01 –Restart
The server will restart. A quick check with Get-WMIObject will return the new name:
Get-WmiObject -Class win32_computersystem
Domain              : WORKGROUP
Manufacturer        : VMware, Inc.
Model               : VMware Virtual Platform
Name                : LAB2013HV01
PrimaryOwnerName    : Windows User
TotalPhysicalMemory : 1073201152
Now use the two commands we saw in the previous post to disable the firewall and enable remote desktop connections on a Windows 2012 R2 server:
netsh advfirewall set allprofiles state off
and
cscript C:\Windows\System32\Scregedit.wsf /ar 0
The next action is to join the domain LAB2013.local:
Add-computer –DomainName LAB2013.local –Restart
The system should ask you for your very secure credentials, join the domain and restart afterward.


It’s worth of note that during shutdown the following message text appears:

This message is specific to the Hyper-V core iso you used.
Since you will be using a Windows 2012 R2 server as back-end storage, configured as ISCSI Target Server, you have to launch the ISCSI initiator service. This can be done in Powershell:
Start-Service MSiSCSI
WARNING: Waiting for service 'Microsoft iSCSI Initiator Service (MSiSCSI)' to start...
Set-Service MSiSCSI -StartupType Automatic
Now you can get the iSCSI Qualified Name (iQN) of the initiator by running iscsicli.exe:
iscsicli.exe
Microsoft iSCSI Initiator Version 6.3 Build 9600
[iqn.1991-05.com.microsoft:lab2013hv01.lab2013.local] Enter command or ^C to exit
Take note the IQN (Microsoft IQNs use the iqn.1991-05.com.microsoft prefix: this corresponds to the date the domain Microsoft.com was first registered, if you did not knew).
A quick final check:
Get-WindowsFeature | ? installed

Display Name                                            Name
------------                                            ----
[X] File and Storage Services                           FileAndStorage-Services
    [X] Storage Services                                Storage-Services
[X] Hyper-V                                             Hyper-V
[X] .NET Framework 4.5 Features                         NET-Framework-45-Fea...
    [X] .NET Framework 4.5                              NET-Framework-45-Core
    [X] WCF Services                                    NET-WCF-Services45
        [X] TCP Port Sharing                            NET-WCF-TCP-PortShar...
[X] SMB 1.0/CIFS File Sharing Support                   FS-SMB1
[X] Windows PowerShell                                  PowerShellRoot
    [X] Windows PowerShell 4.0                          PowerShell
[X] WoW64 Support                                       WoW64-Support
Now your first Hyper-V server is ready. Repeat all the steps for a second Hyper-V (which you will name LAB2013HV02) in order to have the minimum number of servers to build a basic cluster. Here’s a quick memento of the cmdlets you should use to configure the second server:
Get-NetAdapter -Name Ethernet0 | % {
$_ | Set-NetIPInterface -Dhcp Disabled
$_ | New-NetIPAddress -IPAddress 192.168.134.21 -PrefixLength 24 -DefaultGateway 192.168.134.2
$_ | Set-DnsClientServerAddress -ServerAddresses 192.168.134.10
}
Rename-Computer –NewName LAB2013HV02 –Restart
netsh advfirewall set allprofiles state off
cscript C:\Windows\System32\Scregedit.wsf /ar 0
Add-computer –DomainName LAB2013.local –Restart
Start-Service MSiSCSI
Set-Service MSiSCSI -StartupType Automatic
iscsicli
Note the IQN. Once you have done all that, a second Hyper-V will be ready and it's time to configure the ISCSI Target Server. Stay tuned.

How to build a System Center Virtual Machine Manager 2012 R2 lab - part 3

In the previous post you saw how to deploy a basic Windows 2012 R2 virtual machine. Now you have to install Active Directory Directory Services on it. This has become easy and risk free since the arrival of the Active Directory cmdlets (...our good old friend DCPROMO has long gone and won't be missed). Let's see how that's done:
Install-WindowsFeature AD-Domain-Services
You will see following information after finishing the install of the AD DS feature:
Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
True    No             Success        {Active Directory Domain Services, Rem...
WARNING: Windows automatic updating is not enabled. To ensure that your newly-installed role or feature is automatically updated, turn on Windows Update.
Once you have installed the AD DS feature, you have to find out which module you need to setup your Active Directory Forest. You can achieve that with Get-Help because nowadays this basic Powershell cmdlet is able to check inside modules that have not been imported yet:
man forest

Name                              Category  Module                    Synopsis
----                              --------  ------                    --------
Get-ADForest                      Cmdlet    ActiveDirectory           Get-AD...
Set-ADForest                      Cmdlet    ActiveDirectory           Set-AD...
Set-ADForestMode                  Cmdlet    ActiveDirectory           Set-AD...
Install-ADDSForest                Cmdlet    ADDSDeployment            Instal...
Test-ADDSForestInstallation       Cmdlet    ADDSDeployment            Test-A...
As you can see the module we need is ADDSDeployment and importing it is a breeze:
Import-Module ADDSDeployment
Now, before you proceed, use the following brand new cmdlet to check that all the important prerequisites are met:
Test-ADDSForestInstallation
cmdlet Test-ADDSForestInstallation at command pipeline position 1
Supply values for the following parameters:
DomainName: lab2013.local
SafeModeAdministratorPassword: ********************
Confirm SafeModeAdministratorPassword: ********************
WARNING: Windows Server 2012 R2 domain controllers have a default for the security setting named "Allow cryptography algorithms compatible with Windows NT 4.0" that prevents weaker cryptography algorithms when establishing security channel sessions.

For more information about this setting, see Knowledge Base article 942564
(http://go.microsoft.com/fwlink/?LinkId=104751).

WARNING: A delegation for this DNS server cannot be created because the authoritative parent zone cannot be found or it does not run Windows DNS server. If you are integrating with an existing DNS infrastructure, you should manually create a delegation to this DNS server in the parent zone to ensure reliable name resolution from outside the domain "lab2013.local". Otherwise, no action is required.

Message             Context                  RebootRequired              Status
-------             -------                  --------------              ------
Operation comple... Test.VerifyDcPro...               False             Success
The last warning you get it’s not really an issue because this is the first DNS server you're installing. Now get to install the forest for real:
Install-ADDSForest -CreateDnsDelegation:$false -DomainName "lab2013.local" -InstallDns:$true -NoRebootOnCompletion:$false -Force:$true –SafeModeAdministratorPassword (Get-Credential).Password
Powershell beginners, remark here the smart use of (Get-Credential).Password.

As you can see from the previous screenshot, the installation of the DNS role is automatically managed by Install-ADDSForest. After the reboot, you have a brand new DC for your new forest lab2013.local. Straightforward, right?
I like adding -NoRebootOnCompletion:$false to Install-ADDSForest (don't do that in a Production environment!). After the server has rebooted, you can quickly make a verification using this improved Powershell V4 syntax:
Get-WindowsFeature | ? installed
Display Name                                            Name
------------                                            ----
[X] Active Directory Domain Services                    AD-Domain-Services
[X] DNS Server                                          DNS
[X] File and Storage Services                           FileAndStorage-Services
    [X] File and iSCSI Services                         File-Services
        [X] File Server                                 FS-FileServer
    [X] Storage Services                                Storage-Services
[X] .NET Framework 4.5 Features                         NET-Framework-45-Fea...
    [X] .NET Framework 4.5                              NET-Framework-45-Core
    [X] WCF Services                                    NET-WCF-Services45
        [X] TCP Port Sharing                            NET-WCF-TCP-PortShar...
[X] Remote Server Administration Tools                  RSAT
    [X] Role Administration Tools                       RSAT-Role-Tools
        [X] AD DS and AD LDS Tools                      RSAT-AD-Tools
            [X] Active Directory module for Windows ... RSAT-AD-PowerShell
[X] SMB 1.0/CIFS File Sharing Support                   FS-SMB1
[X] User Interfaces and Infrastructure                  User-Interfaces-Infra
[X] Windows PowerShell                                  PowerShellRoot
    [X] Windows PowerShell 4.0                          PowerShell
[X] WoW64 Support                                       WoW64-Support
If you want to check the log of the upgrade, it's named %systemroot%\debug\dcpromo.log. The Get-ADDomain is also an interesting cmdlet to dump your domain configuration:
Get-ADDomain

AllowedDNSSuffixes                 : {}
ChildDomains                       : {}
ComputersContainer                 : CN=Computers,DC=lab2013,DC=local
DeletedObjectsContainer            : CN=Deleted Objects,DC=lab2013,DC=local
DistinguishedName                  : DC=lab2013,DC=local
DNSRoot                            : lab2013.local
DomainControllersContainer         : OU=Domain Controllers,DC=lab2013,DC=local
DomainMode                         : Windows2012R2Domain
DomainSID                          : S-1-5-21-3144066328-731786587-829956889
ForeignSecurityPrincipalsContainer : CN=ForeignSecurityPrincipals,DC=lab2013,DC
                                     =local
Forest                             : lab2013.local
InfrastructureMaster               : LAB2013DC01.lab2013.local
LastLogonReplicationInterval       :
LinkedGroupPolicyObjects           : {CN={31B2F340-016D-11D2-945F-00C04FB984F9}
                                     ,CN=Policies,CN=System,DC=lab2013,DC=local
                                     }
LostAndFoundContainer              : CN=LostAndFound,DC=lab2013,DC=local
ManagedBy                          :
Name                               : lab2013
NetBIOSName                        : LAB2013
ObjectClass                        : domainDNS
ObjectGUID                         : 0e2f8e5f-8e4a-421d-92f7-a83856460e63
ParentDomain                       :
PDCEmulator                        : LAB2013DC01.lab2013.local
QuotasContainer                    : CN=NTDS Quotas,DC=lab2013,DC=local
ReadOnlyReplicaDirectoryServers    : {}
ReplicaDirectoryServers            : {LAB2013DC01.lab2013.local}
RIDMaster                          : LAB2013DC01.lab2013.local
SubordinateReferences              : {DC=ForestDnsZones,DC=lab2013,DC=local,
                                     DC=DomainDnsZones,DC=lab2013,DC=local,
                                     CN=Configuration,DC=lab2013,DC=local}
SystemsContainer                   : CN=System,DC=lab2013,DC=local
UsersContainer                     : CN=Users,DC=lab2013,DC=local
Now stop-computer (man, I start talking verb-cmdlet!) and reduce RAM to 512 MB (since you don't need 2GB on this Core install).
After the virtual machine has restarted, check that the new RAM configuration has been applied:
gwmi win32_computersystem

Domain              : lab2013.local
Manufacturer        : VMware, Inc.
Model               : VMware Virtual Platform
Name                : LAB2013DC01
PrimaryOwnerName    : Windows User
TotalPhysicalMemory : 536330240
and
gwmi win32_operatingsystem | select caption

caption
-------
Microsoft Windows Server 2012 R2 Datacenter
The two last steps are enabling Remote Desktop (RDP) connections and fully disabling the firewall (since we are in a test environment).
There is one simple way of disabling firewall:
netsh advfirewall set allprofiles state off
There are many ways to enable RDP. The simplest of all is to run:
cscript C:\Windows\System32\Scregedit.wsf /ar 0
Now you should be able to RDP inside the new VM.
Oh, I almost forgot to tell: later on you will need internet access (and therefore name resolution) to download the Windows ADK (which is a prerequisite for SCVMM), and since your DNS can’t resolve names residing on any external network (read: Internet), you must add a DNS forwarder: use the VMWare DNS you noted before: x.x.x.2
To add the DNS forwarder, Powershell 4.0 comes once again to the rescue:
Add-DnsServerForwarder -IPAddress 192.168.134.2 -PassThru
UseRootHint        : True
Timeout(s)         : 3
EnableReordering   : True
IPAddress          : {192.168.134.2, fec0:0:0:ffff::1, fec0:0:0:ffff::2,
                     fec0:0:0:ffff::3}
ReorderedIPAddress : {192.168.134.2, fec0:0:0:ffff::1, fec0:0:0:ffff::2,
                     fec0:0:0:ffff::3}
Once you have your first virtual machine running a Windows 2012 R2 Domain Controller, move on to the deployment of the Hyper-V servers.

Tuesday, November 12, 2013

Powershell cmdlets for HP iLO released

On October 17th, HP has released the first version of their HP Scripting Tools for Windows PowerShell, which are available for download here.
There are six available packages, depending on your OS version :
  • Microsoft Windows 7 (32-bit)
  • Microsoft Windows 7 (64-bit)
  • Microsoft Windows 8 (32-bit)
  • Microsoft Windows 8 (64-bit)
  • Microsoft Windows Server 2008 R2
  • Microsoft Windows Server 2012
Personally I downloaded the Windows 7 64 bits package, which is pretty small (less than 1MB)

As stated in the Readme file, "The HP Scripting Tools for Windows PowerShell provide a simplified and consistent infrastructure management experience. Starting with HP Integrated Lights-Out (iLO), this set of PowerShell utilities will grow over time to provide a comprehensive set of HP integration tools. It is designed for IT experts with experience in PowerShell scripting and configuring ProLiant server hardware."

This 1.0 release supports iLO3 and iLO4.

The prerequisite for this package of cmdlets is to have the WMF 3.0 (and therefore Powershell 3.0), as well as .NET 4.0.

To install it, launch the msi file named HPiLOCmdlets-x64.msiThe HP cmdlets are available out-of-the-box, since the installer add the HPiLOCmdlets module:
    Directory: C:\Program Files\Hewlett-Packard\PowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.0.0.0    HPiLOCmdlets                        {Add-HPiLOProfile, Add-HPiLOSSORecord, Add-HPiLOUser, Clea...
To check that the installation has completed successfully, run:
Get-HPiLOModuleVersion


Name             : HPiLOCmdlets
Path             : C:\Program Files\Hewlett-Packard\PowerShell\Modules\HPiLOCmdlets\HPiLOCmdlets.psm1
Description      : Cmdlets to interface with HP iLO
GUID             : 05545ade-5f25-4696-bfcc-e1d67fe32519
Version          : 1.0.0.0
UICultureName    : en-US
UICultureVersion : 1.0.0.0
In total there are 110 cmdlets:
Get-Command *hpilo*

CommandType     Name                                               ModuleName
-----------     ----                                               ----------
Function        Add-HPiLOProfile                                   HPiLOCmdlets
Function        Add-HPiLOSSORecord                                 HPiLOCmdlets
Function        Add-HPiLOUser                                      HPiLOCmdlets
Function        Clear-HPiLOAHSData                                 HPiLOCmdlets
Function        Clear-HPiLOEventLog                                HPiLOCmdlets
Function        Clear-HPiLOIML                                     HPiLOCmdlets
Function        Clear-HPiLOPowerOntime                             HPiLOCmdlets
Function        Disable-HPiLOERSIRSConnection                      HPiLOCmdlets
Function        Disable-HPiLOSecurityMessage                       HPiLOCmdlets
Function        Dismount-HPiLOVirtualMedia                         HPiLOCmdlets
Function        Enable-HPiLOERSIRSConnection                       HPiLOCmdlets
Function        Enable-HPiLOFIPS                                   HPiLOCmdlets
Function        Enable-HPiLOSecurityMessage                        HPiLOCmdlets
Function        Find-HPiLO                                         HPiLOCmdlets
Function        Get-HPiLOAHSStatus                                 HPiLOCmdlets
Function        Get-HPiLOAssetTag                                  HPiLOCmdlets
Function        Get-HPiLOCertificateSigningRequest                 HPiLOCmdlets
Function        Get-HPiLODefaultLanguage                           HPiLOCmdlets
Function        Get-HPiLODirectory                                 HPiLOCmdlets
Function        Get-HPiLOERSSetting                                HPiLOCmdlets
Function        Get-HPiLOEventLog                                  HPiLOCmdlets
Function        Get-HPiLOFan                                       HPiLOCmdlets
Function        Get-HPiLOFIPSStatus                                HPiLOCmdlets
Function        Get-HPiLOFirmwareInfo                              HPiLOCmdlets
Function        Get-HPiLOFirmwareVersion                           HPiLOCmdlets
Function        Get-HPiLOGlobalSetting                             HPiLOCmdlets
Function        Get-HPiLOHealthSummary                             HPiLOCmdlets
Function        Get-HPiLOHostAPO                                   HPiLOCmdlets
Function        Get-HPiLOHostData                                  HPiLOCmdlets
Function        Get-HPiLOHostPower                                 HPiLOCmdlets
Function        Get-HPiLOHostPowerMicroVersion                     HPiLOCmdlets
Function        Get-HPiLOHostPowerSaver                            HPiLOCmdlets
Function        Get-HPiLOHotKeyConfig                              HPiLOCmdlets
Function        Get-HPiLOIML                                       HPiLOCmdlets
Function        Get-HPiLOLanguage                                  HPiLOCmdlets
Function        Get-HPiLOLicense                                   HPiLOCmdlets
Function        Get-HPiLOMemoryInfo                                HPiLOCmdlets
Function        Get-HPiLOModuleVersion                             HPiLOCmdlets
Function        Get-HPiLONetworkSetting                            HPiLOCmdlets
Function        Get-HPiLONICInfo                                   HPiLOCmdlets
Function        Get-HPiLOOAInfo                                    HPiLOCmdlets
Function        Get-HPiLOOneTimeBootOrder                          HPiLOCmdlets
Function        Get-HPiLOPersistentBootOrder                       HPiLOCmdlets
Function        Get-HPiLOPowerAlertThreshold                       HPiLOCmdlets
Function        Get-HPiLOPowerCap                                  HPiLOCmdlets
Function        Get-HPiLOPowerOnTime                               HPiLOCmdlets
Function        Get-HPiLOPowerReading                              HPiLOCmdlets
Function        Get-HPiLOPowerSupply                               HPiLOCmdlets
Function        Get-HPiLOProcessor                                 HPiLOCmdlets
Function        Get-HPiLOProfile                                   HPiLOCmdlets
Function        Get-HPiLORackSetting                               HPiLOCmdlets
Function        Get-HPiLOSecurityMessage                           HPiLOCmdlets
Function        Get-HPiLOServerName                                HPiLOCmdlets
Function        Get-HPiLOSNMPIMSetting                             HPiLOCmdlets
Function        Get-HPiLOSpatial                                   HPiLOCmdlets
Function        Get-HPiLOSSOSetting                                HPiLOCmdlets
Function        Get-HPiLOStorageController                         HPiLOCmdlets
Function        Get-HPiLOTemperature                               HPiLOCmdlets
Function        Get-HPiLOUIDStatus                                 HPiLOCmdlets
Function        Get-HPiLOUser                                      HPiLOCmdlets
Function        Get-HPiLOUserInfo                                  HPiLOCmdlets
Function        Get-HPiLOUserList                                  HPiLOCmdlets
Function        Get-HPiLOVMStatus                                  HPiLOCmdlets
Function        Import-HPiLOCertificate                            HPiLOCmdlets
Function        Import-HPiLOSSHKey                                 HPiLOCmdlets
Function        Invoke-HPiLOProfileDownload                        HPiLOCmdlets
Function        Mount-HPiLOVirtualMedia                            HPiLOCmdlets
Function        Remove-HPiLOProfile                                HPiLOCmdlets
Function        Remove-HPiLOSSORecord                              HPiLOCmdlets
Function        Remove-HPiLOUser                                   HPiLOCmdlets
Function        Remove-HPiLOUserSSHKey                             HPiLOCmdlets
Function        Reset-HPiLOAdministratorPassword                   HPiLOCmdlets
Function        Reset-HPiLORIB                                     HPiLOCmdlets
Function        Reset-HPiLOServer                                  HPiLOCmdlets
Function        Set-HPiLOAHSStatus                                 HPiLOCmdlets
Function        Set-HPiLOAssetTag                                  HPiLOCmdlets
Function        Set-HPiLOBrownout                                  HPiLOCmdlets
Function        Set-HPiLOComputerLockConfig                        HPiLOCmdlets
Function        Set-HPiLODefaultLanguage                           HPiLOCmdlets
Function        Set-HPiLODirectory                                 HPiLOCmdlets
Function        Set-HPiLOFactoryDefault                            HPiLOCmdlets
Function        Set-HPiLOGlobalSetting                             HPiLOCmdlets
Function        Set-HPiLOHostAPO                                   HPiLOCmdlets
Function        Set-HPiLOHostPower                                 HPiLOCmdlets
Function        Set-HPiLOHostPowerSaver                            HPiLOCmdlets
Function        Set-HPiLOHotKeyConfig                              HPiLOCmdlets
Function        Set-HPiLOKerberosConfig                            HPiLOCmdlets
Function        Set-HPiLOLicenseKey                                HPiLOCmdlets
Function        Set-HPiLOLockConfiguration                         HPiLOCmdlets
Function        Set-HPiLONetworkSetting                            HPiLOCmdlets
Function        Set-HPiLOOneTimeBootOrder                          HPiLOCmdlets
Function        Set-HPiLOPassword                                  HPiLOCmdlets
Function        Set-HPiLOPersistentBootOrder                       HPiLOCmdlets
Function        Set-HPiLOPowerAlertThreshold                       HPiLOCmdlets
Function        Set-HPiLOPowerCap                                  HPiLOCmdlets
Function        Set-HPiLORBSUPOSTIP                                HPiLOCmdlets
Function        Set-HPiLOSchemalessDirectory                       HPiLOCmdlets
Function        Set-HpiLOServerName                                HPiLOCmdlets
Function        Set-HPiLOSharedNetworkPort                         HPiLOCmdlets
Function        Set-HPiLOSNMPIMSetting                             HPiLOCmdlets
Function        Set-HPiLOSSOSetting                                HPiLOCmdlets
Function        Set-HPiLOUIDStatus                                 HPiLOCmdlets
Function        Set-HPiLOUser                                      HPiLOCmdlets
Function        Set-HPiLOVirtualPowerButton                        HPiLOCmdlets
Function        Set-HPiLOVLAN                                      HPiLOCmdlets
Function        Set-HPiLOVMPortSetting                             HPiLOCmdlets
Function        Set-HPiLOVMStatus                                  HPiLOCmdlets
Function        Start-HPiLOERSAHSSubmission                        HPiLOCmdlets
Function        Start-HPiLOL2Collection                            HPiLOCmdlets
Function        Start-HPiLOTestEvent                               HPiLOCmdlets
For the moment I started playing with Find-HPiLO, but found no iLO on my subnets. Pretty strange since I have hundreds of them. I'll keep investigating and post here when I understand how this stuff works. Anyway it's a great thing the HP has adopted Powershell as administration language and this shows that this new Microsoft language is becoming both a de jure and de facto standard.

How to build a System Center Virtual Machine Manager 2012 R2 lab - part 2

While in the previous post I described the topology of this System Center Virtual Machine Manager 2012 R2 lab, in this post I will detail the steps required to deploy the one and only Active Directory Domain Controller.



Launch VMWare Workstation and fire the installation of the first virtual machine. When selecting the operating system, choose Windows Server 2012 (for evident reasons R2 hasn't been included in this list yet):

Keep the default network configuration to NAT so that Workstation will take care of setting up an internal DHCP. Since you are installing your lab on a single PC, you want to keep the OS memory footprint as low as possible. That’s why you will install this VM in Server Core mode (without a GUI). There are many articles on the Net explaining the advantages of Core over GUI. Here's some good references for you to read:
The initial virtual machine must be configured with 1 single processor and 2 GB of memory (you will reduce the amount of RAM at the end of the installation).
Boot on the Windows 2012 R2 iso image and once the installation has completed, log on the first time, change your password and there you’ll be facing a true old style windows:

Choose option 15 to exit to the command line and fire up Powershell.

Start the VMWare Tools installation for improved interaction and performance:


Restart the VM to make the VMWare drivers effective then start Powershell again.
Proceed with the configuration of the network adapter. For the moment it gets an IP from the internal DHCP. Take note of the IP address of the built-in VMWare default gateway and DNS server. It should be something like x.x.x.2. Then run this script to set a fixed IP address:
Get-NetAdapter -Name Ethernet0 | % {
   $_ | Set-NetIPInterface -Dhcp Disabled
   $_ | New-NetIPAddress 192.168.134.10 -PrefixLength 24 -DefaultGateway 192.168.134.2
}
Here's the output you will get from this command:
IPAddress         : 192.168.134.10
InterfaceIndex    : 12
InterfaceAlias    : Ethernet0
AddressFamily     : IPv4
Type              : Unicast
PrefixLength      : 24
PrefixOrigin      : Manual
SuffixOrigin      : Manual
AddressState      : Tentative
ValidLifetime     : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource      : False
PolicyStore       : ActiveStore

IPAddress         : 192.168.134.10
InterfaceIndex    : 12
InterfaceAlias    : Ethernet0
AddressFamily     : IPv4
Type              : Unicast
PrefixLength      : 24
PrefixOrigin      : Manual
SuffixOrigin      : Manual
AddressState      : Invalid
ValidLifetime     : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource      : False
PolicyStore       : PersistentStore
I really love the power of those *netadapter cmdlets that come with Powershell 4.0 and miss them each time I move to a server that has Powershell 3.0 or Powershell 2.0 or no Powershell at all (yes, I still have some...)!
Ok. The next step is renaming the server to an appropriate name:
Rename-Computer –NewName LAB2013DC01 –Restart
The server will restart. A quick check with Get-WMIObject will return the new name:
Get-WmiObject -Class win32_computersystem

Domain              : WORKGROUP
Manufacturer        : VMware, Inc.
Model               : VMware Virtual Platform
Name                : LAB2013DC01
PrimaryOwnerName    : Windows User
TotalPhysicalMemory : 2146942976
In the next post you are going to promote this VM to Domain Controller using Powershell and you will unleash all the power inside the ADDSDeployment module. Are you ready?

Monday, November 11, 2013

How to build a System Center Virtual Machine Manager 2012 R2 lab - part 1

In recent weeks Microsoft achieved the general availability (GA) release of three of its major products: Windows Server 2012 R2, Windows 8.1, and System Center 2012 R2. My first consideration on this is that Microsoft is moving very fast toward cloud-oriented solutions and, in most cases, big companies are having a hard time trying to keep up with the pace and with the great amount of features Microsoft is 'injecting' in the market. Take Windows Powershell 4.0, or SMB 3.0, or Data Deduplication, or Windows Azure, or IIS 8.5: system administrators must today strive to stay up-to-date and get set for the Cloud (be it Private or Public) while continuing to maintain their server farms up and running, and, even though some give up, it is my opinion that Microsoft is going the right way and that their recent products (starting from the 2008 R2 series) are rock solid.

I want here to take the occasion to show you how to deploy a full-blown lab based on Windows Server 2012 R2 and System Center Virtual Machine Manager (SCVMM) 2012 R2 running on top of one of the most useful piece of software I have ever used: VMWare Workstation 10.


I won't go in the details of the hardware configuration for this lab. Know just that all you need is an average VT-capable processor, a lot of memory (16GB, 32GB or even 64GB if you can afford it), and a quite large disk (SSD or not, this doesn't matter, but know that the former will give you a better user experience). I will be using Windows Server 2012 as host operating system, but any recent Microsoft OS will do.

Before I begin, let me tell you something. This lab is heavily Powershell-dependent. Microsoft has invested a lot on this language and you should do the same (in terms of time and engagement) if you want to mess with Windows 2012 R2. PowerShell is in fact Microsoft’s strategic task automation platform, a key component of Microsoft’s overall management strategy. It brings you a scripting environment, a script development tool (the PowerShell Integrated Scripting Environment aka ISE) and a huge amount of add-on functionality in the form of modules. So say goodbye to vbs and old style batch files and move forward.

Here's the topology of the lab once we will have gone through the whole procedure:



As you can see this lab requires 6 virtual machines, but if you want you can have more. You could for instance add another domain controller, or more Hyper-V hosts. So I am giving you just a general idea of what your lab should look like, but feel free to adapt it to your needs:
  • 192.168.134.10 : LAB2013AD01 : Active Directory for LAB2013.local
  • 192.168.134.20 : LAB2013HV01 : Hyper-V 01 / iqn.1991-05.com.microsoft:lab2013hv01.lab2013.local
  • 192.168.134.21 : LAB2013HV02 : Hyper-V 02 / iqn.1991-05.com.microsoft:lab2013hv02.lab2013.local
  • 192.168.134.15 : LAB2013ISCSI01 : ISCSI Target Server
  • 192.168.134.16 : LAB2013SQL01 : SQL Server
  • 192.168.134.17 : LAB2013VMM01 : SCVMM 2012 R2
  • 192.168.134.30 : LAB2013CLU01 : Hyper-V Cluster name

To start, get yourself the following sources:
  • VMWare Workstation 10
  • Microsoft Windows 2012 R2
  • Microsoft Hyper-V Server 2012 R2
  • SQL Server 2012 Enterprise Edition with Service Pack 1 (x64)
  • System Center 2012 R2 Virtual Machine Manager
In the next post you'll see how to deploy the Domain Controller of this lab, so stay tuned!
Related Posts Plugin for WordPress, Blogger...