VI Toolkit 1.5 + VUM = Error


image

I was experimenting with the VUM Powershell library. I ran the Get-Baseline cmdlet and then the following error occurred:

image

After some digging around at goolge and vmware.com. I found that  the VUM library doesn’t work with the new version of the VI Toolkit. VMware is aware of the problem according to the post from Carter on VMTN and the Release notes:

Carter Shanklin posted this information on VMTN:

Hi everyone,

There is an incompatibility between VI Toolkit 1.5 and the VUM cmdlets. For now if you need to use the VUM cmdlets you will need to do so on a system that has VITK 1.0 installed.
This incompatibility will be resolved by a minor update to VI Toolkit that will be shipped when the next version of VUM ships. The next version of VUM will have cmdlets that support that version as well as the current version.

We’ve updated the release notes to note the incompatibility. Sorry for the inconvenience.

From the release notes:

VI Toolkit (for Windows) 1.5 is not compatible with VMware Update Manager – PowerShell Library 1.0.

windowstoolkit15-200901-releasenotes.html

To fix this “problem” I removed the VI Toolkit v 1.5 and installed the VI Toolkit v 1 again. After the rollback, the VUM library is working again :-).

I hope that VMware will fix this soon.

Advertisement

VMware: Start the VI Toolkit on Win 7


After installing Windows 7 build 7057 x64 the VI Toolkit starts with the following error /warning. If  you run the Set-ExecutionPolicy unrestricted  command as a normal user, the command will not run successfully.

image

The solution is simple: Open the VI Toolkit with the Run as administrator permissions option.

image

When the VI Toolkit window pop’s up. Run the Set-ExecutionPolicy unrestricted command, and the VI Toolkit starts without the error.

image

Powershell: Check if partition is aligned or not


This script has the following Requirements:

  • VI Toolkit
  • Powershell
  • WMI query
  • Windows VM’s

The following script get al lists of all Windows VM’s which are powered on. The next step is a WMI query which queries the Win32_DiskPartition class. The final step is a match with the $StartingOffset variable.

Add-PSSnapIn VMware.VimAutomation.Core

# Connect to vCenter
$VC = Connect-VIServer (Read-Host "Enter vCenter server")

$StartingOffset = "65536"

# Get all VM’s with powerstate = PoweredOn
$VMS = Get-VM | Where {$_.PowerState -eq "PoweredOn"} |Sort Name
ForEach ($VM in $VMS)
    {
  
# Process only Windows Server VM’s
   if ($VM.Guest.OSFullName -match "Microsoft Windows*")
        {  
      
# Do a WMI Query
       $results = get-wmiobject -class "Win32_DiskPartition" -namespace "root\CIMV2" -ComputerName $VM

           foreach ($objItem in $results)
                {
              
# Do the match
               if ($objItem.StartingOffset -match $StartingOffset){
                  
write-host $objItem.SystemName
                  
write-host $objItem.Name
                  
write-host "Partition aligned" -foregroundcolor green
                  
write-host}
              
else{
                  
write-host $objItem.SystemName
                  
write-host $objItem.Name
                  
write-host "Partition NOT aligned" -foregroundcolor red
                  
write-host                  
                    }
                }
        }
    }
# Disconnect from vCenter
Disconnect-VIServer -Confirm:$False

after running the script, the following output will be generated:

image

Powershell: Check if KB patch is installed


Ik wilde weten of een bepaald KB nummer was geïnstalleerd op mijn VM’s. Dit wilde ik natuurlijk niet met het handje nakijken en heb hiervoor een script bij elkaar geraapt.

Het onderstaande script kun je gebruiken in een VMware VI omgeving.

#Add-PSSnapIn VMware.VimAutomation.Core

# Connect to vCenter
$VC = Connect-VIServer (Read-Host "Enter vCenter server")

# Enter the KB#
$HotFixID = (Read-Host "Enter KB#")
Write-Host

# Get all VM’s with powerstate = PoweredOn
$VMS = Get-VM | Where {$_.PowerState -eq "PoweredOn"} | Sort Name

ForEach ($VM in $VMS)

{
# Process only Windows Server VM’s
if ($VM.Guest.OSFullName -match "Microsoft Windows Server*")
  { 
 
# Get all the info using WMI
  $results = get-wmiobject -class "Win32_QuickFixEngineering" -namespace "root\CIMV2" -ComputerName $VM 
  
    # Loop through $results and look for a match then output to screen
    foreach ($objItem in $results)
            {
                # Do the match
                if ($objItem.HotFixID -match $HotFixID)
                    {
                    write-host $objItem.CSName
                    write-host "Hotfix "$HotFixID" installed"
                    write-host
                    }
            } 
   }
}
# Disconnect from vCenter
Disconnect-VIServer -Confirm:$False

 

Zodra je het script start, word er gevraagd naar de vCenter server en het KB nummer wat je wilt nakijken.

image

De volgende output wordt gegenereerd:

image

 

Je kunt het onderstaande script gebruiken in een omgeving zonder VI3:

# Get content
$computers = get-content c:\computers.txt

# Get all the info using WMI
$results = get-wmiobject -class “Win32_QuickFixEngineering” -namespace “root\CIMV2″ -computername $computers

# Loop through $results and look for a match then output to screen
foreach ($objItem in $results)
{
    if ($objItem.HotFixID -match “KB932168″)
    {
        write-host $objItem.CSName
        write-host “Hotfix KB932168 installed”
        write-host
    }
}

 

Source: http://techittome.wordpress.com/2007/04/12/windows-powershell-script-to-check-for-specific-hotfix/

VMware: VI Toolkit 1.5 Released


 

From the original blogpost by Carter Chanklin:

We’ve added 32 new cmdlets, enhanced our existing cmdlets, and fixed tons of bugs. If you’re the sort of person who loves fine print, you can also have a look at our release notes. The release notes has a great table that shows all the differences between 1.0 and 1.5.

image

More info and videos can be found in the original blogpost: http://blogs.vmware.com/vipowershell/2009/01/vi-toolkit-15-released.html

 

Source: http://www.ntpro.nl/blog/archives/903-Carter-is-happy-to-announce-VMware-has-released-the-VI-Toolkit-1.5.html

VMware: vDiagram script by Alan Renouf


Alan Renouf created a new powershell / vi toolkit script which draws a nice diagram of your VI environment.

Instructions:

You will need:

  • Powershell V1 (I haven’t tried it on V2 yet)
  • The VI Toolkit
  • Microsoft Visio (I have only tried 2003 +)

How to use:

  1. Download the zip file from the bottom of this page
  2. Once extracted copy the  ‘My-VI-Shapes.vss’ file to your ‘My Documents\My Shapes’ folder.  If the folder does not exist create it and copy the file in.
  3. Run the powershell script with the following options:

To diagram the entire Infrastructure:

vDiagram.ps1 -VIServer MYVISERVER

To diagram a specific cluster use the following:

vDiagram.ps1 -VIServer MYVISERVER -Cluster "Production Cluster’

image

More info and the script can be found over here: http://teckinfo.blogspot.com/2009/01/vdiagram-document-your-vi-with-one.html

Alan keep up the good work!

Source:

image

VMware: An introduction to scripting VI using Perl or Powershell


David Deeths heeft een post geplaats met daarin de VMworld labs over Perl scripting en het gebruik van Powershell.

Hello, my name is David Deeths and I’m a new contributor to the VMware Developer Blog. I wanted to share with the community the scripting lab we put together for VMworld 2008. This is a great introduction to scripting with the VI Toolkits in Perl or PowerShell. The PowerShell version doesn’t require any programming or scripting experience at all.

The labs will help you get started with scripting VMware Infrastructure to enable automation, extensibility, and integration with existing tools. When we ran this at VMworld, we had about 600 attendees and it was so popular some students camped out in line to attend the lab a second time. We had so many folks request a way to share this with their teams that we decided to publish the whole thing for the community.

The lab is available in two versions: one shows how to use the VI Perl Toolkit and the other shows how to use the PowerShell-based VI Toolkit (for Windows). The attached files contain the manuals for both versions of the lab and the exercises for both versions of the lab.

The lab takes 2-3 hours to complete (not including the time to set the environment up first), but is conveniently split into 20 minute exercises. You’ll walk away with a better understanding of VMware Infrastructure, resources for using the toolkits, and a variety of useful scripts for performing common administrative tasks. The exercises cover triggering tasks, examining VM attributes, performing actions on VMs, and exporting performance data.

Meer info en een aantal downloads vind je hier: an-introduction-to-scripting-vi-using-perl-or-powershell

Script: VI Toolkit Healthcheck


Ivo Beerens just released his second version of his Healthcheck powershell script.

Version 2.0 of the Healthcheck script is released. The script reports the following:

– VMware ESX server Hardware and version         
– VMware vCenter version    
– Cluster information
– VMware statistics
– Active Snapshots    
– CDROMs connected to VMs   
– Floppy drives connected to VMs  
– Datastores Information such as free space
– RDM information 
– VM information such as VMware tools version,  processor and memory limits     
– VM’s and there datastore
– VMware timesync enabled  
– Percentage disk space used inside the VM
– VC error logs last 5 days

It is possible to schedule this script and output the content to HTML and e-mail it. 

image 

You can download the script over here: http://www.ivobeerens.nl/?p=256

VMware: Service Console Memory


Als je ESX 3.x standaard installeerd krijgt het Service Console 272 MB geheugen.

image

Via fdisk –l  kun je de partitie informatie opvragen. Zoals je ziet heeft deze ESX server een Swap partitie van 1600MB. 

image

Standaard is de Swap partitie 544MB (2*272mb van het Service Console).  Mocht de swap partitie inderdaad “maar” 544mb groot zijn, dan kun je het geheugen van het Service Console niet verhogen. Hoe je dit verder kan oplossen lees je hier: http://communities.vmware.com/message/685697#685697

Je kunt het gehugen van het Service Console op twee manieren aanpassen, via de de VIC of via de commandline.

Via de VIC

klik op properties.

image

Voer daarna de juiste waarde in (800MB is de max):

image

 

Vanaf het Service Console

Via het onderstaande commando kun je opvragen hoeveel geheugen er voor het Service Console geconfigureerd is.

[root@esxserver root]# cat /etc/vmware/esx.conf | grep -i "memSize"
/boot/memSize = "272"

Als je dit wilt ophogen naar 800MB kun je dat doen via het commando:

vmware-vim-cmd hostsvc/memoryinfo 838860800 (http://communities.vmware.com/thread/173359)

Daarna even kijken of de settings is doorgevoerd.

[root@esxserver root]# cat /etc/vmware/esx.conf | grep -i "memSize"
/boot/memSize = "800"

 

Via de VI Toolkit:

$consoleMemMb = 800
Get-VMHost | Get-View | %{(Get-View -Id $_.ConfigManager.MemoryManager).ReconfigureServiceConsoleReservation($consoleMemMb*1mb)}
Thanks to LucD: http://communities.vmware.com/

De bovenstaande code past de setting aan op al je ESX servers in je VirtualCenter.

image

En in de VIC kun je zien dat de settings is aangepast en een herstart nodig is.

image