Below you will find pages that utilize the taxonomy term “VMware”
Posts
Foreman ESXi Installation Never Completes
In our environment we want to use Foreman to build our OCP hardware. It was working well except that the installation would repeatedly PXE boot to reinstall because Foreman would not know that the PXE portion was complete.
The standard notification code below was failing for some reason.
1 2 %post --interpreter=busybox --ignorefailure=true wget -O /dev/null <%= foreman_url %> After running the unattended install in a Fusion VM so I could have console access I reviewed the install log and a misleading message from wget about the URL being bad.
Posts
PowerCLI Move-Datastore Function
Moving datastores into folders via drag/drop can be painful. In some cases vCenter does not want to allow a drag from a long list. Here is a quick function to make moving via PowerCLI a little bit easier.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Function Move-Datastore { param ( [VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.VmfsDatastoreImpl[]] $datastore = $(throw "Datastore(s) must be provided.
Posts
Convenience Functions for Connecting to Multiple vCenters
In a large environment repeatedly connecting and disconnecting from groups of vCenters can be tedious so I created some helper functions and put them in my PowerShell profile.
1 2 3 Connect-VIServerGroup lab Connect-VIServerGroup desktops Disconnect-VIServerGroup lab 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Function Connect-VIServerGroup { param ( [String]$group = $(throw "A VI server group name must be specified.
Posts
Single pane for multiple vCenter alarms
When you have multiple vCenters it can be a pain to go through each one checking for alarms. Hence the script below. You can specify the vCenters you want to connect to and it will display a nice sortable/filterable grid view of all of the triggered alarms.
# Usage .\Get-TriggeredAlarms -vCenters vc001,vc002 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 param ( [String[]]$vCenters ) Function Get-TriggeredAlarms { param ( $vCenter = $(throw "A vCenter must be specified.
Posts
Validate datastore visibility between hosts
This script will check a set of hosts and report on whether the available datastores match. The first host found becomes the reference host and the others are compared against it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 param ( [VMware.
Posts
Find LUNs Presented to Multiple Clusters
After some cluster migrations it appears that not all of the LUN presentations got cleaned up. I needed to find the LUNs that were shared by different clusters so I could determine which one they should belong to and remove access for the other cluster(s). PowerCLI to the rescue.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 param ( [VMware.
Posts
Validate Username / Password on ESX(i) Host
A simple script to validate the login credentials against an ESX(i) host. Useful when validating that the credentials are what you think they should be.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 <# .
Posts
VMware PowerCLI 5 Cmdlets by Noun
Generated using this post.
<th> Verbs </th> <td> Get,New,Remove,Set </td> <td> Get,New,Remove </td> <td> Get,New,Remove </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,New,Remove,Set </td> <td> Get,Move,New,Remove,Set </td> <td> Get,New,Remove,Set </td> <td> New,Remove,Set </td> <td> Get,Move,New,Remove,Set </td> <td> Get,New,Remove,Set </td> <td> Get </td> <td> Copy </td> <td> Apply,Get </td> <td> Get,New,Remove,Set </td> <td> Get </td> <td> Get </td> <td> Get </td> <td> Get,New,Remove,Set </td> <td> Get,Move,New,Remove,Set </td> <td> Get </td> <td> Copy,Get,New,Remove,Set </td> <td> Get,Move,Remove </td> <td> Get,New,Remove,Set </td> <td> Get </td> <td> Get </td> <td> Get,New,Remove,Set </td> <td> Get,Set </td> <td> Get,New,Remove,Set </td> <td> Get,New,Remove,Set </td> <td> Add,Get,Remove </td> <td> Get,Set </td> <td> Get </td> <td> Get,Move,New,Remove,Set </td> <td> Get,New,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,New,Remove,Set </td> <td> Get </td> <td> Get,New,Remove,Set </td> <td> Get </td> <td> Get,Stop,Wait </td> <td> Get,Move,New,Remove,Set </td> <td> Dismount,Mount,Update,Wait </td> <td> Get,Remove </td> <td> Export,Get,Import,Move,New,Remove,Set,Start,Stop </td> <td> Get </td> <td> Get,New,Remove </td> <td> Get </td> <td> Get </td> <td> Get </td> <td> Get,New,Remove,Set </td> <td> Get </td> <td> Get,New,Remove </td> <td> Get,New,Remove,Set </td> <td> Get,New,Remove,Set </td> <td> Get,New,Remove,Set </td> <td> Connect,Disconnect </td> <td> Get,Move,New,Remove,Restart,Set,Start,Stop,Suspend </td> <td> Get,Restart,Shutdown,Suspend </td> <td> Copy </td> <td> Get,Set </td> <td> Get,New,Remove </td> <td> Add,Get,Move,Remove,Restart,Set,Start,Stop,Suspend </td> <td> Get,New,Remove,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get </td> <td> Get,Set </td> <td> Get </td> <td> Format,Get </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,New,Remove,Set </td> <td> Add,Get,Remove </td> <td> Get,Install </td> <td> Apply,Export,Get,Import,New,Remove,Set </td> <td> Test </td> <td> Get </td> <td> Get,New,Remove,Set </td> <td> Get,Restart,Set,Start,Stop </td> <td> Get,Set,Test </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Invoke </td> <td> Get,Set </td>
Posts
Central Ohio VMUG Regional Event 2011
The regional VMware Users Group meeting for 2011 is coming up on May 17th. This was a great event last year and it looks like it could be even better this year.
So far, the named speakers are Chad Sakac, Scott Herold, and Tom Mackay.
Make sure to review the agenda and register before it fills up.
http://info.vmware.com/content/VMUG_Conference_Agenda?src=ws&ug=oh
Posts
Quick Memory Allocation for Limit / Reservation Testing in VMware
I am testing the impact and behavior of memory limits and reservations along with balloon drivers and I needed a quick way to allocate memory in a user program.
PowerShell to the rescue. This isn’t a good method for exact memory allocation, but you can consume MBs to GBs of memory pretty quickly.
1 2 3 4 5 # Allocate memory by creating a large string. Divide the length by 4 # (Unicode size) to get an approximation of the MB allocation.
Posts
Testing TCP Network Firewall Ports from ESXi
As we all transition to ESXi there are certain activities that we need to figure out a new way of doing. One item that comes up in new deployments is making sure that all of the ESXi –> firewall rules are defined correctly.
I do not believe that there is a way to do this from the SDK so its off to Tech Support Mode. Unfortunately there is no telnet, netcat, or other network tool that I typically use.
Posts
Using PowerCLI to Uninstall vCenter Extensions
After finishing a CapacityIQ evaluation we wanted to uninstall the plug-in from vCenter. VMware KB article 1025360 shows how to do this, but it requires the Managed Object Browser. Per the security hardening guide we disabled the mob so this solution would not work as given. PowerCLI to the rescue.
Here are the steps given in the original article and how they translate into PowerCLI.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 #1.
Posts
VMware PowerCLI 4.1.1 Cmdlets by Noun
Generated using this post.
<th> Verbs </th> <td> Get,New,Remove,Set </td> <td> Get,New,Remove </td> <td> Get,New,Remove </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,New,Remove,Set </td> <td> Get,Move,New,Remove,Set </td> <td> Get,New,Remove,Set </td> <td> New,Remove,Set </td> <td> Get,Move,New,Remove,Set </td> <td> Get,New,Remove,Set </td> <td> Copy </td> <td> Apply,Get </td> <td> Get,New,Remove,Set </td> <td> Get </td> <td> Get </td> <td> Get </td> <td> Get,New,Remove,Set </td> <td> Get,Move,New,Remove,Set </td> <td> Get </td> <td> Copy,Get,New,Remove,Set </td> <td> Get,Move,Remove </td> <td> Get,New,Remove,Set </td> <td> Get </td> <td> Get </td> <td> Get,New,Remove,Set </td> <td> Get,Set </td> <td> Get,New,Remove,Set </td> <td> Get,New,Remove,Set </td> <td> Add,Get,Remove </td> <td> Get,Set </td> <td> Get </td> <td> Get,Move,New,Remove,Set </td> <td> Get,New,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,New,Remove,Set </td> <td> Get </td> <td> Get,New,Remove,Set </td> <td> Get </td> <td> Get,Stop,Wait </td> <td> Get,Move,New,Remove,Set </td> <td> Dismount,Mount,Update,Wait </td> <td> Get,Remove </td> <td> Export,Get,Import,New,Remove,Set,Start,Stop </td> <td> Get,New,Remove </td> <td> Get </td> <td> Get </td> <td> Get </td> <td> Get,New,Remove,Set </td> <td> Get </td> <td> New,Remove </td> <td> Get,New,Remove,Set </td> <td> Get,New,Remove,Set </td> <td> Get,New,Remove,Set </td> <td> Connect,Disconnect </td> <td> Get,Move,New,Remove,Restart,Set,Start,Stop,Suspend </td> <td> Get,Restart,Shutdown,Suspend </td> <td> Copy </td> <td> Get,Set </td> <td> Get,New,Remove </td> <td> Add,Get,Move,Remove,Restart,Set,Start,Stop,Suspend </td> <td> Get,New,Remove,Set </td> <td> Get,Set </td> <td> Get </td> <td> Get,Set </td> <td> Get </td> <td> Format,Get </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,New,Remove,Set </td> <td> Add,Get,Remove </td> <td> Get,Install </td> <td> Apply,Export,Get,Import,New,Remove,Set </td> <td> Test </td> <td> Get,New,Remove,Set </td> <td> Get,Restart,Set,Start,Stop </td> <td> Get,Set,Test </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Invoke </td> <td> Get,Set </td>
Posts
PowerCLI Presentation from Central Ohio VMUG
Here is an introduction to PowerCli presentation I gave back in July at the Central Ohio VMware User’s Group.
Posts
VMware PowerCLI 4.1 Cmdlets Summarized by Noun
Here is the list of VMware PowerCLI cmdlets ordered by noun. I find this easier to use when I am trying to write scripts. You can locate what items you want to work with and then see the action you can take. This post contains the code used to generate the list.
<th> Verbs </th> <td> Get,Set </td> <td> Get,New,Remove,Set </td> <td> Get,Move,New,Remove,Set </td> <td> Get,New,Remove,Set </td> <td> New,Remove,Set </td> <td> Get,Move,New,Remove,Set </td> <td> Get,New,Remove,Set </td> <td> Copy </td> <td> Apply,Get </td> <td> Get,New,Remove,Set </td> <td> Get </td> <td> Get,New,Remove,Set </td> <td> Get,Move,New,Remove,Set </td> <td> Copy,Get,New,Remove,Set </td> <td> Get,Move,Remove </td> <td> Get,New,Remove,Set </td> <td> Get </td> <td> Get </td> <td> Get,New,Remove,Set </td> <td> Get,Set </td> <td> Get,New,Remove,Set </td> <td> Get,New,Remove,Set </td> <td> Add,Get,Remove </td> <td> Get,Set </td> <td> Get </td> <td> Get,Move,New,Remove,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,New,Remove,Set </td> <td> Get </td> <td> Get,New,Remove,Set </td> <td> Get </td> <td> Get,Stop,Wait </td> <td> Get,Move,New,Remove,Set </td> <td> Dismount,Mount,Update </td> <td> Get,Remove </td> <td> Export,Get,Import,New,Remove,Set,Start,Stop </td> <td> Get,New,Remove </td> <td> Get </td> <td> Get </td> <td> Get </td> <td> Get,New,Remove,Set </td> <td> Get </td> <td> New,Remove </td> <td> Get,New,Remove,Set </td> <td> Get,New,Remove,Set </td> <td> Get,New,Remove,Set </td> <td> Connect,Disconnect </td> <td> Get,Move,New,Remove,Restart,Set,Start,Stop,Suspend </td> <td> Get,Restart,Shutdown,Suspend </td> <td> Copy </td> <td> Get,Set </td> <td> Get,New,Remove,Set </td> <td> Add,Get,Move,Remove,Restart,Set,Start,Stop,Suspend </td> <td> Get,New,Remove,Set </td> <td> Get,Set </td> <td> Get </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,New,Remove,Set </td> <td> Add,Get,Remove </td> <td> Get,Install </td> <td> Apply,Export,Get,Import,New,Remove,Set </td> <td> Test </td> <td> Get,New,Remove,Set </td> <td> Get,Restart,Set,Start,Stop </td> <td> Get,Set,Test </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Get,Set </td> <td> Invoke </td> <td> Get,Set </td>
Posts
Quick and dirty PowerPath/VE output parser
Here is a quick and dirty PowerShell script to parse the output of the rpowermt command used to manage PowerPath/VE on ESX (for EMC arrays). I wrote the code quickly to solve a particular problem, but if I get requests I could extend it to parse the rest of the output and do so in a little more robust fashion.
Why do this? I am in the middle of migrations between frames and I needed an easy way to determine what needed moved when the storage admin said move all LUNs from CLARiiON XXXX to the new LUNs on YYYY – and make sure to move LUN 41 to LUN 88.
Posts
Recovering from lockdown mode, a corrupt vCenter, and no DCUI
One of the worst case scenarios when securing an ESXi host is disabling the DCUI, enabling lockdown mode, and then losing vCenter for some reason. If your vCenter database is corrupt then you have lost the ability to manage the host. The official answer at this point is to rebuild the host. While I hope you have an automated build process that would make this easy, there is at least one other option to recover your system.
Posts
VMware PowerShell Get-VIHumanReadablePath
An example of how to get the human readable path of an object in the VMware SDK. This is using PowerShell and requires that PowerCLI be installed, but should be easily converted to other languages.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 Function Get-VIHumanReadablePath { param ( $target ) try { if ($target.
Posts
VMware Update Manager: Different non-critical host updates for Nexus
I have 5 difference vCenter servers installed over various timeframes and I am seeing different counts for the Non-Critical Host Updates across them. After some digging it appears that this is due to the Nexus 1000v updates.
We have not deployed the Nexus to production yet so this was a little confusing for me. It appears that when Update Manager is installed it downloaded the patches for the Nexus 1000v, but they are not included in the updates that are downloaded because we have none running in the environment and Update Manager was not configured to download them.
Posts
PXE booting ESXi 4.1 installer from Altiris(HP RDP)
I am looking to do PXE booting of the ESXi installer as the first step in rolling out my new automated deployment solution. We already have an Altiris (HP RDP) PXE server in house for Windows deployments so I needed to figure out a way to make it work. Below is the first phase of this using standard pxelinux and not gPXE.
Download the ESXi 4.1 installable release from VMware Download the current 3.
Posts
Another Orchestrator/PowerShell hang issue
It has come to my attention that some times the scripts will still hang after using the trick from a previous post to fix an issue with standard input when running PowerShell in Orchestrator workflows. After further research there appears to be an issue with stderr hanging the scripts in a similar way to stdin. To be safe you should do something with the output from stderr (where error messages are sent).
Posts
Running PowerShell in VMware Orchestrator – updated
Updated 7/29/2010 – I have added a new follow up post this post regarding another related hanging issue. Please make sure to check it out.
This is a copy of my comment in the VMware Communities, but some times the Google search results for items in this blog show up and the ones for the communities do not.
The original problem is that PowerShell scripts hang when running them in Orchestrator.
Posts
Adding VMware PowerCLI to your standard PowerShell environment
In order to get access to PowerCLI when using another PowerShell shortcut or environment you can run the following commands which is what happens when you run the VMware provided shortcut.
1 2 3 4 5 6 # Adds the base cmdlets Add-PSSnapin VMware.VimAutomation.Core # Add the following if you want to do things with Update Manager Add-PSSnapin VMware.VumAutomation # This script adds some helper functions and sets the appearance.
Posts
PowerCLI Examples for VMUG Presentation 7/20/2010
These are some examples that I will be reviewing at an upcoming Central Ohio VMware User’s Group.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 # List all VMs Get-VM # Get one VM Get-VM ubuntu01 # Get VMs that match Get-VM ubuntu* # List VMs in a Datacenter Get-Datacenter dc001 | Get-VM # List VMs in a cluster Get-Cluster cluster001 | Get-VM # Get 2 CPU or larger VMs Get-VM | Where-Object {$_.
Posts
Understanding VMware VMkernel Traffic Routing
As a basis for an upcoming post on splitting vmkernel traffic across over layer 3 boundaries I wanted to describe how vmkernel traffic is routed on an ESX host. There seems to be a lot of confusion in this area and hopefully this will help to clear it up.
If you need a refresher on IP addresses, network masks, or subnets check out this Cisco article.
Directly Connected Networks
If a host is directly connected to a subnet it will use that interface to talk to devices in that subnet.
Posts
Export and Import Customization Specs Using PowerCLI
Here are a couple of functions to help you export and import OS customization specs in vCenter. Be aware that if you do this between vCenters or the certificate changes then you will have to set any encrypted passwords to their correct value after the import.
These functions and the standard *-OSCustomizationSpec cmdlets should allow you to replicate your customization specs between multiple vCenters fairly easily.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 Function Export-OSCustomizationSpec { param ( [string]$specName, [string]$exportFile = "$specname.
Posts
Notify All Active vSphere Users (PowerCLI version)
Steve Jin recently posted How to Notify All the Active vSphere Users on his DoubleCloud blog. Below are some functions to make this easy to do via PowerCLI.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Function Get-VIServiceMessage { $sessionManager = Get-View SessionManager $sessionManager.Message } Function Set-VIServiceMessage { param ( [String]$message = $(throw "Must specify a message.") ) $sessionManager = Get-View SessionManager $sessionManager.
Posts
Summarize PowerCLI Cmdlets by Noun
Here is some simple code to generate a reference list of the PowerCLI cmdlet objects(nouns) and what actions(verbs) you can perform on them.
This can come in handy for people new to PowerCLI to show them what the cmdlets will handle for them.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 $commandTable = @{} $commandList = Get-Command -Module VMware.VimAutomation.Core -CommandType Cmdlet foreach ($command in $commandList) { if (!
Posts
Bulk password change on ESX hosts
Here is an script to make life a little easier when doing bulk updates to a password for an account as long as the account has a common password on the different hosts.
The script has some documentation in it so make sure to use Get-Help to find more detail.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Get-Help .
Posts
Unable to install ESX400-201002401 or ESX400-200912401
Update Manager 4.0 Update 1 was refusing to install either of these two patches. At first I was confused because I did not have Nexus deployed, but this was looking similar to the problem that Update 1 was supposed to fix.
I downloaded the bundle from VMware’s web site and tried to install the patch manually and got this error:
The following problems were encountered trying to resolve dependencies: cross_emulex-cim-provider_400.2.0.27.1-164009 provides 'emulex-cim-provider >= 400.
Posts
List VMs with Non Thick Disks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 foreach ($vm in Get-VM) { $badFormat = $false foreach ($hardDisk in (Get-HardDisk -VM $vm)) { if ($hardDisk.StorageFormat -ne "Thick") { $badFormat = $true } } if ($badFormat) { $vm.Name } }
Posts
Determine VMs in a SRM recovery plan using PowerShell
Here is some PowerShell code to determine the VMs that are in a VMware Site Recovery Manager recovery plan.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 #requires -version 2 # Description: List the VMs in a SRM recovery plan.
Posts
Set-VMHostService Policy Parameter
Here are the possible values for the policy parameter on Set-VMHostService and their corresponding value in the VI client.
<th> VI Client Value</ht></tr> <tr> <td> automatic </td> <td> Start automatically if any ports are open… </td> <tr> <td> on </td> <td> Start and stop with host </td> <tr> <td> off </td> <td> Start and stop manually </td></table>
Posts
Require a minimum version of PowerCLI
A lot of the script that I have been writing rely on new cmdlets or properties in the current release of PowerCLI. Telling people to upgrade before running the scripts has not been enough so I am going to do the smart thing and check that the appropriate version is running.
Here is the code to that I am using to do the validation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 # By default this will check that the running version of PowerCLI is greater # than or equal to the specified version and throw an exception if not.
Posts
VMware vCLI “persistent login”
Here is a short convenience script that will simulate a persistent login to a VMware host system when using the vCLI on Windows. Typically you have to specify a lot of parameters that include login information or a session file. With this method you just run the script and provide the hostname, username, and password for the connection.
After running this script you can run commands like “vicfg-mpath.pl –list” without additional parameters.
Posts
VMware PowerCLI and Get-View filters
I have been confused by how to best use the -filter parameter on Get-View so I decided to dig around a little. The examples that are given always seem to be (semi)exact matches and I wanted to do an OR in my filter. Per the help this did not appear possible, but after some digging I found that it is possible for a single property at least.
The help has this to say about the Filter parameter:
Posts
PowerShell and SRM – Basic Logic
Here is a script that shows how to get access to the environment variables that VMware sets for a command step and perform some basic control flow using them.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 # A starter script for examining the VMware environment variables and # performing some logic steps relating to the SRM workflow.
Posts
Using PowerShell in VMware Site Recovery Manager
This is the first post in a series about using PowerShell to automate steps in a VMware Site Recovery Manager (SRM) workflow. I will be posting bits and pieces as I learn more and if everything works the way I would like I will post an overview of my testing and recovery procedure.
To use PowerShell in a Command Step of a recovery plan you will need to do the following:
Posts
VMware SRM – finding VMs in a recovery plan
I am evaluating VMware Site Recovery Manager (SRM) and there are some things that I need to do in testing that I can not do in the base product. I am going to run some PowerShell to reconfigure the VMs and rename them. One of the first roadblocks is finding out which VMs are part of a particular recovery plan. Since the SRM API is limited I went into the database and dug around.
Posts
Maximum vSwitches in vSphere
There appears to be a discrepancy in the VMware documentation regarding the maximum number of vSwitches. The Configuration Maximums document states that the limit is 248. The configuration guide lists the maximum as 127 which is what it was in 3.5. I am not sure if I misunderstand what they mean by “Standard switches per host 248”. If you see the error of my ways let me know.
Here is some code that I used to see how many vSwitches I could put on a host.
Posts
Configure NTP on Multiple Hosts Using PowerShell
A handy script to correct NTP settings on multiple hosts.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 #Usage: Get-VMHost | .\ConfigureNtpServer.ps1 BEGIN { $ntpServers = @("ntpserver01","ntpserver02") $hostDateTimeConfig = New-Object Vmware.Vim.HostDateTimeConfig $hostNtpConfig = New-Object VMware.Vim.HostNtpConfig $hostDateTimeConfig.ntpConfig = $hostNtpConfig $hostDateTimeConfig.ntpConfig.server = $ntpServers } PROCESS { $vmHost = $_ $vmHostView = Get-View $vmHost.ID $dateTimeSystem = $vmHostView.ConfigManager.DateTimeSystem $DateTimeSystemRef = Get-View $dateTimeSystem $DateTimeSystemRef.
Posts
Get-VmDiskPersistenceReport
As part of our auditing process I need validate guest disk persistence settings. Here is a simple snippet to get the needed data.
1 2 3 4 Get-VM | ForEach-Object { $vmname = $_.Name $_.HardDisks | Select-Object @{Name="VM"; Expression={$vmname}}, Filename, Persistence }
Posts
Report on HA Isolation Response
1 2 3 4 5 6 7 8 9 10 $desiredResponse = "DoNothing" foreach ($cluster in Get-Cluster) { $result = $cluster | Select-Object Name, HAIsolationResponse, @{Name="DesiredResponse"; Expression={$desiredResponse}} if (!$cluster.HAEnabled) { $result.HAIsolationResponse = "HaNotConfigured" } $result }
Posts
LoadVMs-FromFile
I was using the VMware VI Toolkit for Windows for a change and I needed to load VMs from a CSV and my typical stream oriented way of doing this was very inefficient over the WAN (or LAN really). There are many ways of making Get-VM operations faster, but for this change I decided to use the standard Get-VM cmdlet with an array of computer names instead of doing them one by one.
Posts
VMFS creation error: Unable to read partition information from this disk.
When trying to add a VMFS volume in the VIC I received the message “Unable to read partition information from this disk.” I did not have an option to overwrite any data and could not continue. The SAN administrator said that the disk was presented the exact same way that another working LUN was.
At the console I figured out which device it was (esxcfg-vmhbadevs) and tested to see if I could read the partition table.
Posts
Alternative solution to deployment issues when change Service Console IP
Host IP in vpxa.cfg retains old value after changing service console IP.
The VMware solution is:
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1006768
The problem is that I did not want to lose my host’s historical information. An alternative to removing and re-adding the host is to stop the Virtual Center service and update the VPX_HOST table in the Virtual Center database to contain the correct IP for the server(s). When you start the service back up it will update the hosts configuration (vpxa.
Posts
VMware Converter p2v fails at 2%
My p2v was sticking at 2% and eventually failing. Nothing was apparently wrong and a p2v worked yesterday to the same cluster.
Looking at the logs I ran across a message that led me to this forum post. This was our problem too. We had two NICs in a team – one was ok, but the other one had a duplex mismatch. A quick change of active NICs and the p2v worked just fine.
Posts
Using clusterssh to admin multiple service consoles
We have our service consoles set up to disallow root logins and use sudo (with password) for access. Every once in a while this causes us some pain. How do you update file /etc/filex or run some command across a cluster or a bunch hosts when root privileges are needed?
There are multiple ways to approach this type of issue, but one I have not seen much of in the VMware blogosphere is clusterssh.
Posts
VI SDK – Beware cached data and assumptions
Applications often cache data and that is good because that generally makes them perform better for users. However, if you make assumptions that what you see is the absolute truth you can run into trouble.
1 2 3 4 5 6 7 8 9 Connect-ViServer myVirtualCenter001 # Let's check the status of the server to make sure I can go home. (Get-vmhost myVmHost001.local | Get-View).OverallStatus green #Looks good. Well, maybe not.
Posts
Validating VM advanced settings
Now that we have covered how to make advanced settings changes we need to validate that the settings have been applied. Assuming that a script or command worked is never as good as checking it. Below is a script to do just that.
The script lists all statuses so if you only want to see issues you can pipe the output into the Where-Object cmdlet like so:
<vmObject(s)> | .\Validate-VmAdvancedSettings.ps1 | Where-Object {$_.
Posts
Making advanced settings changes to a running VM
If you use a method like that in the Powershell script I posted the changes can be made to a running VM. This is great because that dialog box is disabled in Virtual Center when the vm is up.
The settings do not take effect until the VM is power cycled (not just restarted in the OS). This is not that big of a deal on clusters with VMotion licensed because a VMotion starts a new instance of the VM on the destination host.
Posts
Get-AllRolePrivileges
This is a good script to easily report on privileges and can easily be extended to audit against a known good list of expected roles/privileges.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 # Must already be connected to a viserver. This works on the default vi server. $si = Get-View ServiceInstance $am = Get-View ($si.Content.AuthorizationManager) $roles = $am.RoleList foreach ($role in $roles) { foreach ($privilege in $role.
Posts
Script to update tools in templates.
Here is a script that takes template objects and updates their VMware tools.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 # Usage: <template object(s)> | .\Upgrade-ToolsTemplate.ps1 # Example: Get-Template template1 | .\Upgrade-ToolsTemplate.ps1 # Get-Datacenter corporate | Get-Template | .
Posts
Get-VIAllPrivileges
This is a good script to easily report on privileges and can easily be extended to audit against a known good list of expected roles/priveleges.
1 2 3 4 5 6 7 8 9 10 11 12 #Must already be connected to a viserver. This works on the default vi server. $si = Get-View ServiceInstance $am = Get-View ($si.Content.AuthorizationManager) foreach ($role in $am.RoleList) { foreach ($privilege in $role.Privilege) { $role| Select-Object RoleId, System, Name, @{Name="Privilege"; Expression={$privilege}} } }
Posts
Forwarding VMware logs to a syslog server using PowerShell
I am working on a PowerShell script to replace the functionality of the logging daemon in VIMA and am making some progress. Check out the scripts/programs page for updates. I have posted the code out there for sending syslog messages from PowerShell. There are some third party tools for this but I wanted the learning experience and I am cheap.
Posts
PowerShell: Get VMs running on a single host
I wanted to perform an action on all of the VMs on a particular host, but using my connection to Virtual Center instead of reconnecting directly to the host. I found something interesting.
This is wrong:
Get-VMhost esx1.local | Get-VM #Not what I expected. This does not work as I expected. It gets all of the VMs in the cluster instead of just the ones registered with the host. My best guess is that this is because the host is not really a container object when in a cluster.
Posts
Package error with HP RDP and ESX 3.5 Update 1
The scripted install fails and the installer reports that it can not find some package files. The files were extracted from an ISO that was verified using md5sum.
When I extracted the files from the ISO image using MagicISO or DaemonTools on Windows a few of the files have invalid names. It looks just fine when I mount the ISO in my Ubuntu Linux VM though. I burnt the ISO to a disk and the same files have incorrect names.
Posts
VC Upgrade to 2.5 and XP template issues
We upgraded to Virtual Center 2.5 and our XP deployments failed to join the domain. When I logged onto the VM I received a popup about an unsigned driver issue for the network card. Turns out a patch to the network driver in ESX 3.0.1 updated the driver to version 2.0.0.9 and there was a version of it in C:\WINDOWS\system32\ReinstallBackups. ESX 3.0.2 has a version of 2.0.0.8 so it looks like the problem was resolved within ESX itself.
Posts
Basic install of bcfg2 on ESX 3.5
I am working on the configuration management problem and have been toying with getting bcfg2 working on ESX 3.5. My goal is to have an isolated install that does not require modifying the existing system files or upgrading any packages. My approach to doing this is to create a local Python 2.5 install and install the bcfg2 packages there.
This is just a start, but I thought I would put it out there for anyone who wants to work on something similar.
Posts
ESX Server Configuration Management
I am not very happy with the landscape of configuration management software out there for VMware ESX server. I am investigating using projects such as Bcfg2 to administer my servers. I am working with Bcfg2 because I do not have a lot of experience with these types of software and I am interested in learning more about Python.
Of course these types of packages fail when you look at ESX 3i, but I am not convinced that I will be an early adopter of that platform.
Posts
VMware Tools Update Job
I needed a way to allow our admins responsible for patching to include VMware Tools updates during a patch cycle. You can easily update via Virtual Center, but this requires multiple interfaces and it can be difficult to pick all of the same servers without making a mistake. I fired up Process Explorer and watched what VMware did with their existing tools update process. This is pretty cool since it does not require a network connection and your Tools install is up to date without needing to maintain a repository.