May 7th, 2015 by JFrappier

Jonathan Frappier Virtxpert

The PowerCLI Cookbook by Phillip Sellers is an excellent resource for any skill level, whether you are a beginner or looking for a great reference to have with you.

PowerCLI Cookbook by Phillip Sellers

First and foremost, this book far exceeds what I expect out of a technology cookbook. If you step back and think about a (food) cookbook you get the recipe for what you are going to make (i.e. what you are going to do in PowerCLI) and the ingredients to make it (i.e. the cmdlets necessary to perform the task). Phillip took that a step further and began the cookbook with how to actually start the oven, or in this case a simple recipe to connect to vCenter and get started using PowerCLI.

The chapters in the book are laid out very well, starting with basic hosts related tasks, before moving on to vCenter, virtual machines, and other more complex scenarios – the build up in this format makes it excellent for those who are new to PowerCLI, or even VMware for that matter. Each recipie also has a “how it works” section where the components use are explained (no one has ever told me how food flavors work together!).

You could quite literally use the book to just about stand up a complete vSphere environment as all the major topics such as networking, datastores, clusters, and virtual machine management (including using PowerCLI to invoke in guest scrips) is covered.

**Disclaimer – I have a book published with Packt Publishing and spoke to Phillip before he decided to write the book. This book was provided to me by the author but the review was not read, or approved by Phillip, it is simply my opinion on the book and its contents.**

Yummy! – PowerCLI Cookbook Review by Phillip Sellers (@pbsellers)

Posted in Tech Tagged with: , , , , , , , , ,

December 22nd, 2014 by JFrappier

Jonathan Frappier Virtxpert

SamSnowmanI don’t know what I would have done without Commitmas to pull us through. Anyway – uh, Commitmas? Huh, could it be that some of you are not acquainted with the story of Commitmas?

Yesterday was the first day of Commitmas, a community event thought up by Matt Brender to help us all get used to sharing code and working with GitHub. The challenges vary based on your level of comfort – I am starting in the beginner track and hoping to work my comfort level up to being a “beginner intermediate” by the end. Now I am no developer but I see the train coming, and for all the vCommunity out there I hope you see it coming at well. The future is code and scripts; Commitmas is a great way to prepare.

Last month I published a few posts on Ansible, as part of that I created a repository on GitHub to put my playbooks in. To get back into the swing of GitHub I decided to install Git on Windows, clone my Ansible repository and create a simple README file.

What little knowledge and hands on with GitHub I have has all been from a Linux based system. On Windows you lack some of the common tools you have with Linux such as the ability to create SSH keys or an SSH client. The Git install for Windows provides these for you. Installing Git for Windows is easy, thanks for course to Chocolatey.org; if you have not used Chocolatey before installing it is also quite simple. Open a cmd prompt as admimistrator and run

@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%chocolateybin

Now packages are as easy to install as running

choco install git

Once installed, we need to verify a few system settings:

  • Go to Advanced system settings (Start >> Control Panel >> System >> Advanced system settings)
  • Click on Environment Variables
  • In the System variables section locate ‘Path’ and verify C:Program Files (x86)Gitcmd; is there
  • Add C:Program Files (x86)Gitbin; directly after C:Program Files (x86)Gitcmd; with no spaces after the ; (make sure you also end with a ;)
  • For SSH commands to work later, you need to add a variable.  In the User variables for user section, click the New… button
  • Create a variable named HOME with a value of %USERPROFILE%
  • Click OK three times and reboot the computer. After the reboot you

After the reboot you should be able to open a cmd prompt and run ssh and not get a “ssh is not a recognized command” message

ssh-windows

We are now ready to setup GitHub on Windows. If you haven’t done so already, create a user account on GitHub. There are a few commands we need to run to get everything ready.

  • git config –global user.name username [where username is your actual username, for example jfrappier]
  • git config –global user.email [email protected] [where [email protected] is your actual email that you signed up for GitHub with]
  • ssh-keygen -t rsa -C [email protected]
  • Select the location to save the key, I accepted the default
  • Enter a passprhase

CD to %userprofile%.ssh; you should see two files – id_rsa and id_rsa.pub.

  • Open id_rsa.pub in note pad and copy the contents
  • Log into GitHub and click on Settings (the gear icon in the upper right corner) >> ssh keys
  • Click Add SSH key
  • Provide a name, paste the contents from id_rsa.pub into the key textbox, and click Add key

Now switch back to your cmd prompt window

  • Type ssh -T [email protected]
  • Type yes to accept the certificate
  • Type the passphrase you set for your key previously

You are now authenticated with GitHub, you can now enjoy the 12 days of Commitmas!

ssh-github-windows

 

On the first day of Commitmas – Windows Git, SSH, and Keys

Posted in Tech Tagged with: , , , , , , , , , , , , , , , , , ,

November 10th, 2014 by JFrappier

Jonathan Frappier Virtxpert

In the last post we looked quickly at importing the vCenter Server Appliance through the vSphere Client, however its high time we introduce PowerCLI.  PowerCLI is a set of PowerShell cmdlets to manage your VMware environments (vSphere, vCloud Director and View) and is quite powerful.  So powerful in fact that this is going to be a pretty short post, the 7 bullet points needed just to import the OVF through the vSphere Client is now a single command!

Launch PowerCLI as administrator and run the following to log in:

connect-viserver 192.168.6.11

Log in as root when prompted.

Now either change to the directory the OVF is located in or make note of the location for the cmdlet:

Import-VApp -source .VMware-vCenter-Server-Appliance-5.5.x.xxxxx-xxxxxxx_OVF.ova -VMhost 192.168.6.11 -DiskStorageFormat thin -name vxprt-vc01

Below you can see it in console as well as it happening if you were to log into the vSphere Client

PowerCLI Import-VApp progress

PowerCLI Import-VApp progress

View PowerCLI Import-VApp progress in the vSphere Client

View PowerCLI Import-VApp progress in the vSphere Client

1 command – how do you not love PowerCLI?  You can see all of the options available in the Import-VApp cmdlet in the PowerCLI documentation.  Now having shown you those options, I am actually going to run the VCSA in VMware Workstation, simply click File >> Open, select the OVF then provide a name and location.  Power on the VCSA and see my post here about configuring it.

Importing VCSA via PowerCLI – VMware Workstation Home Lab Setup Part 10

Posted in Tech Tagged with: , , , , , , , , , , , , , , , , , , ,

November 9th, 2014 by JFrappier

Jonathan Frappier Virtxpert

So had a need to clone a vApp several times, I finally got around to automating thanks again to PowerCLI.  A few things I had to consider; with the New-VApp cmdlet you cannot select portgroups so I had to do that after the vApp was clone and also needed to put the vApp into a specific folder after it was clone.  Otherwise, it was actually kind of easy to figure out based on what I needed to accomplish.  Here it is, in case you need to accomplish it as well :)

#Get vApp names and port groups
$CSVfile = "c:adminscriptsehc_vapps.csv"

# Set PowerCLI Options
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | Out-Null

$EHC_vApps = Import-Csv -Path $CSVfile
ForEach ($EHC_vApp in $EHC_vApps)
{
#Creates new vApp
New-VApp -Name $EHC_vApp.name -Datastore $EHC_vApp.datastore -Location $EHC_vApp.cluster -VApp $EHC_vApp.template

#Get list of vApp VMs to set network card
$vApp_vms = Get-VApp $EHC_vApp.name | Get-VM
ForEach ($vApp_vm in $vApp_vms)
{
Get-VM -Location $EHC_vApp.name $vApp_vm | Get-NetworkAdapter | Set-NetworkAdapter -Portgroup $EHC_vApp.portgroup -Confirm:$false
}

#Move vApp to StudentPod folder
Move-VApp -Destination $EHC_vApp.folder -VApp $EHC_vApp.name
}

PowerCLI to Clone a vApp

Posted in Tech Tagged with: , , , , , , , , , , , , , , ,

November 8th, 2014 by JFrappier

Jonathan Frappier Virtxpert

So now we’ve got two ESXi hosts and our domain controller running in the home lab, it’s almost time to setup vCenter however, in a real world scenario you would need a way to get vCenter onto the ESXi hosts (because of course you are virtualizing vCenter).  Up until now what we have done through the DCUI would have been at a keyboard and mouse or virtual KVM (such as Cisco UCS or HP iLO) and we cannot create virtual machines via the DCUI.  So, what tools are available to manage our ESXi hosts to start creating virtual machines?

First, typically most people would start with the Windows vSphere Client.  This client can connect directly to an ESXi host and start creating virtual machines, such as a Windows virtual machine for vCenter or importing virtual appliances such as the vCenter Server Appliance (VCSA) which we will use in our lab set later on.  You can see all of my VCSA related posts below:

You can download the Windows vSphere client from the ESXi getting started page by navigating the IP address of one of your ESXi hosts (like was done in the last post at https://192.168.6.11).  If you are running Windows 8.x you will need to download a J++ package and install it before proceeding with the Windows vSphere Client, thanks to my friend Matthew Brender for reminding me of that gotcha which also means you will need to turn on the .NET Framework 3.5.  To do so, open the Start menu, go to Control Panel >> Programs and Features and click Turn Windows features on or off.  Tick the .Net Framework 3.5 box and click OK

enable-dotnet35-windows81

Once .NET 3.5 is enabled and J++ is installed, download the vSphere Client, run the installation wizard and log in to the IP address/host name of your ESXi host as root.

vSphere Client

vSphere Client

Another option is to install PowerCLI, which is based on PowerShell and very powerful with many options to manage both ESXi hosts, virtual machines and more.  Again download and run through the PowerCLI installation wizard, it will install a few additional componenets as part of the install.  Once installed launch PowerShell as administrator (even if you are logged in as an administrator) and run

Set-ExecutionPolicy RemoteSigned

You should now be able to launch PowerCLI and run

Connect-VIServer 192.168.6.11

You will be prompted for a username and password and are then connected and can run cmdlets in PowerCLI to import or create new virtual machines.

powershell-powercli

PowerShell Set-ExecutionPolicy and PowerCLI

Since we are using VMware Workstation, we can also use that to connect to the ESXi hosts (or a vCenter server later) as well.  In VMware Workstation, click on File >> Connect to server.  Enter the IP, username (root) and password to log in.  You can now create virtual machines on your virtual ESXi host running in VMware Workstation from VMware Workstation!

esxi-vmware-workstation

ESXi in VMware Workstation

In the next post, we will use the vSphere Web Client and PowerCLI to import the vCenter Server Appliance for our home lab which will provide (obviously) vCenter, Single Sign-On (SSO) and the vSphere Web Client which is where we will do most of the work through this series.

VMware Workstaion Home Lab Setup Part 7 – Management Tools

Posted in Tech Tagged with: , , , , , , , , , , , , , , , , , , , ,