powercli

Obtaining CDP info via PowerCLI

There are quite a few posts out there already on this topic and in fact the official VMware KB article has a suggestion on how you can get CDP info via PowerCLI. I didn’t really like the way they presented the code though so I made my own function Get-VMHostNetworkAdapterCDP in the typical style with pipeline input and object output A typical use case: Get-VMHost ESXi01 | Get-VMHostNetworkAdapterCDP would see the following output

Using PowerCLI for iSCSI VMKernel Port Binding

I was surprised to discover that there were no native cmdlets for managing iSCSI VMKernel Port Binding in PowerCLI. So I made my own Get-VMHostiSCSIBinding and Set-VMHostiSCSIBinding functions and have shared them here in case anyone else finds them useful. Here’s a couple of examples of how they can be used: Retrieve iSCSI Port Binding details Get-VMHost ESXi01,ESXi02 | Get-VMHostiSCSIBinding -HBA "vmhba32" | Format-Table PortGroup,Vmknic,IPv4,IPv4SubnetMask,MACAddress -AutoSize 2) Set iSCSI Port Binding details

Migrating Email Alarm Actions between vCenter 5.0 and 5.1

I needed to migrate some Email Alarm Actions between two vCenters; the target at version 5.1 being a replacement for an existing 5.0 vCenter. The first task was to identify which Alarm Definitions had been configured with an email alert. To do that I used the following PowerCLI command to export them to a CSV file: Get-AlarmDefinition | Select Name,@{N="EmailAction";E={$\_ | Get-AlarmAction | Where {$\_.ActionType -eq "SendEmail"}}} | Export-Csv AlarmActions.csv -NoTypeInformation I could then easily identify those which needed to be migrated across.

Using PowerCLI to set ESXi Dump Collector Settings

I needed to check the configuration of all hosts in an environment for their ESXi Dump Collector Settings and then ensure they were all set to the correct values. I was using the handy ESXi Dump Collector which ships as part of the vCenter 5.1 package. There are no PowerCLI cmdlets for doing this (yet) so I made my own, Get-VMHostDumpCollector and Set-VMHostDumpCollector. Since you can get and set this item via esxcli I used the Get-ESXCli cmdlet for most of the work.

Using PowerCLI for Advanced Syslog Configuration Tasks

PowerCLI has shiped with cmdlets for managing the Syslog configuration of ESXi hosts for some time, Get-VMHostSysLogServer and Set-VMHostSysLogServer. Unfortunately, neither of these (yet) support the configurations mentioned in the below two posts for multiple Syslog servers or different protocols, such as SSL. http://www.boche.net/blog/index.php/2011/07/23/configure-a-vcenter-5-0-integrated-syslog-server/ http://blogs.vmware.com/vsphere/2012/04/configuring-multiple-syslog-servers-for-esxi-5.html So for the time being I have put together two functions, Get-VMHostSyslogConfig and Set-VMHostSyslogConfig, to supplement what you can currently do with the following additional options:

vCheck - Now Available on GitHub

The unbelievably successful vCheck script from Alan Renouf which can be used to provide a daily report on your vSphere (and other technologies) environment is now available on GitHub. This is a great move since it more easily enables further community input to develop this tool further by allowing you to submit contributions via a central repository. If you’ve not used GitHub before then head over to the home page and create an account.

Issue with PowerCLI: Not authenticated and session timeout

A colleague of mine experienced this issue recently where after making a PowerCLI connection to a vCenter and instantly running a command such as Get-VM, he would be prompted by the error: Get-VM. Not authenticated. Possible cause of this error is that the connection was left unused for a while and session has timed out. Checking he was connected to a vCenter appeared to indicate that he was, i.e. $global:defaultVIServer returned a value.

PowerCLI 101 at North East Bytes, Wed 20th March 2013

While on my working sojourn up North my good friend and fellow PowerShell MVP Jonathan Noble asked me to present a PowerCLI 101 session for the North East Bytes User Group he helps to run. So on Wednesday 20th March you can join us for this event at Newcastle University, session abstract and sign up details are below: NEBytes March 2013 - Power The World With Imagination PowerCLI 101 IT Pros are starting to come to grips with the idea of managing Microsoft products with PowerShell, but it’s not just Microsoft who are making use of the powerful automation capabilities on offer.

Working with Custom Attributes in PowerCLI

I recently had a need to create some custom attributes for Clusters and VMs in vCenter. Having previously done this a few times a while back in vCenter I fired up Set-CustomField in PowerCLI 5.1, but was greeted with the following message: $VM | Set-CustomField -Name "TestAttribute" -Value "True" WARNING: Use Set-CustomAttribute cmdlet. WARNING: The 'Set-CustomField' cmdlet is deprecated. Use the 'Set-CustomAttribute' cmdlet instead. So it would work fine now, but going forward some of my code would be deprecated and potentially not work when PowerCLI was upgraded, so I looked for what the options now were, but before we do a quick review of what Set-CustomField gave you.

Automation Station at the UKVMUG 2012

How do you provision, manage and decommission your (sprawling) infrastructure? Running around fighting fires while interesting project work falls by the wayside? Spending long evenings and weekends carrying out maintenance tasks while others are tweeting pictures of what fun they’re having in their spare time? Hiding from the bosses while they hunt you down to deploy a private cloud before Friday afternoon? Or even just figuring out what the heck infrastructure you have got and what underlying issues can you report on….