VCAP5-DCA update…

September 6, 2014 – 5:45 pm

Well, I was planning on taking the exam in september but life events prevented me from reaching that goal. I had to undergo surgery twice for a detached retina in my right eye, with bedrest and impaired vision, I haven’t been much in a study mood. I also recently changed job, leaving consulting for a full time position as an infrastructure architect. Been busy!

I did manage to read through the VMware Press book: Networking for VMware Administrators, which I found interesting and provided good extra knowledge to help with the DCA exam.

I was planning on taking the 5.0 exam of the DCA but since I am postponing it until at least december, I will tackle the 5.5 version of the exam instead.

My biggest concern right now is to upgrade my lab for the next 3 years…

Customized AutoLab for VCAP5-DCA

April 5, 2014 – 7:42 pm

I have been busy for the past few weeks deconstructing and customizing the Autolab (http://www.labguides.com/) to suit my needs. I will start preparing for the VCAP5-DCA exam mid-may and while going through the blueprint, I will build a lab workbook to help myself and others prepare for the exam.

I wanted to start with a clean lab and Autolab was a great option! However it contained too many VMs that weren’t needed for my purpose and I wanted to adapt the naming convention to my personal standards.

While digging into it, I started wondering if I could automate the whole installation from start to finish. Well, I did it! 🙂

The lab contains a Domain Controller, NAS, virtual router, 2 ESXi hosts and vCenter server.

This script requires the lab to be hosted on a vSphere 5.x host with a vCenter instance (to deploy the multi-VMs OVF package).

Check it out and give me your feedback! Would love to hear what you think of it!

You can download it here (4GB): LabInstall

Note: The password everywhere in the environment is “Welcome!”

DeployLab

VCAP5-DCD Update

March 3, 2014 – 5:23 pm

Exam passed! I took the exam this morning and boy was that a beast. Even though I read all of the above, I felt unprepared for the exam as I went through it. Some parts were more technical than I expected (it’s a design cert isn’t it??) and some of the visio diagrams were fairly complex. I finished with 2 mins to spare, thanks to a glitch in the exam software that made me clear/reset a whole diagram to be able to resume it. The proctor told me afterwards that they extended the exam by 5 mins to compensate but I have no idea if that’s the case.

Well, I am very happy to have passed it, not with the score I would have hoped to get but  I managed to get through it. Now, onto the VCAP5-DCA! or the Cisco CCDA, or MCSE Exchange 2013… Nah, VMWare it is for 2014!

VCAP5-DCD Certification

January 19, 2014 – 4:02 pm

I am currently preparing for the VMware design certification for vSphere 5. I thought I would list here the resources I am using and hopefully what will result in a pass 🙂 This is the actual order I have used the materials. My approach to studying any topic is usually the same. Get a good global overview (CBT first usually), then deep dive into the material to get more detailed information. In this case, when I received the OCG, it was so small that I started with that. Took me 3 days to read it… I skipped the exercises for now but will get back to them after the CBT.

  1. VMware VCAP5-DCD Official Study Guide
  2. Pluralsight – Designing Vmware Infrastructure
  3. VMware vSphere 5.1 Clustering Deepdive
  4. Managing and Optimizing VMware vSphere Deployments
  5. VMware vSphere Design 2nd Edition

Still working on this, my exam is booked for the beginning of march 2014. Learning tidbits here and there, which should help me with future designs. Glad I’m doing this!

Sequencing virtual machines startup script

January 17, 2014 – 7:56 pm

Whether it’s for disaster recovery, maintenance or for your home lab, it’s nice to be able to start-up machines in a specific order without having to do it manually. You can do it with vApps, but there are operational drawbacks in doing so, from those pesky warnings when you shutdown/startup an individual VM, to the simple fact that a vApp is also a resource pool, which might not be something you need/want.

So I wrote this basic script to solve this problem. It’s really useful for my home lab, since I shut down everything when I’m done working. This way, I can simply fire up my hosts, run the sequencing script and there you go, back in action.

To ensure that VMs are started when the required services are available, configure your VM Tools service dependency to whatever service MUST be running before the next VM starts.

So here’s the script:

##############################################################################################################
#
# .SCRIPT INFO
#   Name       : SeqStart.ps1
#   Author     : Marc Bouchard
#   Revision   : January 16th, 2014
#
# .DESCRIPTION
#   This script starts VMs in the priority order defined in configuration files.
#   User is prompted for credentials for vCenter/Hosts
#
# .PARAMETERS
#   No parameters required
#
# .INPUT FILES
# 000-Hosts.000         = Contains the list of hosts to poll - can be individual hosts or vCenter server(s)
# 00x-description.00x   = VMs to load in specific order, one per line
#
# .EXAMPLE 1
#   PS> SeqStart
#
# .TO DO LIST
#
##############################################################################################################

# Parameters
Param (
    [Parameter(Mandatory=$false )] [string] $StrCounter = "001"
)

# Initialize
Clear-Host
Set-PowerCLIConfiguration -invalidCertificateAction "ignore" -confirm:$false | Out-Null

##############################################################################################################


# Ask for root credentials for ESXi hosts

while ($vCenterCreds -eq $null) 
{
   Write-Host (get-date -uformat %I:%M:%S) "Getting authentication credentials for hosts" -ForegroundColor Green;
   $vCenterCreds = $host.ui.PromptForCredential("VMware ESXi Login", "Please provide ESXi Hosts credentials", "", "")
}

# Check if file exists
if (Test-Path "*.000")
{
   # Read Host names from text file
   Get-Content "*.000" | Sort | ForEach-Object {Connect-VIServer $_ -Credential $vCenterCreds}|Out-Null
}
else
{
   # Error message
   Write-Host (get-date -uformat %I:%M:%S) "The specified Hosts file does not exist." -ForegroundColor Red;
   Exit
}

# Loop through the numbered tasks lists

$NumCounter = 1
$StrCounter="{0:000}" -f $NumCounter

while (Test-Path "*.$StrCounter" ) 
{
   # Read the file contents
   $VMList = Get-Content "*.$StrCounter"
   
   foreach ($VM in ($VMList))
      {
         # If the VM exists, start it!
         $ItExists = Get-VM -Name $VM
         if ($ItExists) {
            # Start VM and wait for VM Tools to be ready (VM Tools have to be setup for service dependency if required inside the VM)
            Write-Host (get-date -uformat %I:%M:%S) "Starting up $VM" -ForegroundColor Green
            Start-VM -VM $VM | Wait-Tools | Out-Null
         }
         else
         {
            Write-Host (get-date -uformat %I:%M:%S) "$VM does not exist" -ForegroundColor Red
         }
      }
   
   $NumCounter++
   $StrCounter="{0:000}" -f $NumCounter
}
# End of loop

# End of script

SCCM 2012 R2 Installation Script (Part 2)

December 30, 2013 – 2:41 pm

Here are the SQL scripts and the VBS.

EnableMicrosoftUpdate.vbs

Set ServiceManager = CreateObject("Microsoft.Update.ServiceManager") 
ServiceManager.ClientApplicationID = "My App" 
'add the Microsoft Update Service by GUID 
Set NewUpdateService = ServiceManager.AddService2("7971f918-a847-4430-9279-4a52d1efe18d",7,"")

This is the SQL Configuration File

SQL2012-ConfigurationFile.ini

[OPTIONS]

IACCEPTSQLSERVERLICENSETERMS="True"

SAPWD="Welcome!"

ACTION="Install"
ENU="True"
QUIET="False"
QUIETSIMPLE="True"
UpdateEnabled="True"
FEATURES=SQLENGINE,SSMS,ADV_SSMS
UpdateSource="MU"
HELP="False"
INDICATEPROGRESS="False"
X86="False"
INSTALLSHAREDDIR="D:\Program Files\Microsoft SQL Server"
INSTALLSHAREDWOWDIR="D:\Program Files (x86)\Microsoft SQL Server"
INSTANCENAME="MSSQLSERVER"
INSTANCEID="MSSQLSERVER"
SQMREPORTING="False"
ERRORREPORTING="False"
INSTANCEDIR="E:\SQLInst"
AGTSVCACCOUNT="NT AUTHORITY\SYSTEM"
AGTSVCSTARTUPTYPE="Automatic"
COMMFABRICPORT="0"
COMMFABRICNETWORKLEVEL="0"
COMMFABRICENCRYPTION="0"
MATRIXCMBRICKCOMMPORT="0"
SQLSVCSTARTUPTYPE="Automatic"
FILESTREAMLEVEL="0"
ENABLERANU="False"
SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS"
SQLSVCACCOUNT="NT AUTHORITY\SYSTEM"
SQLSYSADMINACCOUNTS="BUILTIN\Administrators"
SECURITYMODE="SQL"
SQLBACKUPDIR="F:\SQLBack"
SQLUSERDBDIR="E:\SQLData"
SQLTEMPDBDIR="E:\SQLTemp"
ADDCURRENTUSERASSQLADMIN="False"
TCPENABLED="1"
NPENABLED="0"
BROWSERSVCSTARTUPTYPE="Disabled"

And last, the SQL script to set the memory sizes (didn’t find this info in the unattended script above. Would have been nice but it works with this 🙂 )

SetSQLMemory.sql

USE master

EXEC sp_configure 'show advanced options',1
RECONFIGURE WITH OVERRIDE
GO

USE master
EXEC sp_configure 'min server memory (MB)',8192
EXEC sp_configure 'max server memory (MB)',8192
EXEC sp_configure 'show advanced options',0
RECONFIGURE WITH OVERRIDE
GO

SCCM 2012 R2 Installation Script (Part 1)

December 30, 2013 – 2:31 pm

Well, as promised here is the script to setup all the pre-reqs for SCCM 2012 R2.

To run this, you need to copy the files in the D: drive.

You need:

  • An SQL configuration file (SQL2012-ConfigurationFile.ini)
  • An SQL script to set the memory sizes (SetSQLMemory.sql)
  • A VBS script to enable the Windows Update feature (EnableMicrosoftUpdate.vbs)
  • WUInstall (from this link: http://www.wuinstall.com/index.php/en)
  • This script (Install-SCCM2012R2.ps1)
##############################################################################
#
# Script       : SCCM Server Complete Build
# Author       : Marc Bouchard
# Revision     : 12/27/2013
# Description  : Complete installation after base OS deployment
# Parameters   : None
#
##############################################################################

#=============================================================================
# Active Directory integration

Function CheckDomainMembership
{
   write-host -fore green "Checking if server is member of a domain..."
   $ADMember=$false
   do
   {
      if ((gwmi win32_computersystem).partofdomain -eq $false) 
      {
         write-host -fore green "Joining Domain"
         $domain = Read-Host -Prompt "Enter Domain name to join"
         $user = Read-Host -Prompt "Enter User account with DomainJoin permissions [Administrator]"
         if ($user -eq "") {$user="Administrator"}
         $password = Read-Host -Prompt "Enter password for $user" -AsSecureString 
         $username = "$domain\$user" 
         $credential = New-Object System.Management.Automation.PSCredential($username,$password) 
         Add-Computer -DomainName $domain -Credential $credential

$msgtxt = @"
The server must now restart to join the domain.
`
Please log back in with a domain account that has 
ADMINISTRATIVE RIGHTS in order to update the schema.
`
Simply relaunch this script to continue after reboot.
"@

               $Message = new-object -comobject wscript.shell 
               $intAnswer = $Message.popup($msgtxt, 0,"Confirmation",0) 
               Restart-Computer         
      } 
      else
      {
         $ADMember=$true
         write-host -fore green "Server is joined to domain..."
      }
   }
   until ($ADMember -eq $true)
}

#=============================================================================
Function InstallSQLServer
{
   #==============================================
   # Install SQL Server binaries                  
   #==============================================
   do 
   {
      Write-Host "Insert SQL Server 2012 DVD and press any key to continue ..." -ForegroundColor White
      $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
   }
   until (Test-Path -path "R:\setup.exe")

   if (!(Test-Path -path "D:\Scripts\SQL2012-ConfigurationFile.ini"))
   {
      Write-Host "SQL Configuration file missing. Aborting..." -ForegroundColor White
      Break
   }
   Write-Host "Installing SQL Server 2012" -ForegroundColor Green
   CMD /C R:\SETUP /ConfigurationFile=D:\Scripts\SQL2012-ConfigurationFile.ini | Out-Null

   #==============================================
   # Configure Memory Limits
   #==============================================

   CMD /C "D:\Program Files\Microsoft SQL Server\110\Tools\Binn\OSQL.EXE" -E -i D:\Scripts\SetSQLMemory.sql | Out-Null

   #==============================================
   # CONFIGURE SQL INTEGRATED AUTHENTICATION MODE 
   #==============================================

   Write-Host "Set SQL Authentication Mode" -ForegroundColor Green

   # Connect to the instance using SMO
   [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null
   $s = new-object ('Microsoft.SqlServer.Management.Smo.Server') $env:COMPUTERNAME

   # Get current Authentication Mode
   [string]$nm = $s.Name
   [string]$mode = $s.Settings.LoginMode

   If ($mode -ne "Integrated")
   {
      #Change to Integrated Mode
      $s.Settings.LoginMode = [Microsoft.SqlServer.Management.SMO.ServerLoginMode]::Integrated

      # Make the changes
      $s.Alter()

      NET STOP SQLSERVERAGENT
      NET STOP MSSQLSERVER
      NET START MSSQLSERVER
      NET START SQLSERVERAGENT
   }

   #==============================================
   # Install Latest updates
   #==============================================
   Write-Host "Install latest updates for SQL and OS" -ForegroundColor Green
   CMD /C cscript D:\Scripts\EnableMicrosoftUpdate.vbs /nologo

   #!!! Loop WUinstall until no more updates (errorlevel 2)
   D:\Scripts\WUInstallAMD64.exe /install

}

#=============================================================================
# Main Program
#=============================================================================

CLS
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force

#==============================================
# Set Automatic Windows Update
#==============================================
Write-Host "Enabling Automatic Windows Updates" -ForegroundColor Green
CMD /C cscript %windir%\system32\scregedit.wsf /AU 4

#==============================================
# Execute Custom Functions
#==============================================

CheckDomainMembership
InstallSQLServer

#==============================================
# Install required features 
#==============================================

Write-Host "Installing Features" -ForegroundColor Green

Install-WindowsFeature RSAT | Out-Null
Install-WindowsFeature Web-Windows-Auth | Out-Null
Install-WindowsFeature Web-ISAPI-Ext | Out-Null
Install-WindowsFeature Web-Metabase | Out-Null
Install-WindowsFeature Web-WMI | Out-Null
Install-WindowsFeature BITS | Out-Null
Install-WindowsFeature RDC | Out-Null
Install-WindowsFeature NET-Framework-Features | Out-Null
Install-WindowsFeature Web-Asp-Net | Out-Null
Install-WindowsFeature Web-Asp-Net45 | Out-Null
Install-WindowsFeature NET-HTTP-Activation | Out-Null
Install-WindowsFeature NET-Non-HTTP-Activ | Out-Null

#==============================================

Import-Module ActiveDirectory
Get-Module ServerManager | Out-Null

#==============================================
# Fix Firewall Rules
#==============================================

Write-Host "Modify Firewall Rules" -ForegroundColor Green
CMD /C netsh advfirewall firewall add rule name="SQL / SQL Replication" dir=in protocol=tcp localport="1433,4022"  action=Allow

#==============================================
# Install WSUS
#==============================================

Write-Host "Installing WSUS" -ForegroundColor Green
Install-WindowsFeature -Name UpdateServices-Services,UpdateServices-DB -IncludeManagementTools | Out-Null
CMD /C "C:\Program Files\update services\tools\wsusutil.exe" postinstall CONTENT_DIR=E:\Sources\WSUS\WSUS SQL_INSTANCE_NAME=$env:COMPUTERNAME

#==============================================
# Install ADK
#==============================================
Write-Host "Installing ADK" -ForegroundColor Green
$dwnld = "D:\Scripts\Downloads"
if (!(Test-Path -path $dwnld))
 {
 New-Item $dwnld -type directory | Out-Null
 }
$object = New-Object Net.WebClient
$ADKurl = 'http://download.microsoft.com/download/6/A/E/6AEA92B0-A412-4622-983E-5B305D2EBE56/adk/adksetup.exe'
$object.DownloadFile($ADKurl, "$dwnld\adksetup.exe")
Start-Process -FilePath "$dwnld\adksetup.exe" -Wait -ArgumentList "/quiet /features OptionId.DeploymentTools OptionId.WindowsPreinstallationEnvironment OptionId.UserStateMigrationTool" | Out-Null

#==============================================
# Create Container
#==============================================

   Write-Host "Create OU container" -ForegroundColor Green

   $root = (Get-ADRootDSE).defaultNamingContext

   # Check if System Management OU already exists
   $ou = $null

   try
   {
      $ou = Get-ADObject "CN=System Management,CN=System,$root"
   }
   catch
   {
      Write-Host "System Management container does not currently exist."
   }

   if ($ou -eq $null)
   {
      $ou = New-ADObject -Type Container -name "System Management" -Path "CN=System,$root" -Passthru
   }

   # Get the current ACL for the OU
   $acl = get-acl "ad:CN=System Management,CN=System,$root"

   # Get the SCCM Server's SID (the LOCAL machine)
   $computer = get-adcomputer $env:ComputerName
   $sid = [System.Security.Principal.SecurityIdentifier] $computer.SID

   # Create a new access control entry to allow access to the OU
   $adRights = [System.DirectoryServices.ActiveDirectoryRights] "GenericAll"
   $type = [System.Security.AccessControl.AccessControlType] "Allow"
   $inheritanceType = [System.DirectoryServices.ActiveDirectorySecurityInheritance] "All"
   $ace = New-Object System.DirectoryServices.ActiveDirectoryAccessRule $sid,$adRights,$type,$inheritanceType

   # Add the ACE to the ACL, then set the ACL to save the changes
   $acl.AddAccessRule($ace)
   Set-acl -aclobject $acl "ad:CN=System Management,CN=System,$root"

#==============================================
# Extend Schema
# Note: Requires SCCM ISO mounted
#==============================================
   do 
   {
      Write-Host "Insert SCCM 2012 DVD and press any key to continue ..." -ForegroundColor White
      $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
   }
   until (Test-Path -path "R:\SMSSetup\BIN\x64\ExtADSch.exe")

   Write-Host "Extending Schema" -ForegroundColor Green
   CMD /C R:\SMSSetup\Bin\x64\ExtADSCh.exe

##############################################################################
# INSTALLATION COMPLETED
##############################################################################

Write-Host "DONE!" -ForegroundColor Green

SCCM, SQL and PowerShell

December 27, 2013 – 9:16 pm

I also got involved with pretty much every aspect of the new environment (it’s a consolidation project), with Active Directory, SQL Server, SCCM 2012, etc…

Having last worked with SMS 2003 R2, I decided to start playing with SCCM 2012. Foundations are the same as SMS so far, so nothing too complicated (other than the whole management console itself has changed 🙂 ). But being in a scripting mood, I decided to automate the whole installation process.

Start from a new VM, with 4 virtual disks (C:, D:, E:, and … F: )

  • C: = OS Only
  • D: = Applications
  • E: = Data
  • F: = Backups (SQL Exports)

Vmware_4Disks

Which means I have to rename the virtual CD drive to something else (my standard is R: for … Reader…).

So my initial build looks like this:

  • Change the Optical Drive letter to R:
  • Initialize all the virtual disks
  • Set all the volume labels

And while at it, clear all the event logs (I like starting with clean logs before installing new apps. Easier to spot the issues…)

Here’s the code for this script, which I call “Prep-New-Server.ps1” (Again, I didn’t reinvent the wheel, just learning and having fun with Powershell)

#################################################
# Function: ChangeDriveLabel                    #
# Params:                                       #
# - Drive Letter                                #
# - New Drive Label                             #
#################################################

Function ChangeDriveLabel([string]$DriveLetter, [string]$NewLabel)
{
If ((New-Object System.IO.DriveInfo($driveletter)).DriveType -ne 'NoRootDirectory')
    {
    $drive = Get-WmiObject -Class win32_volume -Filter "DriveLetter = '$DriveLetter'"
    Set-WmiInstance -inputobject $drive -Arguments @{DriveLetter="$DriveLetter"; Label="$NewLabel"}
    }
}

#################################################
# Function: ChangeOpticalDriveLetter            #
# Params:                                       #
# - Drive Letter                                #
#################################################

Function ChangeOpticalDriveLetter([string]$DriveLetter)
{
    (gwmi Win32_cdromdrive).drive | %{$a = mountvol $_ /l;mountvol $_ /d;$a = $a.Trim();mountvol $DriveLetter $a} | Out-Null
}

#################################################
# Function: InitNewDisks                        #
#################################################

Function InitNewDisks
{
    Get-Disk | Where PartitionStyle -eq 'raw' | Initialize-Disk -PartitionStyle MBR
    $NewDisks=Get-Disk | Where NumberOfPartitions -eq 0 | sort Number
    Foreach ($Nb in $NewDisks)
    {
        $NewPartition=New-Partition -DiskNumber $Nb.Number -AssignDriveLetter -UseMaximumSize
        Sleep 2
        $NewPartition | Format-Volume -FileSystem NTFS  -Confirm:$false
    }
}

#################################################
# Function: ClearAllEvents                      #
#################################################

Function ClearAllEvents
{
    wevtutil.exe el | ForEach-Object {wevtutil.exe cl "$_"}
}

#################################################
# Main Program                                  #
#################################################
ChangeOpticalDriveLetter "R:" | Out-Null
InitNewDisks
ChangeDriveLabel "C:" "OS" | Out-Null
ChangeDriveLabel "D:" "Apps" | Out-Null
ChangeDriveLabel "E:" "Data" | Out-Null
ChangeDriveLabel "F:" "Backups" | Out-Null
ClearAllEvents

#################################################

After running this, I’m ready for the SCCM installation (or anything else for that matter… This is pretty much standard VM deployment configuration (with or without the F: drive if there are no SQL servers on the box).

To keep this short, I will post the SCCM script in a future post!

State of things…

December 27, 2013 – 9:01 pm

I have lost a little of my drive to study in the past year, I guess I gave too much the year before with the CCNP, CCNA Security, and the MCSE 2012 🙂 Soooo… I’m trying to get back into it a bit.

I have moved to a new mandate, doing the detailed design for a VMware vSphere deployment (2 vCenters, 24 hosts). While configuring things, I wanted to use PowerCLI to automate certain configurations (especially since I had to repeat them on both environments). And… I got hooked I guess !

I joined that project a bit late in the game, some of the deployment tasks were already done (they had already built about 200 VMs). All of them with E1000 interfaces… So after scouring the net for scripts to automate the upgrade, I customized and rearranged pieces of code that I found to come up with a great script that works really well. I will post it here when I get back to work and grab my latest update.

Basically, it checks if the virtual NIC of a VM is E1000, captures the IP information, shuts down the VM, changes the NIC type to VMXNET3 (retaining the MAC address), sets the “automatically update the VM Tools at power up” feature, starts the VM, runs external tools to remove ghost devices, disables IPv6 (client requirement), restores the IP information, disables automatic DNS registration and restarts the VM one last time.

Oh and if you call the script with a cluster name instead of a VM, it runs on all VMs in the cluster 🙂 So yeah, I didn’t reinvent the wheel but I made it work for my client’s needs.

To be continued…

Summertime!

August 1, 2013 – 11:27 am

It’s been a while since my last update! My current mandate is almost over, what started as a 3 week replacement for a sysadmin lasted almost 2 years overhauling the entire infrastructure, going from a room full of standalone physical servers on 100mbps network with cabling issues, to a modern network with 10GB backbone, gigabit to the desktop, 99% virtualised back-end on shared storage and blade servers, disaster recovery solution, etc…

This was my most challenging and stimulating mandate ever. I worked with a great IT manager who trusted me and gave me the latitude to learn and experiment while deploying all of this, I also learned a lot of new technologies/products.

I hope my next one will be even better 🙂

I am taking the summer off from studying (well I started the CCDA curriculum but I put everything on hold to relax a bit). Once I know what my next mandate is, I’ll resume the studies.

I am considering the following for next year:

  • CCDA/CCDP
  • VMware View
  • Microsoft Exchange 2013
  • And possibly Cisco UCS (ain’t that a cool product!)