Category: cloudforms
Posts
Men and Mice API Client Gem for Ruby
Part of what I am doing these days is integrating Red Hat CloudForms / ManageIQ with the Men and Mice IP address management (IPAM) application. In order to reduce gem dependencies, reduce duplication, and handle some architecture issues I have been working on a client gem that uses the JSON-RPC API provided by Men and Mice.
If you are using Ruby and want to integrate with M&M please check out the gem and provide any feedback you have through Github issues.
Posts
Helper utility for ManageIQ/CloudForms Automate
As I do Automate development on RedHat CloudForms I am seeing a lot of copy/paste code which is the opposite of DRY. Our process was to put commonly used code in a starting template for an Automate method. This is nice because someone new to development gains the experience of a nice starting point, but it results in a lot of extra code. We also lose the benefit of bug fixes to the helper methods.
Posts
Getting ManageIQ instance attributes without executing methods/states
I want to use the values from the ProvisionRequestQuotaVerification instance. The problem is that using $evm.instantiate will cause the code to run. This results in an exception or error.
Digging around I found
1 $evm.instance_get(path) Which works as long as you know the full path including the domain, but then you can not rely on domain inheritance.
1 my_instance = $evm.instance_get("/ManageIQ/Infrastructure/VM/Provisioning/StateMachines/ProvisionRequestQuotaVerification/default") Here is my current workaround:
Posts
Red Hat CloudForms/ManageIQ – Examples
For me, one of the easier ways to begin to learn something is to learn by example. Even if the example does not solve my exact problem, I can use it to figure out ways of extracting the information I need and patterns for implementing new functionality. As a response to a forum question regarding provisioning approvals, Kevin Morey pointed out a Github repository that I was unaware of (https://github.com/ramrexx/CloudFormsPOC). This repo is a great source of example code to get you started exploring more advanced usage of CloudForms.
Category: conference
Posts
PyOhio 2010 is coming up 7/31-8/1
I enjoyed this event quite a bit last year and I am looking forward to attending this time around.
Homepage
Registration
Category: development
Posts
Men and Mice API Client Gem for Ruby
Part of what I am doing these days is integrating Red Hat CloudForms / ManageIQ with the Men and Mice IP address management (IPAM) application. In order to reduce gem dependencies, reduce duplication, and handle some architecture issues I have been working on a client gem that uses the JSON-RPC API provided by Men and Mice.
If you are using Ruby and want to integrate with M&M please check out the gem and provide any feedback you have through Github issues.
Posts
Helper utility for ManageIQ/CloudForms Automate
As I do Automate development on RedHat CloudForms I am seeing a lot of copy/paste code which is the opposite of DRY. Our process was to put commonly used code in a starting template for an Automate method. This is nice because someone new to development gains the experience of a nice starting point, but it results in a lot of extra code. We also lose the benefit of bug fixes to the helper methods.
Posts
Getting ManageIQ instance attributes without executing methods/states
I want to use the values from the ProvisionRequestQuotaVerification instance. The problem is that using $evm.instantiate will cause the code to run. This results in an exception or error.
Digging around I found
1 $evm.instance_get(path) Which works as long as you know the full path including the domain, but then you can not rely on domain inheritance.
1 my_instance = $evm.instance_get("/ManageIQ/Infrastructure/VM/Provisioning/StateMachines/ProvisionRequestQuotaVerification/default") Here is my current workaround:
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
OpenZIS installation guide
I have spent a day or so trying to get the OpenZIS project up and running on a CentOS machine. A lack of updated instructions and an older code base made this process harder than I expected.
While I am still investigating if OpenZIS will meet my needs, I wanted to publish what I did as a reference to others who might try to install it. The doc is in my forked version of OpenZIS.
Posts
Google Book Advanced Search Query Parameters
A reference for those working on Google book searches other than full text queries. Let me know if something is incorrect or missing.
<th> Values </th> <td> All of the words. </td> <td> Exact phrase. </td> <td> At least one of the words. </td> <td> Without the words. </td> <td> 0=AllBooks, 1=FullView, 3=Limited preview and full view, 4=Public domain only </td> <td> One of "ALLTYPES", "BOOKS", "MAGAZINES" </td> <td> Empty for all languages otherwise a language code.
Category: ebook
Posts
Sony PRS600 hung (1fskin:/l/string…)
My new PRS600 reader from Sony was hung and I was getting pretty worried. I was using calibre on Linux and unplugged the device without unmounting. I would reset it and it would boot, but come to a blank version of the menu screen with 1fskin:/l/string… showing at the bottom. I tried a hard reset, but the device would not respond.
Here are the steps I did to resolve the issue.
Category: google
Posts
Google Book Advanced Search Query Parameters
A reference for those working on Google book searches other than full text queries. Let me know if something is incorrect or missing.
<th> Values </th> <td> All of the words. </td> <td> Exact phrase. </td> <td> At least one of the words. </td> <td> Without the words. </td> <td> 0=AllBooks, 1=FullView, 3=Limited preview and full view, 4=Public domain only </td> <td> One of "ALLTYPES", "BOOKS", "MAGAZINES" </td> <td> Empty for all languages otherwise a language code.
Category: microsoft
Posts
Basic PowerShell Registry Value Helpers
Working with registry values in PowerShell can be a little cumbersome, so here are some example helpers that I am using to simplify some of my configuration scripts.
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 Function Get-RegistryValue { param ( $key, $value ) (Get-ItemProperty -Path $key -Name $value).
Posts
Free virtualization book from Microsoft
Understanding Microsoft Virtualization Solutions (Second Edition)
http://blogs.msdn.com/b/microsoft_press/archive/2010/02/16/free-ebook-understanding-microsoft-virtualization-r2-solutions.aspx
Category: orchestrator
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.
Category: people
Posts
IT Infrastructure Performance – Research
I have been working on methods to benchmark the Windows infrastructure team at work and I have not been finding much luck finding existing metrics. I was not too happy with the last Gartner review of our IT department, but perhaps that is all that is out there. I have developed some thoughts on the matter and once I am fairly certain they make sense I will post them here.
Posts
Leadership and self deception
I just read Leadership and self-deception : getting out of the boxand I am sure I will have to read it a few more times to have it sink in, but I like what I got out of it so far. I like that it goes beyond “don’t be selfish” to talk about the ways that a mindset can color our perceptions of other people. It hit pretty close to home for me and I am glad to have found it.
Posts
Forums – good or evil?
It amazes me the amount of incorrect information that is put on user forums. There are always mistakes and I have seen some posts where people realize and correct their errors. Primarily though, I see people ranting about “the correct way” when that way is not based in product knowledge, but rather on “it seemed to work”.
This reminds me of the time I went to the pet store to buy some activated charcoal after my dog ate some wild mushrooms.
Category: powercli
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
PowerShell Asynchronous Job Queueing
Here is some sample code to have a variable size work queue for asynchronous jobs in PowerShell. The sample code uses Start-Job, but it was written as a skeleton to be able to run multiple PowerCLI tasks at once.
The variable length is beneficial in case the work should be split up, but there is a chance of overwhelming the system if too many concurrent jobs are started at once.
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
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
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
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.
Category: powershell
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
PowerShell: Alternate script behavior when dot sourced vs run directly
I use dot sourcing in my PowerShell scripts to reuse functions* and sometimes I want different behavior if they are included (dot sourced) or run directly. This concept is used in Python to provide an easy way to run tests against the code when run directly but not when it is imported.
You are not restricted to running tests using this approach, but I think that automated testing is useful so that is the example I provide below.
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
Simple XML output of a data object
I am doing some data collection using PowerShell and the output needs to be a simple XML document string.
The built in cmdlets do a great job when persisting data, but they produce some fairly complicated XML that provides more detail on object types than I can use.
Here is a single function to take a PSObject based data object and turn it into XML. I have also included a test function to show an example of building the data object.
Posts
PowerShell Asynchronous Job Queueing
Here is some sample code to have a variable size work queue for asynchronous jobs in PowerShell. The sample code uses Start-Job, but it was written as a skeleton to be able to run multiple PowerCLI tasks at once.
The variable length is beneficial in case the work should be split up, but there is a chance of overwhelming the system if too many concurrent jobs are started at once.
Posts
Basic PowerShell Registry Value Helpers
Working with registry values in PowerShell can be a little cumbersome, so here are some example helpers that I am using to simplify some of my configuration scripts.
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 Function Get-RegistryValue { param ( $key, $value ) (Get-ItemProperty -Path $key -Name $value).
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
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
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
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
PowerShell advanced parameter behavior unexpected
I have been experimenting with parameter values from the pipeline and the processing behavior is slightly different when using piplines vs. parameterized values. It is easy enough to work around, but I wanted to make sure and explain the issue and one workaround.
The standard way of using a pipeline parameter is to do something like this:
param ( [parameter(Mandatory=$true, ValueFromPipeLine=$true)] [String[]]$item ) In cases where you accept input from the pipeline or a single item as an input parameter this works fine.
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.
Category: python
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
PyOhio 2010 is coming up 7/31-8/1
I enjoyed this event quite a bit last year and I am looking forward to attending this time around.
Homepage
Registration
Category: red-hat
Posts
Men and Mice API Client Gem for Ruby
Part of what I am doing these days is integrating Red Hat CloudForms / ManageIQ with the Men and Mice IP address management (IPAM) application. In order to reduce gem dependencies, reduce duplication, and handle some architecture issues I have been working on a client gem that uses the JSON-RPC API provided by Men and Mice.
If you are using Ruby and want to integrate with M&M please check out the gem and provide any feedback you have through Github issues.
Posts
Helper utility for ManageIQ/CloudForms Automate
As I do Automate development on RedHat CloudForms I am seeing a lot of copy/paste code which is the opposite of DRY. Our process was to put commonly used code in a starting template for an Automate method. This is nice because someone new to development gains the experience of a nice starting point, but it results in a lot of extra code. We also lose the benefit of bug fixes to the helper methods.
Posts
Getting ManageIQ instance attributes without executing methods/states
I want to use the values from the ProvisionRequestQuotaVerification instance. The problem is that using $evm.instantiate will cause the code to run. This results in an exception or error.
Digging around I found
1 $evm.instance_get(path) Which works as long as you know the full path including the domain, but then you can not rely on domain inheritance.
1 my_instance = $evm.instance_get("/ManageIQ/Infrastructure/VM/Provisioning/StateMachines/ProvisionRequestQuotaVerification/default") Here is my current workaround:
Posts
Red Hat CloudForms/ManageIQ – Examples
For me, one of the easier ways to begin to learn something is to learn by example. Even if the example does not solve my exact problem, I can use it to figure out ways of extracting the information I need and patterns for implementing new functionality. As a response to a forum question regarding provisioning approvals, Kevin Morey pointed out a Github repository that I was unaware of (https://github.com/ramrexx/CloudFormsPOC). This repo is a great source of example code to get you started exploring more advanced usage of CloudForms.
Category: scripting
Posts
Men and Mice API Client Gem for Ruby
Part of what I am doing these days is integrating Red Hat CloudForms / ManageIQ with the Men and Mice IP address management (IPAM) application. In order to reduce gem dependencies, reduce duplication, and handle some architecture issues I have been working on a client gem that uses the JSON-RPC API provided by Men and Mice.
If you are using Ruby and want to integrate with M&M please check out the gem and provide any feedback you have through Github issues.
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
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
PowerShell: Alternate script behavior when dot sourced vs run directly
I use dot sourcing in my PowerShell scripts to reuse functions* and sometimes I want different behavior if they are included (dot sourced) or run directly. This concept is used in Python to provide an easy way to run tests against the code when run directly but not when it is imported.
You are not restricted to running tests using this approach, but I think that automated testing is useful so that is the example I provide below.
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
Simple XML output of a data object
I am doing some data collection using PowerShell and the output needs to be a simple XML document string.
The built in cmdlets do a great job when persisting data, but they produce some fairly complicated XML that provides more detail on object types than I can use.
Here is a single function to take a PSObject based data object and turn it into XML. I have also included a test function to show an example of building the data object.
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
PowerShell Asynchronous Job Queueing
Here is some sample code to have a variable size work queue for asynchronous jobs in PowerShell. The sample code uses Start-Job, but it was written as a skeleton to be able to run multiple PowerCLI tasks at once.
The variable length is beneficial in case the work should be split up, but there is a chance of overwhelming the system if too many concurrent jobs are started at once.
Posts
Basic PowerShell Registry Value Helpers
Working with registry values in PowerShell can be a little cumbersome, so here are some example helpers that I am using to simplify some of my configuration scripts.
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 Function Get-RegistryValue { param ( $key, $value ) (Get-ItemProperty -Path $key -Name $value).
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
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
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
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
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
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
PowerShell advanced parameter behavior unexpected
I have been experimenting with parameter values from the pipeline and the processing behavior is slightly different when using piplines vs. parameterized values. It is easy enough to work around, but I wanted to make sure and explain the issue and one workaround.
The standard way of using a pipeline parameter is to do something like this:
param ( [parameter(Mandatory=$true, ValueFromPipeLine=$true)] [String[]]$item ) In cases where you accept input from the pipeline or a single item as an input parameter this works fine.
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
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
Gzip creation in PowerShell – Gzip-FileSimple.ps1
I have a need to compress some of the data I am exporting using PowerShell so I figured why not use PowerShell to do it? I did not want to have a dependency on the Community Extensions even though they have solved this problem already. Luckily in newer versions of .Net there is the System.IO.Compression class.
Here is my code which is based off of the Microsoft example for the class.
Posts
PyOhio 2009
I just finished attending my first PyOhio and I have to say that I enjoyed it. It was interesting to see so many people involved enough in their interests to spend a weekend talking about code. There were sessions geared to all levels of Python knowledge and a wealth of knowledge to be shared.
I am a Python novice so my ability to hang in on the deeper side discussions was limited, but I came away with much more information and a bunch of areas to dig into deeper.
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
Free PowerShell eBook
As reported on the PowerShell Team blog.
Free PowerShell V1 Book From the Makers of PowerShell Plushttp://blogs.msdn.com/powershell/archive/2009/07/17/free-powershell-v1-book-from-the-makers-of-powershell-plus.aspx
Posts
Get-PreviousWeekdayDate
I am fleshing out my automated monitoring/reporting system and I wanted to include some performance data exports. As part of this I always wanted my weekly exports to start on a certain day of the week no matter when the script was run. I also needed to make sure that I received a weeks worth of data.
To help out I wrote this function:
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 # Find the date of a previous weekday.
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
Secure Credential Storage
I have added some code to my Scripts/Programs page for securely storing credentials to disk to be used by scripts at a later time.
I explored the VI Credential cmdlets and I was not 100% happy with them so I decided to implement my own version that uses the Microsoft DPAPI for encryption. Make sure to look at the README as it covers usage and current limitations.
I wrote these for use in some automated VMware monitoring I am doing, but there is no reason they have to be used with the VI Toolkit.
Posts
Issue with Read-Host PowerShell 2 CTP3
When using Read-Host with the AsSecureString paramater in PS2 CTP3 the prompt text does not appear. Here is a wrapper function that simulates the basic behavior. This does not implement all of the other parameters of Read-Host as I only needed it for the base case.
1 2 3 4 5 6 7 8 9 # PowerShell v1 Read-Host "blah" -AsSecureString blah: **** System.Security.SecureString # Powershell v2 CTP3 Read-Host "blah" -AsSecureString **** System.
Posts
My Favorite Scripting Editors
Notepad++
I use Notepad++ for quick editing jobs because it is a very capable editor and it has a quick load time. Works on a thumb drive.
Komodo Edit (Komodo IDE)
I use Komodo Edit a lot when I am working with Python, Perl, VBScript, JScript, or XML files. It works on my Linux system as well which is a great bonus. I like this editor because it more of a development environment and gives me a lot of flexibility in configuration and custom tools.
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
VI Toolkit Install Script – PowerShell
Here is a script I wrote to install the VI Toolkit Extensions on my systems. The VITKE team decided to go with a cmd file in case PowerShell was not installed and I think that makes perfect sense. I am posting this code just in case it will be useful to someone else.
InstallVitkEextensions.ps1
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: Custom Objects with Method Parameters
I was not sure how to add parameters to custom object methods, but it is pretty simple. Here is a simple example.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Function CustomObjectWithMethodParameter { $CustomObject = New-Object PSObject $CustomObject | Add-Member -MemberType ScriptMethod -Name testParam -Value { param ( [String]$parameter01 = $(throw "parameter01 must be specified.") ) Write-Host "Parameter01 value: $parameter01" } $CustomObject } $myobj = CustomObjectWithMethodParameter $myobj.
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
PowerShell ISE Custom Menu
Here is some code that I am working on for customizing the PowerShell ISE to do some things that I would like it to do.
`Update 1/22/2009: After switching to a full WordPress install I don’t have a problem uploading code files any more. Keep any eye on this pagefor any updates to the custom ISE menu. Feedback is welcomed.
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 # # Add Run with arguments capability # $psise.
Category: security
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
Powered Ethernet and CDP
I was looking into Cisco Discovery Protocol details and read that you can negotiate POE using CDP packets. Could a malicious trojan forge some CDP packets and energize the POE link to the PCs nic?
Category: system-administration
Posts
Red Hat CloudForms/ManageIQ – Examples
For me, one of the easier ways to begin to learn something is to learn by example. Even if the example does not solve my exact problem, I can use it to figure out ways of extracting the information I need and patterns for implementing new functionality. As a response to a forum question regarding provisioning approvals, Kevin Morey pointed out a Github repository that I was unaware of (https://github.com/ramrexx/CloudFormsPOC). This repo is a great source of example code to get you started exploring more advanced usage of CloudForms.
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
OpenZIS installation guide
I have spent a day or so trying to get the OpenZIS project up and running on a CentOS machine. A lack of updated instructions and an older code base made this process harder than I expected.
While I am still investigating if OpenZIS will meet my needs, I wanted to publish what I did as a reference to others who might try to install it. The doc is in my forked version of OpenZIS.
Posts
Problems with intuitive availability calculations
I often see/hear comments from people whose common sense approach to availability design includes eliminating a single point of failure. This is a great goal when required, but care must be take that the “common sense” approach is actually achieving what is required. I have found that using a fault tree approach to evaluating design decisions can be insightful.
The last instance of this is a book, while otherwise great, gave the advice of separating a database from the application function onto separate servers because there was a single point of failure.
Posts
Helpful Commands for vCenter Linked Mode Troubleshooting
Launch the command prompt via: Start | Programs | ADAM | ADAM Tools Command Prompt
dsdiag.exe /s:localhost:389 repadmin.exe /viewlist * /homeserver:localhost:389 repadmin.exe /replsummary * /homeserver:localhost:389 repadmin.exe * /repsto /homeserver:localhost:389 repadmin.exe /showconn * /homeserver:localhost:389
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
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 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
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
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
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 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
Ohio LinuxFest 2009
If you are anywhere around Ohio and interested in Linux you may want to check out Ohio LinuxFest 2009. It is being held September 25th & 26th in Columbus Ohio.
This will be my first year attending, but I have heard good things about the conference and am looking forward to talking with some other Open Source enthusiasts in the area.
Posts
Secure Credential Storage
I have added some code to my Scripts/Programs page for securely storing credentials to disk to be used by scripts at a later time.
I explored the VI Credential cmdlets and I was not 100% happy with them so I decided to implement my own version that uses the Microsoft DPAPI for encryption. Make sure to look at the README as it covers usage and current limitations.
I wrote these for use in some automated VMware monitoring I am doing, but there is no reason they have to be used with the VI Toolkit.
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
Validating Ubuntu Installed Files
I had an issue where I ran a vendor provided install script and my kernel sound drivers were deleted. I recovered them just fine, but it had me wondering about how I could be sure that no other files were missing or corrupted.
After some searching online I found a reference to someone checking a package using dpkg’s md5sums. This and some poking around gave me what I needed.
cd / sudo /usr/bin/md5sum -c /var/lib/dpkg/info/*.
Posts
System Administration Podcast
This looks like it might be an interesting development – a system admin podcast. The first one covers some substantial topics and I look forward to more.
http://cuddletech.com/blog/pivot/entry.php?id=964
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
IT Infrastructure Performance – Research
I have been working on methods to benchmark the Windows infrastructure team at work and I have not been finding much luck finding existing metrics. I was not too happy with the last Gartner review of our IT department, but perhaps that is all that is out there. I have developed some thoughts on the matter and once I am fairly certain they make sense I will post them here.
Posts
Infrastructure Value != Utilization
A common problem in infrastructure groups is determining the value that we provide to the organization. One common way of thinking about this is in terms of asset utilization. Messages such as “take your servers from 5% utilization to 60%” are very common in virtualization value propositions, but I do not think that capacity utilization is the correct measurement of infrastructure value. That value is derived from being able to run an application at adequate performance levels.
Posts
Forums – good or evil?
It amazes me the amount of incorrect information that is put on user forums. There are always mistakes and I have seen some posts where people realize and correct their errors. Primarily though, I see people ranting about “the correct way” when that way is not based in product knowledge, but rather on “it seemed to work”.
This reminds me of the time I went to the pet store to buy some activated charcoal after my dog ate some wild mushrooms.
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.
Posts
Formalized System Administration Education
It is interesting to read about more formal approaches to system administrator education. I have been reading “Master Education Programmes in Network and System Administration” from the LISA 07 proceedings. The authors’ approach is an interesting one, but I wonder what we do for all of the administrators already “in the wild”? A training vs. education mentality and the difficulty of adult education make introduction of a program like this very difficult.
Category: uncategorized
Posts
VMware vSphere and Enterprise Plus
So here are the new editions.
Hmm. My current Enterprise licenses will not give me the all of the feature of the new version. There are a lot of angry blog posts out there on this new policy. I do not know if I would consider myself angry, but I am disappointed and more than a little confused.
I understand that as new products come out (* Manager) I will be expected to pay extra for them.
Posts
Using ScriptProperty members in PowerShell
I was looking for information on ScriptProperty members in PowerShell and was running into trouble finding anything useful. The PowerShell in Action book saved me on page 229.
Here is the object I am using in a piece of code that I am finishing for persisting server credentials to disk in a secure fashion. It shows a real world example of when a ScriptProperty is needed instead of the simpler NoteProperty.
Posts
Version Control for (VMware) System Administrators
It has been long held that *nix administrators should use version control, but this knowledge has not really made it over to the Windows world where a lot of VMware administrators come from.
I consider version control for scripts and configuration files to be an essential part of any well run site. It is something that can be set up in a few hours (Window or *nix) and most admins will need to learn only the basics of the tools.
Posts
VMware Update Manager Profile Updates
I added these to my Powershell profile to make working with the VMware Update Manager Toolkit a little easier from my standard shell.
Add-PSSnapin VMware.VumAutomation function Get-VumCommand {Get-Command -pssnapin VMware.VumAutomation}
Posts
Script for VM advanced settings
I created this one so I could easily apply multiple advanced settings to a list of VMs. The $advancedSettings array is easily modified to change what get configured.
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 # Usage: <vmobject> | .\Configure-VmAdvancedSettings.ps1 # Examples: Get-VM myTestVM | .
Posts
A New VMware Scripting Site
A co-worker has created a site that is dedicated to scripting the VMware environment. It is a good place to share scripts, ask questions, and to have discussions about all types of VMware automation.
http://www.vmwarescripting.com
The site is relatively new so share what you can and keep coming back for new content.
Posts
Added VMware Logforwarder to the Scripts/Programs Page
I have updated my Scripts/Programs page to include the bundle of scripts that I created when testing out forwarding options for logs that are not normally accessible via the service console syslog subsystem.
This set of scripts is functional, but ended at POC stage when I decided to go another route. If there are any questions about them let me know, but they should not be used for production systems until more error checking added and testing is done.
Posts
New Scripts/Programs Page
I have added a new page that will be the central index to any scripts or programs that I develop. It is available on the front page menu bar and is creatively labeled Scripts/Programs.
I have started off with an updated version of my PowerShell ISE custom menu.
Posts
Plug for SAGE and USENIX
This is for the admins out there who have not heard of sage or Usenix or those that think that this is only for *nix people (Windows and VM admins).
I think that both of these groups are great and have memberships to both. They focus on issues that are important to IT professionals and provide a forum for a professional system administrator to learn and grow. Some topics have a *nix bias but beneath it all most of the current OSes are based on the same principles.
Posts
Creating content
For the past 10 years I have been doing system administration and have benefited greatly from search engines and forums, but I have not provided much content. I am trying to correct this by creating this blog and participating in online forums.
Time will tell if I can keep it up.
Posts
Introduction
I am new to blogging, but I figured that creating an online persona is a good thing.
Category: virtualization
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
Problems with intuitive availability calculations
I often see/hear comments from people whose common sense approach to availability design includes eliminating a single point of failure. This is a great goal when required, but care must be take that the “common sense” approach is actually achieving what is required. I have found that using a fault tree approach to evaluating design decisions can be insightful.
The last instance of this is a book, while otherwise great, gave the advice of separating a database from the application function onto separate servers because there was a single point of failure.
Posts
Helpful Commands for vCenter Linked Mode Troubleshooting
Launch the command prompt via: Start | Programs | ADAM | ADAM Tools Command Prompt
dsdiag.exe /s:localhost:389 repadmin.exe /viewlist * /homeserver:localhost:389 repadmin.exe /replsummary * /homeserver:localhost:389 repadmin.exe * /repsto /homeserver:localhost:389 repadmin.exe /showconn * /homeserver:localhost:389
Posts
Free virtualization book from Microsoft
Understanding Microsoft Virtualization Solutions (Second Edition)
http://blogs.msdn.com/b/microsoft_press/archive/2010/02/16/free-ebook-understanding-microsoft-virtualization-r2-solutions.aspx
Category: 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.