Jul 27th, 2011
by Arnim van Lieshout.
I got a question on my previous post about the Get-EsxCli cmdlet, ESXCLI the PowerCLI way, from Alasdair Carnie who was having trouble using the Get-EsxCli cmdlet to mask luns at the ESXi host level. In this post I’ll show you how to accomplish LUN masking at the ESXi host level.
Note 1:
Before you read any further, please notice that the Get-EsxCli cmdlet is experimental. Also notice that in order to retrieve an esxcli instance you have to be connected directly to an ESX host.
Note 2:
When using the esxcli methods in PowerCLI, remember that you pay close attention to the definition of the specific method. You always have to provide a value for every parameter. If you don’t need to provide a value for a specific parameter, you have to specify the $null value.
Now that we are aware of these requirements, let’s create an additional claimrule to mask a LUN at the ESXi host level. Before we create a new claimrule, we’re going to have a look at the running claimrules on the ESXi host first.
Posted in: ESX, PowerShell, VMware.
Tagged: ESXi · PowerCLI · Storage · VMware
Jun 21st, 2011
by Arnim van Lieshout.
One of the core features of VMware vSphere is the Distributed Resource Scheduler (DRS). VMware DRS is vSphere’s workload load balancer and relies on VMware vMotion technology to live-migrate workloads from one ESX host to another.
You can constrain the VMware DRS decisions by defining DRS Rules. As of vSphere 4.1 there are 2 type of DRS rules:
- VM-to-VM rules
- VM-to-Host rules (new in vSphere 4.1)
VM-to-VM rules
Until vSphere 4.1 you could only create VM-to-VM rules. This type of rule specifies the affinity between virtual machines (VMs). You can define both affinity- and anti-affinity rules.
Affinity rules
Affinity rules keep workloads together on the same ESX host. This is beneficial if for instance an application server needs fast access to its database that resides on another VM. Keeping both VMs together on the same host boosts performance as network traffic between the VMs won’t leave the ESX host. Note that if both servers are in different VLANs or subnets this benefit could be undone, as network traffic might need to be routed externally.
Anti-affinity rules
Anti-affinity rules separate workloads on different ESX hosts. This is beneficial if you have services running on multiple servers for redundancy, like domain controllers or Network Load Balancing (NLB) clusters. In these situations you want to make sure that the VMs are distributed over different ESX hosts. If one ESX host fails, the service would still be available through other VM(s) residing on other ESX hosts.
Posted in: PowerShell, Scripts, VMware.
Tagged: DRS · PowerCLI · Scripts · VMware
May 16th, 2011
by Arnim van Lieshout.
Who would’ve thought that 2011 would become such a great year for me? Earlier this year a dream came true with the release of our PowerCLI book on March 28th. Now, only 2 months after, another dream is about to happen. I think I can honestly say that I’m living my dream right now.
Well, it’s official.
I will be joining VMware as a Senior Consultant starting June 6th.
After almost 13 years, I’m leaving my current employer KEMBIT. During that period KEMBIT has always felt like family to me, so deciding to leave them was not that easy. On the other hand, working for VMware was something I could only dream about and I simply couldn’t refuse the offer.
I want to thank KEMBIT for the opportunity to let me grow my VMware knowledge and for their support and understanding. Thanks guys, it was a blast.
Posted in: Uncategorized.
Tagged: VMware
Apr 18th, 2011
by Arnim van Lieshout.
Now that our PowerCLI Book Raffle has ended and the lucky winner is published, I want to give you a full disclosure of the drawing process. Because our PowerCLI Book is about PowerCLI, what other tool than PowerShell could we use to perform the drawing process?
Twitter Fun
So first we need to retrieve all the twitter messages that people re-tweeted on Twitter. In order to do that we need to call the HTTP based Twitter search API. For more information on how to use the Twitter search API have a look at http://search.twitter.com/api/ This page shows us that the Twitter search API supports the Atom format through the Atom service URL “http://search.twitter.com/search.atom?q=<query>”. It also shows us the supported URL parameters. The most important parameters are:
- rpp: the number of tweets to return per page, up to a max of 100
- page: the page number to return, up to a max of roughly 1500 results (based on rpp * page
In order to perform a simple search, we only need to fill in the query parameter. We are interested in all messages that contain both “powerclibook” and “magictweet”. In order to search for tweets that contain both words, we need to concatenate them with the plus (+) sign, like http://search.twitter.com/search.atom?q=powerclibook+magictweet. To see the results you could simply paste that URL into your browser.
Continue reading →
Posted in: PowerShell, Scripts.
Tagged: PowerCLI · Scripts · Twitter
Mar 28th, 2011
by Arnim van Lieshout.
It has been quite a journey, but it has finally arrived. Today our book: “VMware vSphere PowerCLI Reference: Automating vSphere Administration” will be released by Sybex. The journey started about a year ago when Alan Renouf and Luc Dekens decided to write a PowerCLI book that should have a practical approach to vSphere administration. Later that year they contacted 3 co-authors to help them out in order to keep meeting the deadlines. The PowerCLI book team was born and the book was to be written by “4 vExperts and a MVP”.
From this point I would like to personally thank Alan and Luc for the opportunity to realize a dream. I would also like to personally thank Mary Ellen Schutz, Developmental Editor, for transforming my technical gibberish into readable and most importantly understandable language. Last but not least I would like to personally thank our Technical Editor, Stuart Radnidge. He left no script unturned and served as the gatekeeper, ensuring that any code you find in the book will run the first time, every time. You might think that’s all there is to it, but then you’re wrong. I’ve never written a book before and I was impressed by the number of people that were involved behind the scenes in this book thing. On the Sybex team there were numerous people involved including but not limited to: Editorial Manager, Acquisition Editor, Production Editor, Copyeditor, Indexer, Proofreader and Compositor. Without each of their contributions, this book would have never made it to the presses.
Posted in: PowerShell, Scripts, VMware.
Tagged: PowerCLI · Scripts · VMware
Mar 18th, 2011
by Arnim van Lieshout.
Today VMware announced the release of the vSphere Client for iPad. The first great thing is that you can download the vSphere Client for iPad from Apple’s iTunes Store for FREE! The second great thing is that it looks really awesome and the interface is very intuitive.
VMware is taking mobility very seriously as this is their second application specifically for the iPad. Recently VMware released the VMware View Client for iPad. The vSphere Client for iPad isn’t meant to be a fully functional equivalent for the existing Windows client, but allows you to do the most common tasks, according to VMware. With the current release, the functionality offered by the vSphere Client for iPad is:
- Search for vSphere hosts and virtual machines
- Monitor the performance of vSphere hosts and virtual machines
- Manage virtual machines with the ability to start, stop and suspend
- View and restore virtual machines’ snapshots
- Reboot vSphere hosts or put them into maintenance mode
- Diagnose vSphere hosts and virtual machines using built-in ping and traceroute tools
The ability to manage your vSphere environment with a mobile device isn’t new, as VMware already provides the vCenter Mobile Acces (vCMA) virtual appliance. If you’re familiar with this vCMA, you might recognize the vSphere Client for iPad’s functionality. In fact it’s built on top of this vCMA. The vCMA is required in order for the vSphere Client for iPad to function and can be obtained from VMware free of charge at http://labs.vmware.com/flings/vcma The latest version of the vCMA has now SSL configured by default, to make sure your connection is secure. Because you connect to the vCMA virtual appliance using standard SSL, you can easily use the vSphere Client for iPad to connect to the vCMA through a firewall to manage your vSphere environment.
Posted in: Tools, VMware.
Tagged: iPad · Tools · vCenter · VMware
Feb 17th, 2011
by Arnim van Lieshout.
While preparing some disaster recovery (DR) tests, I had to add and remove a couple of LUNS from several ESX hosts in different clusters. Doing so, I had to rescan a lot of host bus adapters (HBA) several times. As I hate doing repetitive tasks in a graphical user interface (GUI), I always find myself quickly turning to the PowerCLI console. The PowerCLI command to rescan an ESX host is somewhere hidden in the Get-VMHostStorage cmdlet. This isn’t the most logical location and every time I have to perform a rescan operation I have to search for the correct command line syntax.
Today I decided to simplify that process and created a little PowerCLI function to simplify this task. The function I created is called Rescan-VMHost and accepts an ESX host name or host object as input parameter.
Rescan-VMHost ESX01
The function also accepts host names or host objects from the pipeline. The optional -IncludePeers switch rescans all hosts in the given ESX host’s cluster additionally.
Get-VMHost ESX01 | Rescan-VMHost -IncludePeers
As an extra bonus feature the function also accepts a cluster object as input parameter and will rescan all ESX hosts in the given cluster.
Get-Cluster CL01 | Rescan-VMHost
Pretty cool huh?
I’ve already used this little function a lot and hope you find a use case for it too.
One last thing. Although the title of this post might suggest that this function works on ESXi only, that is NOT the case. The function will work on both ESXi and ESX, but since VMware decided to go solely with ESXi and refers to it as the VMware vSphere Hypervisor, I decided to follow that path and hence the post’s title.
function Rescan-VMHost {
<#
.SYNOPSIS
Performs a rescan operation on a specified ESX host or cluster
.DESCRIPTION
This function rescans an ESX host or it's complete cluster when the -IncludePeers parameter is specified.
.NOTES
Author: Arnim van Lieshout,
.PARAMETER Entity
Specifies the hostname, host object or cluster object to perform the rescan operation on.
.PARAMETER IncludePeers
Specifies that all the hosts in the host's cluster should be rescanned instead of only the host itself.
.EXAMPLE
PS> Rescan-VMHost ESX001
.EXAMPLE
PS> Get-VMHost ESX00* | Rescan-VMHost -IncludePeers
.EXAMPLE
PS> Get-Cluster CL01 | Rescan-VMHost
#>
Param (
[parameter(valuefrompipeline = $true, mandatory = $true,
HelpMessage = "Enter an ESX(i) entity")]
[PSObject]$Entity,
[Switch]$IncludePeers)
process {
switch ($Entity.gettype().name) {
"String" {
if ($IncludePeers) {Get-VMHost -Name $Entity | Rescan-VMHost -IncludePeers}
else {Get-VMHost -Name $Entity | Rescan-VMHost}
}
"VMHostImpl" {
if ($IncludePeers) {
foreach ($VMHost in Get-Cluster $Entity.Parent | Get-VMHost) {
$VMHost | Get-VMHostStorage -RescanAllHba
}
}
else {
$Entity | Get-VMHostStorage -RescanAllHba
}
}
"ClusterImpl" {
foreach ($VMHost in $Entity | Get-VMHost) {
$VMHost | Get-VMHostStorage -RescanAllHba
}
}
default {throw "No valid object type for parameter -VMHost specified"}
}
}
}
Posted in: PowerShell, Scripts.
Tagged: ESX · ESXi · PowerCLI · PowerShell · Scripts · VMware
Jan 25th, 2011
by Arnim van Lieshout.
As you might know, I was asked to co-author a PowerCLI book. Now that the book is nearly finished we posted an update on our book’s website at www.powerclibook.com. If you’re interested in what will be covered in the upcoming book called “VMware vSphere PowerCLI Reference: Automating vSphere Administration” (Yes, I know it’s a mouth full, but I didn’t made the title) view the book’s table of contents on our book’s website.
This upcoming valuable resource (at least that’s what we think) is written by:
If you want to receive the latest updates on our book, make sure you subscribe to the PowerCLI book’s RSS feed.
You can already pre-order the book
on various online bookstores. Secure your first edition collector’s item now!
Posted in: VMware.
Tagged: PowerCLI · PowerShell · Scripts · VMware
Jan 20th, 2011
by Arnim van Lieshout.
As a security recommendation you should always disable Tech Support Mode (TSM) on your ESXi servers, but sometimes it’s helpful if you’re able to connect to your ESXi server using Secure Shell (SSH). When you want to enable TSM, you have 3 options:
- Use the Direct Console User Interface (DCUI)
- Use the vSphere Client
- Script it (using PowerCLI for example).
Enabling TSM using the DCUI
- Connect to the server console of your ESXi host.
- At the DCUI screen (Alt-F2) of the ESXi host, press F2 and provide credentials when prompted.
-
Select
Troubleshooting Options and press
Enter.
- If you want to enable local TSM, select Enable Local Tech Support and press Enter. This allows you to login using the local console (ALT-F1) of the ESXi host.
- If you want to enable remote TSM, select Enable Remote Tech Support (SSH) and press Enter. This allows you to login to the ESXi host via SSH.
-
Optionally you can configure a timeout that specifies the availability of TSM. After the timeout expires, TSM will be disabled again. Active sessions won’t be terminated however. To specify a TSM timeout:
- Select Modify Tech Support timeout and press Enter.
- Enter the desired timeout value in minutes and press Enter.
- Press Esc three times to return to the main DCUI screen.
Posted in: ESX, PowerShell, Scripts, VMware.
Tagged: ESXi · PowerCLI · PowerShell · Scripts · VMware
Jan 13th, 2011
by Arnim van Lieshout.
The storage network administrator drew my attention to the Brocade Network Advisor (BNA) Management Plug-in for VMware vCenter.
Brocade Network Advisor
Brocade Network Advisor provides a unified network management solution across Brocade Fibre Channel SANs, Fibre Channel over Ethernet (FCoE), Layer 2/3 IP switches and routers, Wireless, Layer 4/7 Application Delivery networks and Multiprotocol Label Switching (MPLS) networks. It provides a consistent user interface along with custom views and controls based on users’ areas of specialization. For more information have a look at the Brocade site or view the solutions brief
Management Plug-in for VMware vCenter
The management plug-in for VMware vCenter displays SAN connectivity information for managed ESX server hosts and switch port statistics in the vSphere client. It’s implemented as a web application hosted on the BNA Management server. This web application sends dynamic HTML content to the vSphere client and the client renders the HTML content.
- SAN connectivity information of each virtual machine across all managed ESX hosts of the vCenter server.
- Switch or AG port statistics of the switch to which the host is directly connected.
- End-to-end (EE) monitor statistics (collected by EE monitors on the switch).
- SAN events based on Fabric OS events displayed in the vSphere client. These events include a crossed threshold at the switch or AG ports for transmit or receive percent utilization as well an adapter port logging out of the fabric.
The VMware vCenter plug-in is supported on:
- ESX 4.0 and ESX 3.5
- vCenter 4.0 and later
- Plug-in will support managing ESX hosts with adapters from following vendors:
- Brocade Communications
- Q-Logic
- Emulex
Please note that the management plug-in for vCenter is only available in the BNA Professional and Enterprise products. After reading more info on the Brocade website, we decided to give it a try, but the problem was that we didn’t find any download available. Also consulting our Brocade contacts didn’t brought a solution. Digging through BNA’s documentation, we found out that the VMware vCenter management plug-in isn’t a separate download, but already integrated in BNA.
Posted in: Tools, VMware.
Tagged: ESX · Storage · vCenter · VMware