Rename a Standard Port Group on all hosts in a cluster

Well, I recently decided to rename a bunch of my Standard Port Groups, since they did no longer reflect the network they were providing. Since I’m a lazy bastard (well lazy as in click lazy), I wrote this little PowerCLI script: 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 param( [string] $vcenter, [string] $cluster, [string] $oldpg, [string] $newpg, [string] $vlan ) # Add the VI-Snapin if it isn't loaded already if ( (Get-PSSnapin -Name "VMware.VimAutomation.Core" -ErrorAction SilentlyContinue) -eq $null ) { Add-PSSnapin -Name "VMware.VimAutomation.Core" } If ( !($vcenter) -or !($cluster) -or !($oldpg) -or !($newpg) -or !($vlan) ) { Write-Host `n "pg-cluster-rename: <vcenter-server> <cluster> <oldpg> <newpg>" `n Write-Host "This script renames each port group with the name <oldpg> to <newpg>" `n Write-Host " <vcenter-server> - DNS name of your vCenter server." `n Write-Host " <cluster> - Display-Name of the vCenter cluster, on which we are" Write-Host " gonna create the new portgroup." `n Write-Host " <oldpg> - Name of the old Port Group that is to be replaced (ie VLAN2)." `n Write-Host " <newpg> - Name of the new Port Group (ie PG-VLAN2-Produktion)." `n Write-Host " <vlan> - VLAN-ID for of the new port group." `n exit 1 } Connect-VIServer -Server $vcenter Get-Cluster $cluster | Get-VMHost | Get-VirtualSwitch -Name $vswitch | ` New-VirtualPortGroup -Name $pg -VLanId $vlan Get-Cluster $cluster | Get-VM | Get-NetworkAdapter | Where { $_.NetworkName -eq "$oldpg" } | ` Set-NetworkAdapter -NetworkName $newpg -Confirm:$false Get-Cluster $cluster | Get-VMHost | %{Get-View (Get-View $_.ID).configmanager.networkSystem} | %{ $_.RemovePortGroup($oldpg) } Disconnect-VIServer -server $vcenter -Confirm:$false This script basically takes a vCenter instance and a single cluster, then creates a new Port Group on each host, after which it reconfigures all VMs possessing a virtual NIC with that Port Group and then deletes the old Port Group.

September 24, 2014 · 2 min · 321 words · christian

VMware design rules

I’m just got back from four days in Rostock over at S&N, where I was attending a VMware design course and here’s a list of questions I did ask the trainer: What’s the disadvantage of having a 1016 ported vSwitch ? Any clues on how to exchange the default certificate of the Virtual Center ? Are there any tools to stress test the virtual system ? Are there any performance impacts of having more than 10 users in Virtual Center ? Any clues and/or guides on how to do time synchronization in VMware guests, especially Linux guests ? What’s the preferred NIC type for Linux guests ? Any clues to using Raw Device Mappings with VMotion ? Is there a way of defining CPU masks on a global level ? Answers: ...

August 16, 2014 · 3 min · 503 words · christian

More VirtualCenter troubles

Well, after my co-worker switched the VirtualCenter certificates with one produced by our RA a few days ago, I can’t clone anything using a customization specification anymore. Unable to decrypt passwords in customization specification Guess, we’re shit outa luck. At least both of those linked VMTN discussions don’t contain any (that is for us) workable solution (well besides storing the password in cleartext in the spec – which ain’t sooo good). Gonna bug him tomorrow to open up a VMware support request, maybe that’ll help somewhat. I sure hope so.

August 16, 2014 · 1 min · 90 words · christian

VMware vCenter: is not connected

Well, today I once again had the case where a virtual machine (in my case a Virtual Machine Template) was kinda stuck. You couldn’t remove the template (as in the entries for “Remove from inventory” was grayed out) and you couldn’t re-add the Virtual Machine’s VMX from the datastore browser either. VI Client - Disconnected templates Though, a simple putting the host into maintenance mode and rebooting helped that problem. Maybe there is a simpler solution for this, I just don’t know about it. ...

August 8, 2014 · 1 min · 182 words · christian

VMware: New VirtualCenter 2-5 Update 4

As many people on the VM-Planet already blogged about this, I ain’t gonna write just about it. Let’s turn the clock back a few months, to January 2008. As the institution I work for, is part of the DFN we took the opportunity to be a part of the " I want you to run our RA"-gang. In January 2008 we thought about changing the vCenter certificate. Now, apparently there’s a slight difference between the DFN-PCA and what VMware considers common practice. ...

August 8, 2014 · 2 min · 242 words · christian

vCenter: Removing VSC custom attributes

Well, yesterday I got pissed of those Virtual Storage Console custom attributes. Currently we don’t use the Provisioning & Cloning feature of the VSC, thus we don’t need the custom attributes. After poking around, I decided to write a short PowerCLI script to do the task. It’s really rather simple, so here goes: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 param( [string] $vCenter ) # Add the VI-Snapin if it isn't loaded already if ( (Get-PSSnapin -Name "VMware.VimAutomation.Core" -ErrorAction SilentlyContinue) -eq $null ) { Add-PSSnapin -Name "VMware.VimAutomation.Core" } If ( !($vCenter) ) { Write-Host Write-Host "vcenter-remove-vsc-attributes: <vcenter-server>" Write-Host Write-Host " <vcenter-server> - DNS name of your vCenter server." Write-Host exit 1 } Connect-VIServer -Server $vCenter Remove-CustomAttribute -CustomAttribute "PnC.CustSpec", "PnC.Deployed", "PnC.GroupID", "PnC.Source" -Confirm:$false Disconnect-VIServer -server $vCenter -Confirm:$false

October 17, 2012 · 1 min · 142 words · christian

VMs in Alarm state after scheduled maintainance

Well, I’m back at work after three weeks of vacation (some pictures to follow) and the provider hosting our disaster datacenter had their annual (or is it monthly now?) SAN maintainance, so we shut down everything over there by 9:00 am. After things were back up around 5pm, I booted the ESX hosts, however the VMs we’re all displaying the alert state - as if either the VMs had an HA event or we’re using to much CPU time. It didn’t matter whether or not the VM was running or not, the state persisted. ...

July 22, 2012 · 1 min · 129 words · christian

VMware Update Manager issues

Well, I recently (last Wednesday) had a lot of trouble with Update Manager. First I thought, upgrading vCenter and modules to 5.0U1 would solve my troubles, however it did not. Update Manager was still complaining about something. Since neither in the vCenter Update Manager nor the vCenter log itself were having any useful information I enabled SSHd and the ESXi Shell via the vCenter client: SSH’ed into the ESX host and looked at /var/log/esxupdate.log, and found this particular log: ...

March 31, 2012 · 2 min · 305 words · christian

Microsoft Cluster on VMware and Devices

Well, once again the Microsoft Cluster on VMware bit my ass … As you might know, MSCS on VMware is a particular kind of pain, with each upgrade you end up with the same problem over and over again (SCSI reservations on the RDM-LUNs being one, and the passive node not booting being the other). So I opened up another support case with VMware, and the responded like this: Please see this kb entry: http://kb.vmware.com/kb/1016106 ...

February 11, 2012 · 2 min · 299 words · christian

Reconfiguring NTP settings vCenter-wide

I recently started reinstalling all my ESX hosts, so I wrote up a short script that is reconfiguring all hosts and sets the NTP configuration according to my wish: 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 param( [string] $vcenter, [string] $ntpserver1, [string] $ntpserver2 ) # Add the VI-Snapin if it isn't loaded already if ( (Get-PSSnapin -Name "VMware.VimAutomation.Core" -ErrorAction SilentlyContinue) -eq $null ) { Add-PSSnapin -Name "VMware.VimAutomation.Core" } If ( !($vcenter) -or !($ntpserver1) -or !($ntpserver2) ) { Write-Host `n "vcenter-ntp-reconfigure: <vcenter-server> <ntpserver1> <ntpserver2>" `n Write-Host "This script clears the NTP servers currently configured and" `n Write-Hsot "adds the ones supplied on the command line." `n Write-Host " <vcenter-server> - DNS name of your vCenter server." `n Write-Host " <ntpserver1> - NTP server #1" `n Write-Host " <ntpserver2> - NTP server #2" `n exit 1 } Connect-VIServer -Server $vcenter foreach ($esxhost in Get-VMHost) { Get-VMHost $esxhost | Remove-VMHostNtpServer -Confirm:$false -NtpServer (Get-VMHost $esxhost | ` Get-VMHostNtpServer) Get-VMHost $esxhost | Add-VMHostNtpServer -NtpServer $ntpserver1 Get-VMHost $esxhost | Add-VMHostNtpServer -NtpServer $ntpserver2 } Disconnect-VIServer -server $vcenter -Confirm:$false As you can see, the script takes the vCenter hostname and two NTP servers and basically applies it to each host in your vCenter environment.

February 4, 2012 · 2 min · 219 words · christian