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

Using HPs vibdeposit with VMware Update Manager

As we’re finally at the point, where I only need to bother with HP hardware (which in itself is troublesome enough), I wanted to use HPs vibdeposit with our Update Manager. The whole purpose of the repository is the integration of HPs custom vibs (download able on each hardware under VMware ESXi 5.0) into the VMware Update Manager. That makes it easy to integrate, say the nmi-sourcing driver, into the VMware built ESXi images. ...

February 4, 2012 · 3 min · 469 words · christian

Emptying a VMFS datastore with PowerCLI

Well, once again I hacked at the Powershell/PowerCLI the other day. Since we don’t yet have a Enterprise Plus license at work (which would support Datastore Maintaince and Storage DRS), I needed a way to empty one datastore and move all the content into another one, while enabling Thin-Provisioning. So I googled for a bit, and actually found a few hints … So without further yada-yada, here’s the script I came up with: ...

January 26, 2012 · 2 min · 272 words · christian

Doing TSM's job on Windows Server 2008

Ran into another weird problem the other day … Had a few Windows boxens running out of space. Why ? Well, because TSM includes a System-State backup when creating the daily incremental. Now, apparently (as stated by the IBM support) it isn’t TSM’s job to keep track of the VSS snapshots but rather Windows’. Now by default, if you don’t click on the VSS properties of a Windows drive, there is no limit on the volume. Thus, VSS is slowly eating up all your space. ...

January 26, 2012 · 1 min · 213 words · christian

Empty Port SSL after ADAM installation

I’ve been meaning to post this, but never actually got around to doing that. When installing vCenter 5.0, an instance of ADAM is installed, which stores all the configration data for Linked Mode. It basically boils down to running this script and rebooting the box: 1 2 reg DELETE "HKLMSYSTEMCurrentControlSetservicesADAM_VMwareVCMSDSParameters" /v "Port SSL" /f reg ADD "HKLMSYSTEMCurrentControlSetservicesADAM_VMwareVCMSDSParameters" /v "Port SSL" /t REG_DWORD /d 0000027c /f This is no new invention of myself, just writing it down for myself from here or here.

January 18, 2012 · 1 min · 82 words · christian

Rebooting a virtual machine via Task scheduler

Since the Scheduled Tasks in vCenter ain’t exportable, I went ahead and wrote a rather simple script, which lets me do this in Windows own Task Scheduler. What this script does, is initiate a graceful shutdown and if the VM isn’t shutdown within 60 seconds (12 * 5 seconds) it simply powers the VM off and immediately after that powers it back on. 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( [string] $vCenter, [string] $VMname ) # 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 !($VMname) ) { Write-Host Write-Host "vm-reboot: <vcenter-server> <VMname>" Write-Host Write-Host " <vcenter-server> - DNS name of your vCenter server." Write-Host " <VMname> - Display name of the VM in this vCenter server." Write-Host exit 1 } Connect-VIServer -Server $vCenter $VM = Get-VM $VMname # First, try shutting down the virtual machine gracefully Write-Host "Stopping VM $( $VM )" Write-Host " - Graceful shutdown" Shutdown-VMGuest -VM $VM -Confirm:$false $VM = Get-VM $VMname $i = 0 While ($VM.PowerState -ne "PoweredOff") { # If that doesn't work, break out the hammer and just kill it if ( $i -gt 12 ) { Write-Host " - Forced shutdown" Stop-VM -VM $VMname -Confirm:$false } Start-Sleep -Seconds 5 $VM = Get-VM $VMname $i++ } If ($VM.PowerState -eq "PoweredOff") { Write-Host "Starting VM $( $VM )" Start-VM -VM $VM -Confirm:$false >$NULL } Disconnect-VIServer -server $vCenter -Confirm:$false Before this implementation in PowerCLI, I needed three tasks for each VM that was to be scheduled. And when migrating vCenters (and I usually do an empty install) vCenter’s scheduled tasks are not exportable, thus you need to re-create the tasks on the new vCenter by yourself again, which for more than four virtual machines is really a pain in the ass … ...

January 16, 2012 · 2 min · 401 words · christian

Reoccurring memory limits in vCenter

We recently had, after we migrated from vSphere 4 to vSphere 5, a memory limit in size of the configured memory on each and every VM. Since memory limits on VM level pretty much destroy performance, I went ahead an wrote this simple script to remove all memory limits on all VMs that don’t have “Unlimited” 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 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 "cluster-remove-mem-limits: <vcenter-server>" Write-Host Write-Host " <vcenter-server> - DNS name of your vCenter server." Write-Host exit 1 } Connect-VIServer -Server $vCenter Get-VM | Get-VMResourceConfiguration | Where-Object { $_.memlimitmb -ne '-1' } |` Set-VMResourceConfiguration -memlimitmb $null Disconnect-VIServer -server $vCenter -Confirm:$false This script is basically what the guy over at get-admin.com did, just only for memory limits.

January 13, 2012 · 1 min · 170 words · christian

PowerCLI undamp; Windows jump list for recent items set to zero

Today I had to install PowerCLI on my workstation. When I tried launching it for the first time, it simply opened and closed again instantly. After browsing the VMware community for this error and not finding a useful solution, I ended up googling the error. As it turns out, this only happens when you did set the " Number of recent items to display in jump lists" to something less than 4. ...

July 5, 2011 · 1 min · 89 words · christian

Changing the vCenter hostname

I recently reinstalled the vCenter Server at work, and in my never ending wisdom cough, I decided to do that on new hardware. That entitled using the same host name plus the appendix _NEW. Now, I know this isn’t conforming with DNS naming schemes (iirc underscore isn’t a valid DNS char), however it worked … So once I had everything installed on the new hardware, I switched the ESX servers from the old vCenter to the freshly installed one. Once that was finished, I shut down the old vCenter server, changed IP address and host name of the new one and rebooted. That basically worked, even though suddenly every ESX in my inventory was disconnected. After reconnecting all ESX servers everything was back online. ...

June 1, 2011 · 2 min · 216 words · christian

WDS and DL580 G7

We recently received a shipment of Hewlett Packards all-new DL580 G7. While I’m impressed with what they did with the iLO3, I’m quite disappointed with what they did to the PXE-ROM. Sure, gPXE may be the future and is offering more possibilites than “normal” PXE, however breaking customers deployment option(s) – at least for Windows that is – really wouldn’t be an option. Now for the long story, we needed to install a temporary Windows on this DL580 (one with testing purposes). That said, we tried for three days to actually make this work (trying different things with the boot image), but it kept ending with the same result. ...

January 15, 2011 · 2 min · 246 words · christian