Add a VMware Exam Blueprint Guide recommended readings to iTunes using PowerShell

PowerShell logoAlthough I have been working as a VMware vSphere systems admin for more than two years now, I still don’t hold any VMware certification. The main reason for this was, that I didn’t take any VMware training course. And you won’t be VMware certified, if you haven’t at least followed one VMware training. In june I took the “VMware vSphere: Troubleshooting” class. So the reason for not doing a VMware exam was gone. And now I need to get prepared for the VMware VCP4 exam.

As you might now, if you want to prepare yourself for a VMware exam, you need to start with downloading the Exam Blueprint Guide. This guide describes what you should know to pass the exam. In this guide there are references to VMware documentation you should read before taking the exam. And I would love to read all these documents on my iPad. Being a PowerShell scripter I didn’t want to download all these documents and add them to my iTunes library manually. So I wrote a Powershell function to do that for me.

To download a VMware Exam Blueprint Guide you should go to the VMware Certification website:
http://mylearn.vmware.com/portals/certification/. There you should login using a VMware myLearn Login account. So VMware will know who downloads the Blueprint Guides. After you have downloaded the Blueprint Guide, you can use the PowerShell function Add-BlueprintToiTunes from Listing 1, to download all the recommended readings. For those people that don’t use iTunes the function has a DownloadOnly parameter. If you specify this parameter the function will only download the documents and not try to add them to iTunes. If you are using iTunes and want to add the documents to an iTunes library, you can specify the iTunes library name where the documents should go to. This will probably be the library called Books. Or the translation of the English word books in your own language. Being Dutch the library is called “Boeken” for me.

I have tried the Add-BlueprintToiTunes function with all the VMware Exam Blueprint Guides I could download. Unfortunately there were only three guides that the function worked with: VCP4, VCAPDCA and VCAPDCD. These were the only Blueprint Guides that contain clickable links to the documentation. I hope the VCP5 Blueprint Guide will contain these clickable links as well after vSphere 5 is released.

All the relevant documentation, including examples, of the Add-BlueprintToiTunes function is in the comment-based help inside the function.

After you have run the function and added all the documents to your iTunes library, all you have to do is synchronize your iPad and start reading the documents.

Update:
Today I tried this function with the VCP5 Blueprint Guide. Unfortunately this pdf has a different format and the function does not work with the VCP5 Blueprint Guide.

function Add-BlueprintToiTunes {
  <#
    .SYNOPSIS
      This script downloads all the recommended readings from a
      VMware Exam Blueprint Guide and adds them to a iTunes playlist.
  
    .DESCRIPTION
      This script downloads all the recommended readings from a
      VMware Exam Blueprint Guide and adds them to a iTunes playlist.
      You can specify the iTunes playlist and the folder where all the books
      should be stored on your computer. The Blueprint Guide is also added to iTunes.
      You can use the -DownloadOnly parameter to specify that the books should
      only be downloaded and not added to iTunes.
      iTunes has to be installed on the computer where you run this script if
      you want to add the books to iTunes.
      To use this function you should first download the Exam Blueprint Guide
      from the VMware Certification website:
      http://mylearn.vmware.com/portals/certification/

    .PARAMETER BlueprintPath
      Specify the path to the VMwware Exam Blueprint Guide wich recommended readings
      you want to download and add to iTunes.
	
    .PARAMETER Folder
      Specify the folder where the book files should be stored.
	   
    .PARAMETER Playlist
      Specify the iTunes playlist that should contain the books.
	 
    .PARAMETER DownloadOnly
      Use this parameter to specify that the files should
      only be downloaded and not added to iTunes.
  
    .EXAMPLE
      Add-BlueprintToiTunes -BlueprintPath "c:\Users\Robert\My Documents\ebooks\VMware\Training\VCP4\VCP410_Exam_Blueprint_Guide_1.9.5.pdf" -Playlist Books -Folder "c:\Users\Robert\My Documents\ebooks\VMware\Training\VCP4"
	   
      Downloads all the recommended readings from the VCP410 Exam Blueprint Guide
      to folder "c:\Users\Robert\My Documents\ebooks\VMware\Training\VCP4" and adds them to the iTunes playlist Books.
	   
    .EXAMPLE
      Add-BlueprintToiTunes -BlueprintPath "c:\Users\Robert\My Documents\ebooks\VMware\Training\VCP4\VCP410_Exam_Blueprint_Guide_1.9.5.pdf" -Folder "c:\Users\Robert\My Documents\ebooks\VMware\Training\VCP4" -DownloadOnly
	   
      Downloads all the recommended readings from the VCP410 Exam Blueprint Guide
      to folder "c:\Users\Robert\My Documents\ebooks\VMware\Training\VCP4" and doesn't add them to iTunes.
	 
    .NOTES
      Author:  Robert van den Nieuwendijk
      Date:    31-Jul-2011
      Version: 1.0
	
      I have tested this function with all the VMware Exam Blueprint Guides.
      The only ones that contain links to online documentation and work with this function are:
      VCP4, VCAPDCA and VCAPDCD.
      Probably VCP5 will work when VMware vSphere version 5 is released.
	  
      Unfortunately iTunes does not copy the title and header tags that are in the books.
      I couldn't find a way to change these tags in iTunes from this script.
	  
    .COMPONENT
      iTunes
	
    .LINK
      https://rvdnieuwendijk.com/2011/07/31/add-a-vmware-exam-blueprint-guide-recommended-readings-to-itunes-using-powershell/

  #>


  [CmdletBinding(DefaultParameterSetname = "iTunes")]
  #region Parameter definitions
  param([string]$BlueprintPath="$env:USERPROFILE\VCP410_Exam_Blueprint_Guide_1.9.5.pdf",
        [string]$Folder="$env:USERPROFILE",
        [parameter(ParameterSetName="iTunes")][string]$Playlist="Books",
        [parameter(ParameterSetName="DownLoadOnly")][switch]$DownloadOnly=$false)
  #endregion
  
  #region Main Function
  # Check if the Blueprint Guide exists
  if (-not (Test-Path -Path $BlueprintPath)) {
    Write-Error "Could not find Blueprint Guide $BlueprintPath."
    break
  }
  
  # Check if the Folder exists
  if (-not (Test-Path -Path $Folder)) {
    Write-Error "Could not find folder $Folder."
    break
  }
  
  # Add a backslash to the folder if the last character isn't a backslash
  if ($Folder.SubString($Folder.Length-1) -ne "\") {
    $Folder += "\"
  }
  
  # Create the WebClient .Net object
  Try {
    $WebClient = New-Object System.Net.WebClient
    $WebClient.UseDefaultCredentials = $true
    $WebClient.Proxy.Credentials = $WebClient.Credentials
  }
  Catch {
    Write-Error "Could not connect to the System.Net.WebClient object."
    break
  }

  if ($PSCmdlet.ParameterSetName -eq "iTunes") {
    # Connect to iTunes
    Try {
      $iTunes = New-Object -ComObject iTunes.Application
    }
    Catch {
      Write-Error "Could not find iTunes on this computer."
      break
    }

    # Retrieve the playlist
    $iTunesPlaylist = $iTunes.LibrarySource.Playlists | Where-Object {$Playlist -eq $_.Name} 

    If (-not $iTunesPlaylist) {
      Write-Error "Could not find iTunes playlist $Playlist."
      break
    }
 
    # Add the Exam Blueprint Guide to iTunes
    Try {
      $iTunesPlaylist.AddFile($BlueprintPath) | Out-Null
      Write-Verbose "File $BlueprintPath added to iTunes."
    }
    Catch {
      Write-Error "Could not add the Exam Blueprint Guide to the iTunes playlist $Playlist."
    }
  }
  
  # Retrieve the url´s to all recommended pdf files from the Exam Blueprint Guide
  $Pattern = "http:.*\.pdf"
  $Result = Get-Content -Path $BlueprintPath | Select-String -Pattern $Pattern -AllMatches
  $Result | Select-Object -ExpandProperty Matches | `
    Select-Object -Property Value | `
    Sort-Object -Property Value -Unique | `
    ForEach-Object {
      # Download the url and save the file
      $FileName = $_.Value.Split("/")[-1]
      $FullFilePath = "$Folder$FileName"
      Write-Verbose "Downloading Url $FileName and saving it to file $FullFilePath."
      $WebClient.DownloadFile($_.Value,$FullFilePath)
  
      if ($PSCmdlet.ParameterSetName -eq "iTunes") {
        # Add the file to iTunes
        Try {
          $iTunesPlaylist.AddFile($FullFilePath) | Out-Null
          Write-Verbose "File $FullFilePath added to iTunes."
        }
        Catch {
          Write-Error "Could not add file $FullFilePath to iTunes."
        }
      }
    }
  #endregion
}

Listing 1. Add-BlueprintToiTunes function

Advertisements

About Robert van den Nieuwendijk
Robert van den Nieuwendijk is a freelance senior systems engineer with over 30 years of experience in the IT industry. He focusses on VMware vCloud Suite and Microsoft Windows Server. He tries to automate as much of his work as possible using Microsoft PowerShell. Robert is the author of the books “Learning PowerCLI” and “Learning PowerCLI – Second Edition.” Robert is a frequent contributor and moderator at the VMware VMTN Communities. He has a bachelor degree in software engineering and holds the following IT certifications and accreditations: VSP 2016, VTSP 2016, VCP4-DCV, VCP5-DCV, VCP6-Cloud, VCP6-CMA, VCA-Cloud, VCA-WM, VCA-NV, VMSP, VMTSP, ZCS, ZCP, ZCP-Cloud, MCSE, MCSA, MCP, MCP+I, PRINCE2 Foundation and ITIL Foundation. In 2012, 2013, 2014, 2015, 2016 and 2017 Robert received the VMware vExpert award for his contribution to the community of VMware users over the past year. PernixData made him in 2015 a member of the PernixPro.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: