Scripting. Powershell, VMware, Windows, Active Directory & Exchange. All that kind of stuff…..
RSS icon Email icon Home icon
  • London VMUG May 17th 2012

    Posted on May 15th, 2012 Jonathan Medd No comments

    The next London VMUG takes place this Thursday May 17th and there’s still time to register. The line-up looks great as usual and in particular some excellent community content is on the agenda from well known regular faces at the VMUG.

    Hope to see you there.

    London VMUG Meeting

    Thursday, 17 May, 2012
    Meeting: 08:30 – 17:15
    London Chamber of Commerce and Industry
    33 Queen Street
    London, EC4R 1AP
     
    Click here for directions
    Networking Reception: 17:15
    Pavilion End
    23 Watling Street, EC4M 9BR
     
    Click here for directions
    The London VMUG Steering Committee is delighted to invite you to our second VMUG meeting of 2012. Thank you to our Gold sponsor Trend Micro, our Silver sponsors Liquidware Labs and Tintri and our Lab sponsor VMTurbo. Registration and the first lab of the day begin at 08.30, so come along early and make the most of the labs before we start our meeting promptly at 10.00.

    Be sure to visit our new London VMUG Workspace! Connect with your fellow VMUG members in te forum, ask and answer questions about VMware, and get involved in your VMUG community.


    Registration is open and included as part of member benefits for all VMUG members.
    Registration for this event will close on Wednesday, 16 May.
    Meeting Highlights     
    • Using vShield to Drive Efficiency and Costs Savings – Stephen Porter, Trend Micro
    • Desktop Transformation with Liquidware Labs – Dan Falconer, Liquidware Labs
    • Solving VM Storage Cost and Performance Challenges with VM-aware Storage – Tintri
    • VMTurbo Labs
    • The vCenter Appliance – Hugo Phan, VMware
    • Climb the Stack and Pimp your Cloud with VMware vFabric – Peter Holditch, VMware
    • Flexpod: The Flexible Converged Infrastructure – Chris Kranz
    • Help, My VDI Project is Hell! – Julian Wood
    • Management and Orch’n – What, Why & How – Steve Bryen
    • The vMarket – Skills in Demand for the Next Five Years – Neil Mills
    • Over to You: Design Me a Highly Available Virtualised Infrastructure – Darren Woollard
    • Writing VMware Apps for Novice Programmers – Ricky El-Qasem 

     

  • The Importance of Being On Time

    Posted on April 2nd, 2012 Jonathan Medd 2 comments

    In an Active Directory environment its typical for client machines to use a local domain controller as their time source, domain controllers with the PDC emulator for the domain and the PDC emulator for the root domain to synchronise time with an external source. In most circumstances the aim is to keep the time synchronised within a 5 minute tolerance level, this will ensure there are no issues with Kerberos authentication which has the 5 minute tolerance as part of its requirements.

    For some applications a tolerance of 5 minutes is too large and can cause issues with the application. You may need to adjust items such as the polling interval to ensure that the time is within a lower tolerance, but first of all you need to know how far out of tolerance the servers within your environment are.

    The below Get-WindowsTimeDifference function can help you out here. It will take a list of Windows computers as input and then compare their time to either a specified Time Server within the environment, or by default attempt to use the PDC emulator for the Root AD Domain (or failing that, the PDC emulator for the current domain). The default tolerance level is one minute, this can be altered with the ToleranceLevel parameter.

    A common cause of time sync issues can be Windows servers in the DMZ, which are not members of the domain. Consequently, by default they will not sync with a local domain controller and may need to be manually configured to use a time server (which doesn’t always happen!). Checking the time for these servers may require alternate credentials, so the Credential parameter is provided for that purpose.

    The example below demonstrates using a text file list of Windows Server names piped into Get-WindowsTimeDifference with one server out of synch when the ToleranceLevel has been set to 3 minutes.

    function Get-WindowsTimeDifference {
    <#
    .SYNOPSIS
    Get the time difference between a time server and Windows clients
    
    .DESCRIPTION
    Get the time difference between a time server and Windows clients
    
    .PARAMETER  ReferenceComputer
    Name of the computer to check time difference for
    
    .PARAMETER  TimeServer
    Name of a TimeServer to use instead of the PDC Emulator
    
    .PARAMETER  ToleranceLevel
    Amount in minutes to permit as an acceptable time difference. Default is 1
    
    .PARAMETER  Credential
    Supply a PSCredential to use alternative credentials for the WMI query
    
    .EXAMPLE
    PS C:\> Get-WindowsTimeDifference -ReferenceComputer Server01 -ToleranceLevel 2
    
    .EXAMPLE
    
    PS C:\> Get-Content servers.txt | Get-WindowsTimeDifference
    -TimeServer TimeServer -ToleranceLevel 3 | Select ComputerName,SynchronisedStatus,TimeDeviation,TimeServer
    
    .EXAMPLE
    PS C:\> Get-Content servers.txt | Get-WindowsTimeDifference -Credential (Get-Credential)
    
    .NOTES
    Author: Jonathan Medd
    Date: 16/03/2012
    #>
    
    [CmdletBinding()]
    param(
    [Parameter(Position=0,Mandatory=$true,HelpMessage="Name of the computer to check time difference for",
    ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$true)]
    [Alias('CN','__SERVER','IPAddress','Server','Computername')]
    [System.String]
    $ReferenceComputer = $env:COMPUTERNAME,
    
    [Parameter(Position=1)]
    [System.String]
    $TimeServer,
    
    [Parameter(Position=2)]
    [int]
    $ToleranceLevel = 1,
    
    [Parameter(Position=3)]
    [System.Management.Automation.PSCredential]
    $Credential
    )
    
    begin {
    
    # If no TimeServer specified, retrive the PDC Emulator for the Root Domain and the Current Domain
    if (-not($Timeserver)) {
    
    $Forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
    $DomainContext = New-Object System.DirectoryServices.ActiveDirectory.DirectoryContext("Domain", $Forest.RootDomain)
    $RootPDCEmulator = ([System.DirectoryServices.ActiveDirectory.Domain]::GetDomain($DomainContext)).PdcRoleOwner.Name
    $CurrentDomainPDCEmulator = ([System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()).PdcRoleOwner.Name
    
    # Attempt a WMI query to the PDC Emulator for the Root Domain
    try {
    
    $PDCEmulator = (Get-WmiObject Win32_OperatingSystem -ComputerName $RootPDCEmulator -ErrorAction Stop).__Server
    
    }
    
    # If there is an error (such as blocked TCP ports or permissions) try the PDC Emulator for the Current Domain instead
    catch [System.Exception] {
    
    $PDCEmulator = (Get-WmiObject Win32_OperatingSystem -ComputerName $CurrentDomainPDCEmulator).__Server
    }
    
    }
    }
    
    process {
    
    # If no TimeServer specified, calculate the time difference between the PDC Emulator and the Reference Computer
    if (-not($Timeserver)) {
    
    try {
    $PDCEmulatorWMI = Get-WmiObject Win32_OperatingSystem -ComputerName $PDCEmulator
    
    if ($Credential){
    
    $ReferenceComputerWMI = Get-WmiObject Win32_OperatingSystem -ComputerName $ReferenceComputer -Credential $Credential -ErrorAction Stop
    
    }
    
    else {
    
    $ReferenceComputerWMI = Get-WmiObject Win32_OperatingSystem -ComputerName $ReferenceComputer -ErrorAction Stop
    
    }
    
    $PDCEmulatorTime = $PDCEmulatorWMI.ConvertToDateTime($PDCEmulatorWMI.LocalDateTime)
    $ReferenceComputerTime = $ReferenceComputerWMI.ConvertToDateTime($ReferenceComputerWMI.LocalDateTime)
    $TimeDeviation = $PDCEmulatorTime - $ReferenceComputerTime
    }
    
    # Catch any errors with the WMI query to the Reference Computer
    catch [System.Exception] {
    
    $TimeDeviation = "Unable to contact server"
    
    }
    }
    
    else {
    
    # If TimeSever is specified, calculate the time difference between the TimeServer and the Reference Computer
    try {
    
    $TimeServerWMI = Get-WmiObject Win32_OperatingSystem -ComputerName $TimeServer
    
    if ($Credential){
    
    $ReferenceComputerWMI = Get-WmiObject Win32_OperatingSystem -ComputerName $ReferenceComputer -Credential $Credential -ErrorAction Stop
    
    }
    
    else {
    
    $ReferenceComputerWMI = Get-WmiObject Win32_OperatingSystem -ComputerName $ReferenceComputer -ErrorAction Stop
    
    }
    
    $TimeServerTime = $TimeServerWMI.ConvertToDateTime($TimeServerWMI.LocalDateTime)
    $ReferenceComputerTime = $ReferenceComputerWMI.ConvertToDateTime($ReferenceComputerWMI.LocalDateTime)
    $TimeDeviation = $TimeServerTime - $ReferenceComputerTime
    
    }
    
    # Catch any errors with the WMI query to the Reference Computer
    catch [System.Exception] {
    
    $TimeDeviation = "Unable to contact server"
    
    }
    
    }
    # Use the TimeDeviation variable to determine SynchronisedStatus and TimeDeviation to report
    if ($TimeDeviation -eq "Unable to contact server"){
    
    $SynchronisedStatus = "Unable to contact server"
    
    }
    
    elseif ([Math]::Abs(($TimeDeviation).Minutes) -ge $ToleranceLevel) {
    
    $SynchronisedStatus = "Not Synchronised"
    $TimeDeviation = [string]$TimeDeviation.Minutes +" Minute(s) " + [string]$TimeDeviation.Seconds +" Seconds"
    }
    
    else {
    
    $SynchronisedStatus = "Synchronised"
    $TimeDeviation = [string]$TimeDeviation.Minutes +" Minute(s) " + [string]$TimeDeviation.Seconds +" Seconds"
    }
    
    # Create custom objects to store the results
    New-Object -TypeName PSObject -Property @{
    ComputerName = $ReferenceComputer
    SynchronisedStatus = $SynchronisedStatus
    TimeDeviation = $TimeDeviation
    TimeServer = if ($PDCEmulator) {$PDCEmulator} else {$TimeServer}
    
    }
    }
    
    }
    

    It may also be important to prove that time is synchronised across your VMware servers. The Get-ESXTimeDifference function will do this for you. In the below example a list of VMware servers is obtained froma text file and the time checked against the Root Domain PDC emulator using the default ToleranceLevel of 1 minute.

    Note: Get-ESXTimeDifference requires PowerCLI installed and a connection to vCenter having already been made.

    
    function Get-ESXTimeDifference {
    <#
    .SYNOPSIS
    Get the time difference between a time server and ESX clients
    
    .DESCRIPTION
    Get the time difference between a time server and ESX clients
    
    .PARAMETER  ReferenceComputer
    Name of the computer to check time difference for
    
    .PARAMETER  TimeServer
    Name of a TimeServer to use instead of the PDC Emulator
    
    .PARAMETER  ToleranceLevel
    Amount in minutes to permit as an acceptable time difference. Default is 1
    
    .EXAMPLE
    PS C:\> Get-ESXTimeDifference -ReferenceComputer ESX01 -ToleranceLevel 2
    
    .EXAMPLE
    
    PS C:\> Get-VMHost ESX01 | Get-ESXTimeDifference
    -TimeServer TimeServer -ToleranceLevel 3 | Select ComputerName,SynchronisedStatus,TimeDeviation,TimeServer
    
    .NOTES
    Author: Jonathan Medd
    Date: 16/03/2012
    #>
    
    [CmdletBinding()]
    param(
    [Parameter(Position=0,Mandatory=$true,HelpMessage="Name of the computer to check time difference for",
    ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$true)]
    [Alias('CN','__SERVER','IPAddress','Server','Computername','VMHost','Name')]
    [System.String]
    $ReferenceComputer,
    
    [Parameter(Position=1)]
    [System.String]
    $TimeServer,
    
    [Parameter(Position=2)]
    [int]
    $ToleranceLevel = 1
    )
    
    begin {
    
    # If no TimeServer specified, retrive the PDC Emulator for the Root Domain and the Current Domain
    if (-not($Timeserver)) {
    
    $Forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
    $DomainContext = New-Object System.DirectoryServices.ActiveDirectory.DirectoryContext("Domain", $Forest.RootDomain)
    $RootPDCEmulator = ([System.DirectoryServices.ActiveDirectory.Domain]::GetDomain($DomainContext)).PdcRoleOwner.Name
    $CurrentDomainPDCEmulator = ([System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()).PdcRoleOwner.Name
    
    # Attempt a WMI query to the PDC Emulator for the Root Domain
    try {
    
    $PDCEmulator = (Get-WmiObject Win32_OperatingSystem -ComputerName $RootPDCEmulator -ErrorAction Stop).__Server
    
    }
    
    # If there is an error (such as blocked TCP ports or permissions) try the PDC Emulator for the Current Domain instead
    catch [System.Exception] {
    
    $PDCEmulator = (Get-WmiObject Win32_OperatingSystem -ComputerName $CurrentDomainPDCEmulator).__Server
    }
    
    }
    }
    
    process {
    
    # If no TimeServer specified, calculate the time difference between the PDC Emulator and the Reference Computer
    if (-not($Timeserver)) {
    
    $PDCEmulatorWMI = Get-WmiObject Win32_OperatingSystem -ComputerName $PDCEmulator
    
    $PDCEmulatorTime = $PDCEmulatorWMI.ConvertToDateTime($PDCEmulatorWMI.LocalDateTime)
    
    $ReferenceComputerTime = ((Get-View ((Get-VMHost $ReferenceComputer).ExtensionData.ConfigManager.DateTimeSystem)).QueryDateTime()).ToLocalTime()
    $TimeDeviation = $PDCEmulatorTime - $ReferenceComputerTime
    
    }
    
    else {
    
    # If TimeSever is specified, calculate the time difference between the TimeServer and the Reference Computer
    
    $TimeServerWMI = Get-WmiObject Win32_OperatingSystem -ComputerName $TimeServer
    
    $TimeServerTime = $TimeServerWMI.ConvertToDateTime($TimeServerWMI.LocalDateTime)
    $ReferenceComputerTime = ((Get-View ((Get-VMHost $ReferenceComputer).ExtensionData.ConfigManager.DateTimeSystem)).QueryDateTime()).ToLocalTime()
    $TimeDeviation = $TimeServerTime - $ReferenceComputerTime
    
    }
    # Use the TimeDeviation variable to determine SynchronisedStatus and TimeDeviation to report
    
    if ([Math]::Abs(($TimeDeviation).Minutes) -ge $ToleranceLevel) {
    
    $SynchronisedStatus = "Not Synchronised"
    $TimeDeviation = [string]$TimeDeviation.Minutes +" Minute(s) " + [string]$TimeDeviation.Seconds +" Seconds"
    }
    
    else {
    
    $SynchronisedStatus = "Synchronised"
    $TimeDeviation = [string]$TimeDeviation.Minutes +" Minute(s) " + [string]$TimeDeviation.Seconds +" Seconds"
    }
    
    # Create custom objects to store the results
    New-Object -TypeName PSObject -Property @{
    ComputerName = $ReferenceComputer
    SynchronisedStatus = $SynchronisedStatus
    TimeDeviation = $TimeDeviation
    TimeServer = if ($PDCEmulator) {$PDCEmulator} else {$TimeServer}
    
    }
    }
    
    }
    
  • Which VMs restarted after a vSphere HA event?

    Posted on March 29th, 2012 Jonathan Medd No comments

    I experienced a vSphere HA event where VMs restarted on other hosts and I was requested by management to confirm which VMs had restarted. Details are stored within vCenter events, but trawling through those manually for multiple VMs would be pretty tedious. Enter of course, PowerCLI. The Get-VIEvent cmdlet enables you to search through the events, but to a certain extent it kind of helps if you know what you are looking for since there is so much information to look through.

    In the PowerCLI Book, we include a function, Get-VIEventType to return the different type of events that are available. By using this function we can search for an event that would match HA restarts.

    
    Get-VIEventType | Where-Object {$_.Description -like '*restarted*'} | Select-Object Name,Description
    

    So to find these events when can now run a query and filter out only those that match the VmRestartedOnAlternateHostEvent. In the initial Get-VIEvent query we can also reduce the scope of the search by using -Type Info since these events are not recorded as Warnings or Errors.

    
    Get-VIEvent -start (Get-Date).adddays(-1) -MaxSamples 5000 -Type Info | Where-Object {$_.gettype().Name -eq "VmRestartedOnAlternateHostEvent"} | Select-Object @{N='VM';E={($_ | Select -ExpandProperty VM).Name}},@{N='Host';E={($_ | Select -ExpandProperty SourceHost).Name}},CreatedTime
    

    Update:

    After putting this post together I noticed (after the report came through this morning) that this check is also included as part of vCheck, but implemented slightly differently. As always, there’s usually more than one way to get to the same end result.

    $Date = Get-Date
    $HAVMrestartold =5
    Get-VIEvent -maxsamples 100000 -Start ($Date).AddDays(-$HAVMrestartold) -type info | Where {$_.FullFormattedMessage -match "was restarted"} |select CreatedTime,FullFormattedMessage |sort CreatedTime -Descending
    

    Update 2:

    While testing out this post on vSphere 5 (the above was all vSphere 4.1) I discovered that there had been a few changes. Firstly, there are now two types listed

    
    Get-VIEventType | Where-Object {$_.Description -like '*restarted*'} | Select-Object Name,Description
    

    Some research led to the discovery that the VmRestartedonAlternateHostEvent was deprecated in vSphere 5.

    Consequently, the below no longer produced any results:

    
    Get-VIEvent -start (Get-Date).adddays(-1) -MaxSamples 5000 -Type Info | Where-Object {$_.gettype().Name -eq "VmRestartedOnAlternateHostEvent"} | Select-Object @{N='VM';E={($_ | Select -ExpandProperty VM).Name}},@{N='Host';E={($_ | Select -ExpandProperty SourceHost).Name}},CreatedTime
    

    It needed to be modified to:

    
    Get-VIEvent -start (Get-Date).adddays(-1) -MaxSamples 5000 | Where-Object {$_.eventtypeid -eq "com.vmware.vc.ha.VmRestartedByHAEvent"} | Select ObjectName,CreatedTime
    

    Also the vCheck method no longer worked:

    $Date = Get-Date
    $HAVMrestartold =5
    Get-VIEvent -maxsamples 100000 -Start ($Date).AddDays(-$HAVMrestartold) -type info | Where {$_.FullFormattedMessage -match "was restarted"} |select CreatedTime,FullFormattedMessage |sort CreatedTime -Descending
    

    and needed to be modified to the below since the text changed slightly and it was now also a warning event:

    $Date = Get-Date
    $HAVMrestartold =5
    Get-VIEvent -maxsamples 100000 -Start ($Date).AddDays(-$HAVMrestartold) -type warning | Where {$_.FullFormattedMessage -match "restarted"} |select CreatedTime,FullFormattedMessage |sort CreatedTime -Descending
    

  • Windows Server 8 Core Beta – Installing VMware Tools

    Posted on March 26th, 2012 Jonathan Medd 8 comments

    Here’s a quick post on installing VMware Tools inside Windows Server 8 Core Beta (Note the Tools version this was tested against is the version that is available via ESXi 5 Build 515841):

    1) Mount the VMware Tools installer for the VM and switch to the CD-Rom drive. (Note: the screenshots below show a session where I was already running PowerShell, not cmd.exe)

    2) Run setup.

    3) Work through the wizard, selecting the appropriate options:

    4) Alternatively, you could use some of the command line options for installing VMware Tools, e.g. the below will perform a quiet install and reboot automatically:

    setup64.exe /s /v/qn

    5) Here’s confirmation of the successful install:

  • Including the HP Offline Bundle as part of an upgrade to ESXi 4.1 U2

    Posted on March 6th, 2012 Jonathan Medd 1 comment

    If you’re running your vSphere deployment on HP kit then there’s a pretty good chance you use the HP Customized ISO Image for installation, for example this one for ESXi 4.1 U1. These customised images typically contain HP management tools and drivers and are great for saving time during the installation process. Naturally you will be upgrading ESXi at some point, but it’s important that you also keep the HP part up-to-date too. To accompany the release of ESXi 4.1 U2 there is a corresponding release of the HP Offline Bundle. The release notes for this version do not suggest any enhancements or bug fixes, only that it is the version that is supported with 4.1 U2.

    Once you have downloaded the HP Offline Bundle, it is possible to deploy it via a number of methods. The installation notes suggest installing with the vihostupdate utility, however in this post I’m going to show how it can be installed via vCenter Update Manager.

    1) First of all the HP Offline Bundle needs to be imported into the Update Manager Patch Repository. Navigate to the Patch Repositoy and select Import Patches.

    2. Enter the path to the HP Offline Bundle. (Note: the GUI does not display the full path, just the filename)

    3. The patches will then be uploaded to the Patch Repository.

    4. Finally, finish off the wizard.

    5. Once the HP Offline Bundle has been imported a Host Extension Patch Baseline needs to be created. Navigate to Baselines and Groups and create a new Baseline, with the type changed from the default Host Patch to Host Extension.

    6. Select the Extension to add to the Baseline. The best thing to do here is enter HP into the search box to reduce the number of items to choose from.

    7. On the final page confirm the HP Offline Bundle has been added.

    Alternatively, once the HP Offline Bundle has been uploaded into the Patch Repository, it’s much easier to create this baseline via the vCenter Update Manger PowerCLI cmdlets. :-)   Note that we need to use the Extension parameter since the baseline will be of type Host Extension.

    
    New-PatchBaseline -Name "HP Offline Bundle for ESXi 4.1 U2 " -Description "HP Offline Bundle for ESXi 4.1 U2" -IncludePatch (Get-Patch -SearchPhrase "HP ESXi 4.1 Bundle 1.2-25") -TargetType Host -Static -Extension
    

    The main advantage for me of deploying the HP Offline Bundle with Update Manager is that we can take advantage of Baseline Groups. As the name suggests Baseline Groups enable you to group together multiple and different types of baselines. Consequently in this instance we can place the ESXi and HP Offline Bundle upgrade into a Baseline Group and carry out the upgrade to 4.1 U2 in a single remediation task.

    There are similar upgrade packages for ESXi 5 from HP, so this process could also be used for that upgrade.

  • ESXi Syslog Server Check Plugin for vCheck6

    Posted on March 5th, 2012 Jonathan Medd 2 comments

    I remember back to a London VMUG long ago a presentation about differences to watch out for between ESX and ESXi during the version 3.5 days. The one that got most people looking around at each other saying “oops, I don’t think we knew that” was configuring a Syslog server for your ESXi servers. vCenter 5 now includes it’s own built in Syslog server so there’s no excuse. Alternatives, such as Kiwi Syslog Server, are available if you don’t want to use the vCenter 5 syslog server. There’s a lot more awareness about needing one now, but it has still burnt me in a couple of environments I have worked on recently, where there was a need to review logs after an issue and no central logging had been configured for the hosts in question.

    So this additional plugin for vCenter will highlight any ESXi hosts which have not been configured with the correct Syslog server.

    In a previous post I detailed how to add your own plugin to vCheck 6. You can either do that for the below plugin, download it from the plugins section on Alan’s site or it is also included as part of the vCheck 6.10 release. There are now 70+ plugins for vCheck thanks to some great community contributions!

    
    $Title = "Syslog Name"
    $Header =  "Syslog Issues"
    $Comments = "The following hosts do not have the correct Syslog settings which may cause issues if ESXi hosts experience issues and logs need to be investigated"
    $Display = "Table"
    $Author = "Jonathan Medd"
    $Version = 1.0
    
    # Start of Settings
    # The Syslog server which should be set on your hosts
    $SyslogServer ="SyslogServer"
    # End of Settings
    
    @($VMH | Where-Object {$_.ExtensionData.Summary.Config.Product.Name -eq 'VMware ESXi'} | Select-Object Name,@{Name='SyslogServer';Expression = {($_ | Get-VMHostSysLogServer).Host}} | Where-Object {$_.SyslogServer -ne $syslogserver})
    
  • Checking out the vCloud Client for iPad to access resources hosted at Stratogen

    Posted on February 22nd, 2012 Jonathan Medd No comments

    During last week’s VMware PEX event the vCloud Client for the iPad was released. I have access to a few VMs hosted in a public vCloud Directory deployment thanks to the guys at Stratogen, which I use from time to time. Up till now, while I can access these VMs on my iPad via RDP with something like the PocketCloud App from Wyse, the web browser interface for the management of these VMs through vCloud Director was not supported through the Safari browser. So I thought I would check out the new client for the iPad.

    Configuration is  unsuprisingly simple, enter the URL given to you by the hosting provider and pick any of the other options relevant. Note: currently it seems that the only two RDP clients available are JumpDesktop and Remoter – hopefully more clients (such as PocketCloud) will be added in the future.

    Once the credentials have been saved, you’ll be taken to the logon screen for your hosting provider.

    Then after signing in with your credentials, you’ll be presented with your vApps.

    Checking out details of your vApps:

    I then went to see if I could provision a new VM. Initally it looked promising:

    However, it doesn’t seem like it is possible to deploy from OS templates yet:

    Better success though with managing existing VMs. I was able to check out details of the VMs:

    View the hardware configuration, although unfortuantely not edit it.

    Have options for the power state:

    When using the power buttons, you need to press down on the button for 5 secs, during which time a cool countdown begins and whizzes around. (sadly, I quite enjoyed that!)

    Conclusion: A great start! The client has a really swish feel to it and I enjoyed using it. Being able even to have basic management capabilities from the iPad is really useful. Features such as editing VM hardware, deploying from template and additional RDP clients would be great, but I’m sure they will appear in good time.

  • Managing vCenter Plugins with PowerCLI

    Posted on February 21st, 2012 Jonathan Medd No comments

    VMUG, vBeers, vLunch….whatever the occasion, there are always some great conversations and I particularly enjoy finding out what other people are up to in their environments. During vLunch last week, I was talking with Ed Grigson and he asked whether it was possible to use PowerCLI to remove vCenter Plugins that have got into an orphaned state, i.e. the uninstall process did not remove the vCenter plugin. VMware KB article 1025360 details a process whereby you can clean these up by navigating to the vCenter Server with a web browser. Point 3) mentions ExtensionManager and that got me thinking that it should be possible to do this via PowerCLI.

    Coincidently I have seen a few people tweeting about this topic in the last week, so thought it might be useful to make some PowerCLI functions for managing this process.

    First up is Get-vCenterPlugin , this function will return either all vCenter Plugins or a specifc one, e.g:

    
    Get-vCenterPlugin
    

    or

    
    Get-vCenterPlugin -Name 'vCenter Hardware Status'
    

    (Note: the object doesn’t actually have a Name property, but what is stored in Description appears in most cases to be the name)

    
    function Get-vCenterPlugin {
    
    <#
    .SYNOPSIS
    Retrieves vCenter Plugins
    
    .DESCRIPTION
    Retrieves vCenter Plugins
    
    .PARAMETER  Name
    Name of the Plugin to return
    
    .EXAMPLE
    PS C:\> Get-vCenterPlugin -Name 'vCenter Hardware Status'
    
    .NOTES
    Author: Jonathan Medd
    Date: 17/02/2012
    #>
    
    [CmdletBinding()]
    param(
    [Parameter(Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
    [System.String]
    $Name
    )
    
    begin {
    $ExtensionManager = Get-View ExtensionManager
    }
    
    process {
    
    if ($Name){
    $ExtensionManager.ExtensionList | Select-Object @{Name='Description';Expression={$_.Description.Label}},Key,Company,Version | Where-Object {$_.Description -eq $Name}
    }
    
    else {
    $ExtensionManager.ExtensionList | Select-Object @{Name='Description';Expression={$_.Description.Label}},Key,Company,Version | Sort-Object Description
    }
    
    }
    }
    

    If you have a vCenter plugin in an orphaned state then it may look something like this:

    To remove the vCenter plugin we need to supply the plugin Key to the UnregisterExtension method. The Remove-vCenterPlugin function has two parameters, Name and Key. If you supply the name of the plugin then the function first of all determines the key and subsequently supplies it to the UnregisterExtension method.

    
    Remove-vCenterPlugin "vCenter Operations Standard"
    

    The vCenter Operations Standard plugin has been removed.

    
    function Remove-vCenterPlugin {
    
    <#
    .SYNOPSIS
    Removes vCenter Plugins
    
    .DESCRIPTION
    Removes vCenter Plugins
    
    .PARAMETER  Name
    Name of the Plugin to remove
    
    .EXAMPLE
    PS C:\> Remove-vCenterPlugin -Name '3PAR_Plug-In'
    
    .EXAMPLE
    PS C:\> Remove-vCenterPlugin -Key 'com.3par.3PAR_Plug-In'
    
    .EXAMPLE
    PS C:\> Get-vCenterPlugin -Name '3PAR_Plug-In' | Remove-vCenterPlugin
    
    .NOTES
    Author: Jonathan Medd
    Date: 17/02/2012
    #>
    
    [CmdletBinding(DefaultParametersetName="Name")]
    param(
    [Parameter(ParameterSetName="Name",Position=0,Mandatory=$true,HelpMessage="Name of plugin to remove",
    ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
    [Alias('Description')]
    [System.String]
    $Name,
    
    [Parameter(ParameterSetName="Key",Position=0,Mandatory=$true,HelpMessage="Key of plugin to remove",
    ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
    [System.String]
    $Key
    )
    
    begin {
    $ExtensionManager = Get-View ExtensionManager
    }
    
    process {
    
    switch ($PsCmdlet.ParameterSetName) {
    
    "Name" {
    $KeyID = ($ExtensionManager.ExtensionList | Select-Object @{Name='Description';Expression={$_.Description.Label}},Key,Company,Version | Where-Object {$_.Description -eq $Name}).Key
    $ExtensionManager.UnregisterExtension("$KeyID")
    }
    
    "Key" {
    $ExtensionManager.UnregisterExtension("$Key")
    }
    
    }
    }
    }
    

     

    The sharp eyed amongst you will of course notice that the first plugin in the list does not have the Description property populated, so to remove the vShield Manager Plugin you will need to supply the key; which you can determine by first running Get-vCenterPlugin.

    
    Remove-vCenterPlugin -Key com.vmware.vShieldManager
    

    Remove-vCenterPlugin also accepts pipeline input, so if you have a list of plugins to remove you can automate this a bit smarter than one at a time, e.g.:

    
    'vCenter Operations Standard','3PAR_Plug-In' | Get-vCenterPlugin | Remove-vCenterPlugin
    

    or:

    
    Get-Content plugins.txt | Get-vCenterPlugin | Remove-vCenterPlugin
    

    All being well your vCenter Plugins should now look tidy again.

     

    Big thanks to Ed for helping me test this out. You should check out his blog, he has made some great posts recently in addition to his well known VCAP study guide.

  • Adding Your Own Plugin to vCheck6

    Posted on February 8th, 2012 Jonathan Medd 3 comments

    The vCheck PowerCLI script from Alan Renouf is one of the most popular scripts for managing vSphere with PowerCLI. Its an amazing piece of work and I think has in its own small way helped the success of PowerCLI itself, by showing the kind of information it is possible to retrieve from vSphere and present in a great format. The number of people I talk to who use it and the large scale organisations that you would think spend thousands of pounds on expensive monitoring tools that have it as part of the daily monitoring checks never ceases to surprise me.

    Alan has just released version 6 of vCheck and has taken the time to look at it from scratch, take in feedback from the 400+ comments he has received back about it and implement it in such a fashion that it is possible for you to extend it simply yourself. The script has been split out into some general components and a seperate Plugins folder.

    Each of the individual checks that vCheck makes against your vSphere environment is stored in this Plugins folder. If you wish to make your own check to add to vCheck then all you need to is add a new *.ps1 file containing some required header information and the code to run the check. This is brilliant and really saves any hassle from the previous versions where you had to put your own code in to the right place in the script to make it work. Below I have added number 46 Cluster Capacity.

    This script contains the following required code. Here you can supply details about the script, various parts of which will be displayed during the execution of the script and in the resulting report, for instance you can place a link to a website containing more info about the check – in this case I have placed a link to my blog post about how the cluster capacity check works.

    
    $Title = "Basic Cluster Capacity"
    $Header =  "Basic Cluster Capacity"
    $Comments = "Retrieve Cluster Capacity Information. For details see http://www.jonathanmedd.net/2012/01/basic-cluster-vmware-capacity-check-with-powercli.html"
    $Display = "Table"
    $Author = "Jonathan Medd"
    $Version = 1.0
    

    The full code for this particular example is below:

    
    $Title = "Basic Cluster Capacity"
    $Header =  "Basic Cluster Capacity"
    $Comments = "Retrieve Cluster Capacity Information. For details see http://www.jonathanmedd.net/2012/01/basic-cluster-vmware-capacity-check-with-powercli.html"
    $Display = "Table"
    $Author = "Jonathan Medd"
    $Version = 1.0
    
    # Start of Settings
    # End of Settings
    
    function Get-ClusterCapacityCheck {
    <#
    .SYNOPSIS
    Retrieves basic capacity info for VMware clusters
    
    .DESCRIPTION
    Retrieves basic capacity info for VMware clusters
    
    .PARAMETER&nbsp; ClusterName
    Name of the computer to test the services for
    
    .EXAMPLE
    PS C:\> Get-ClusterCapacityCheck -ClusterName Cluster01
    
    .EXAMPLE
    PS C:\> Get-Cluster | Get-ClusterCapacityCheck
    
    .NOTES
    Author: Jonathan Medd
    Date: 18/01/2012
    #>
    
    [CmdletBinding()]
    param(
    [Parameter(Position=0,Mandatory=$true,HelpMessage="Name of the cluster to test",
    ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$true)]
    [System.String]
    $ClusterName
    )
    
    begin {
    $Finish = (Get-Date -Hour 0 -Minute 0 -Second 0)
    $Start = $Finish.AddDays(-1).AddSeconds(1)
    
    New-VIProperty -Name FreeSpaceGB -ObjectType Datastore -Value {
    param($ds)
    [Math]::Round($ds.FreeSpaceMb/1KB,0)
    } -Force
    
    }
    
    process {
    
    $Cluster = Get-Cluster $ClusterName
    
    $ClusterCPUCores = $Cluster.ExtensionData.Summary.NumCpuCores
    $ClusterEffectiveMemoryGB = [math]::round(($Cluster.ExtensionData.Summary.EffectiveMemory / 1KB),0)
    
    $ClusterVMs = $Cluster | Get-VM
    
    $ClusterAllocatedvCPUs = ($ClusterVMs | Measure-Object -Property NumCPu -Sum).Sum
    $ClusterAllocatedMemoryGB = [math]::round(($ClusterVMs | Measure-Object -Property MemoryMB -Sum).Sum / 1KB)
    
    $ClustervCPUpCPURatio = [math]::round($ClusterAllocatedvCPUs / $ClusterCPUCores,2)
    $ClusterActiveMemoryPercentage = [math]::round(($Cluster | Get-Stat -Stat mem.usage.average -Start $Start -Finish $Finish | Measure-Object -Property Value -Average).Average,0)
    
    $VMHost = $Cluster | Get-VMHost | Select-Object -Last 1
    $ClusterFreeDiskspaceGB = ($VMHost | Get-Datastore | Where-Object {$_.Extensiondata.Summary.MultipleHostAccess -eq $True} | Measure-Object -Property FreeSpaceGB -Sum).Sum
    
    New-Object -TypeName PSObject -Property @{
    Cluster = $Cluster.Name
    ClusterCPUCores = $ClusterCPUCores
    ClusterAllocatedvCPUs = $ClusterAllocatedvCPUs
    ClustervCPUpCPURatio = $ClustervCPUpCPURatio
    ClusterEffectiveMemoryGB = $ClusterEffectiveMemoryGB
    ClusterAllocatedMemoryGB = $ClusterAllocatedMemoryGB
    ClusterActiveMemoryPercentage = $ClusterActiveMemoryPercentage
    ClusterFreeDiskspaceGB = $ClusterFreeDiskspaceGB
    }
    }
    }
    
    $Clusters | Get-ClusterCapacityCheck | Select-Object Cluster,ClusterCPUCores,ClusterAllocatedvCPUs,ClustervCPUpCPURatio,
    
    ClusterEffectiveMemoryGB,ClusterAllocatedMemoryGB,ClusterActiveMemoryPercentage,
    
    ClusterFreeDiskspaceGB
    

    Now when you execute vCheck6 you will see your own plugin executed at the end of the script run.

    And if your plugin generates some data for the vCenter it has been run against, then it will appear in the report.

    The possibilites for this are endless and don’t necessarily need to only extend to vSphere. Think of it as a reporting framework into which you could plugin information from any system that you can access via PowerShell, say Windows Server, Exchange, SQL, Citrix, your SAN etc. Brilliant stuff!

  • VCP5 Study Resources

    Posted on January 30th, 2012 Jonathan Medd No comments

    Having passed the VCP5 exam last week, I thought I would write the obligatory study resources blog post. So below are the resources I found most useful in preparing for the exam:

    1) TrainSignal VMware vSphere 5 Training

    I’ve previously used the TrainSignal VMware vSphere 4 VCAP Training Package to begin preparations for the VCAP-DCA exam so was well accustomed with the style of the TrainSignal videos. Since I was in the position of needing to upgrade my VCP from 4 to 5 before February 29th 2012 to avoid needing to fulfill a class requirement again, I found this to be a great resource to quickly get up to speed on some of the new features in vSphere 5 and also provide a refresher for some of the topics that have been in the exam since the VCP 3 days. The topics covered are listed below; the great thing about the modular style nature of these videos is that you can easily focus in on particular topics of interest and skip over others if you want to. I was tempted to skip a few of the chapters I thought I knew everything about, however I stuck with them and not only had a good refresher of those topics, but also picked up a few things I didn’t know.

    Lesson 1 – Getting Started with VMware vSphere 5 Training Course
    Lesson 2 – Lab Setup
    Lesson 3 – Course Scenario
    Lesson 4 – Overview of VMware vSphere 5
    Lesson 5 – Installing VMware ESXi 5
    Lesson 6 – Installing vCenter 5
    Lesson 7 – Installing vCenter 5 as a Linux Appliance (vCSA)
    Lesson 8 – Using the vSphere 5 Web Client
    Lesson 9 – What’s New in vSphere 5
    Lesson 10 – Navigating vSphere Using the vSphere Client
    Lesson 11 – vCenter 5 – Configuring Your New Virtual Infrastructure
    Lesson 12 – Creating and Modifying Virtual Guest Machines
    Lesson 13 – Installing and Configuring VMware Tools
    Lesson 14 – Understanding and Using Tasks, Events, and Alarms
    Lesson 15 – Virtual Storage 101 and Storage Terminology
    Lesson 16 – vSphere Storage Appliance (VSA)
    Lesson 17 – Creating a Free iSCSI SAN with OpenFiler
    Lesson 18 – Administering VMware ESXi Server Security
    Lesson 19 – vSphere Virtual Networking
    Lesson 20 – Using the vSphere Distributed Virtual Switch (dvswitch)
    Lesson 21 – Moving Virtual Machines with vMotion
    Lesson 22 – Moving Virtual Storage with svMotion
    Lesson 23 – Performance Optimization with Distributed Resource Scheduler (DRS)
    Lesson 24 – Implementing High Availability with VMware HA (VMHA)
    Lesson 25 – Super High Availability with VMware Fault Tolerance (FT)
    Lesson 26 – Upgrading from VMware vSphere 4 to vSphere 5
    Lesson 27 – vSphere Command Line Interface (CLI) Options
    Lesson 28 – vSphere Auto Deploy
    Lesson 29 – Storage DRS
    Lesson 30 – Policy-driven Storage
    Lesson 31 – Understanding the New vSphere 5 vRAM Pooled Pricing
    Lesson 32 – Network I/O Control (NIOC)
    Lesson 33 – Storage I/O Control (SIOC)
    Lesson 34 – ESXi Firewall
    Lesson 35 – VMware Data Recovery (VDR) 2
    Lesson 36 – Administering vSphere Using an iPad

    Both David Davis and Elias Khnaser have excellent presenting styles, in their clear explanations and enthusiasm for the topic – which I am particularly grateful for having watched most of them on the early commute into work. While not directly aimed at the VCP exam, the videos provide a good breadth of coverage of most of the exam topics. As with the other series they are available online streamed from the website as soon as you make the purchase, but also shipped to you on a DVD in formats suitable for PC, iPhone iPad etc.

    2) VCP5 Exam Blueprint

    Reading the VCP5 Exam Blueprint document is essential to ensure that you have covered all of the bases. I worked through the document and ticked off each objective as I went. Most of my work is with the larger Enterprise deployments of vSphere, so this is a good way to ensure that you have not missed anything that might be more commonly used in say SMB deployments.

     

    3) VCP5 Exam Blueprint Study Guide PDF

    While working through the official blueprint document I discovered this Study Guide PDF which Jason Langer and Josh Coen have put together. They have put a lot of work into this document which typically contains a paragraph or two on each objective with highlight points and links to pages in vSphere documentation pdfs for further research. Given the limited time I had to prepare for the exam, this was great for quickly covering all of the objectives and I really appreciated the effort they had made in putting it together.

    4) VCP 5 Brownbags

    The Professional Vmware site is well known for running 1 hour brownbag sessions for VMware topics, including the VCAP exams. Recently they have started them for VCP5 too and although currently there are only a few, they are well worth checking out.

    5)  vSphere 5.o Clustering DeepDive

    I bought this book by Frank Denneman and Duncan Epping when it came out last year because I wanted know about new vSphere 5 features, however it is also worth reading as preparation for this exam. While the book goes into far more technical depth than required for the VCP, it was still useful for an early appreciation of these topics.

    6) Practice Questions

    It’s good to at least get a feel of the kind of questions you will be asked in the exam. Both the VMware VCP site with a mock exam and Simon Long’s blog are a great resource for this.

    7) Hands-on experience with real world vSphere experience

    Most important of all was hands-on experience of vSphere. There were many questions I knew the answer to that were not through the result of self-study, but either I had configured them at work or experienced the issue and had resolved it. You can emulate a fair amount of this if you have access to say a home-lab, but you can’t beat experience and unfortunately there is only one way to get that.

    I was pleased to see that the exam was heading more in this direction. When I took the VCP 3.5 in 2008 the Minimum and Maximums document was a core part of my study process, in fact I took the exam while my family were away for a few days, so my house resembled something out of Prison Break with different pages of the Min / Max guide on the walls! I didn’t do that this time and while a good knowledge of the fundamental minimum and maximums is still required on the blueprint, the days of having to memorise every single one in the guide just to pass the exam appear to be over which is a good thing.

    sdfsd