Tag Archives: VESI

Release: vEcoShell 1.2.6


image

vEcoShell 1.2.6 is GA!!

Quote from vEcoShell blog:

The major difference in 1.2.6 is in how connections to multiple vCenter or ESX Servers are managed.  In previous versions, vEcoShell maintained all session management and required custom code in nearly all of it’s scripts to function properly.  These scripts could not run externally to vEcoShell, so the PowerShell Code tab provided limited value.  With the 1.2.6 release, vEcoShell now lets PowerCLI manage all connections.  This means we were able to remove all custom code from our script library.  Nearly every script that is in vEcoShell today can be run externally.  Simply copy a code block from the "PowerShell Code" tab after a script has completed and paste it into the script editor.  After running the Connect-VIServer command in the console window, the copied funciton will run just as it does in the admin console.

What’s new:

  • it’s the first stable release
  • compatible with PowerCLI 4.0 U1
  • easy Copy and Paste PowerCLI code
  • It will remain Freeware 🙂

You can download the vEcoShell 1.2.6 and language packs here: http://vcommunity.vizioncore.com/administration/vecoshell/p/downloads.aspx 

If you’re new to the vEcoShell, checkout the QuickTip videos from Scott Herold here: http://vcommunity.vizioncore.com

Advertisements

PowerCLI: Return Datastore name by Canonical name


When you are troubleshooting an ESX host, you can see a lot off warnings in the VMKERNEL log:

Jan 29 16:15:34 esx02.ict-freak.local vmkernel: 9:23:45:33.917 cpu1:4210)WARNING: NMP: nmp_DeviceAttemptFailover:
Retry world failover device “t10.9454450000000000000000001000000056900000D0000000” – issuing command 0x4100041f0c00

But which datastore belongs to the Canonical name mentioned in the VMKERNEL log??

The following script will return the Datastore name. Thanks @Lucd22 for the help!!

$esxhost = "esx1.ict-freak.local"
$id = "t10.9454450000000000000000001000000056900000D0000000"

foreach($ds in (Get-VMHost $esxhost | `
    Get-Datastore | where{$_.Type -eq "vmfs"} | Get-View)){

    $ds.Info.Vmfs.Extent | %{
         if($_.DiskName -eq $id){
            Write-Host $ds.Info.Name $_.DiskName
        }
    }
}

The output will look like this:

image

Ok, this is a nice script to have in you toolbox, but I hear you think,  how do I add it to the VESI?.

First you need to create a new folder, if you don’t use any other Powerpack.

image

Give the folder a name. I used the name Personal scripts:

image

The next step is to add a new script node:

image

The last step is to paste the following code into the new created script node:

if ($global:defaultviservers) {
    $id = Read-Host "Enter the Canonical Name (naa.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)"
    foreach($esx in (Get-VMHost)){
        foreach($ds in (Get-VMHost $esx | Get-Datastore | ` 
        where{$_.Type -eq "vmfs"} | Get-View)){
            $Details = "" |Select-Object DataStore
                $ds.Info.Vmfs.Extent | %{
                 if($_.DiskName -eq $id){
                    $Details.DataStore = $ds.Info.Name
                }
               }
        }
        $Details.PSTypeNames.Clear()
        $Details
    }
}
Else {
    [System.Windows.Forms.MessageBox]::Show('You must connect to one or more hosts before you can use this node. Please click on the ''Managed Hosts'' node of the VMware PowerPack, connect to one or more of the servers you have configured there, and then try again.','Connection not established',[System.Windows.Forms.MessageBoxButtons]::OK,[System.Windows.Forms.MessageBoxIcon]::Information) | Out-Null
}

If you want to run this script, you have to connect to vCenter first. Open VMware – Managed Hosts:

image

Click on Add managed host… to add a server:

image

To connect to the new added vCenter server, press the connect under actions. To run the script click on the new create script node and enter a Canonical Name.

image

And the script will return the Datastore name:

image

Now you are able to convert the Canonical name to the Datastore Name.

PowerCLI: Search VM via IP or MAC Address


image image

In this post you’ll find two scripts that will help you find a VM via an IP or MAC address. I found the MAC address script on the vmtn communities and it was written by Luc Dekens (@LucD22):

http://communities.vmware.com/message/1068045#1068045

 

IP Address:

 

The following script will return the VM name after a short search. The only thing you need to enter is the ip address:

$tgtIP = "192.168.123.1"
$vms = Get-VM
foreach($vm in $vms){
  
  $vmIP = $vm.Guest.IPAddress
  foreach($ip in $vmIP){
    if($ip -eq $tgtIP) {
      Write-Host "Found the VM!" 
      $vm.Name 
    }
  }
}

When you add the script to the Virtualizaion Eco Shell, you will have to change the $tgtIP line:

$tgtIP = Read-Host "enter IP address"

When you run the script from the Eco Shell, you’ll have to enter an ip address:

image

After a couple of seconds (if you have a large environment it will take a while 😉 ) The script will return the VM name:

image

 

MAC Address

 

The following script start a search based on the MAC address of the VM.

$tgtMAC = ""
$vms = Get-VM
foreach($vm in $vms){
  
  $vmMAC = $vm | Get-NetworkAdapter | select MacAddress
  foreach($mac in $vmMAC){
    if($mac.MacAddress -eq $tgtMAC) {
      Write-Host "Found the VM!" 
      $vm.Name 
    }
  }
}

You can also add the script to the Eco Shell. Just change the $tgtMAC line to:

$tgtMAC = Read-Host "enter MAC address"

PowerCLI: Find Resourcepool or VMs with Memory Ballooning/Swap Usage


 image image

In this post I will show you how to report Resource Pools and VMs with active Memory Ballooning. But what is Memory Ballooning. I short quote from the ESX3 memory whitepaper http://www.vmware.com/pdf/esx3_memory.pdf:

The balloon driver, also known as the vmmemctl driver, collaborates with the server to reclaim pages that are considered least valuable by the guest operating system. It essentially acts like a native program in the operating system that requires more and more memory. The driver uses a proprietary ballooning technique that provides predictable performance that closely matches the behavior of a native system under similar memory constraints. This technique effectively increases or decreases memory pressure on the guest operating system, causing the guest to invoke its own native memory management algorithms. When memory is tight, the guest operating system decides which particular pages to reclaim and, if necessary, swaps them to its own virtual disk.

You need to be sure your guest operating systems have sufficient swap space. This swap space must be greater than or equal to the difference between the virtual machine’s configured memory size and its reservation.

More information about Memory ballooning can also be found in this post by Arnim van Lieshout.

So let’s continue with the PowerCLI scripts.

The following script will report all the resource pools with active Memory Ballooning:

$myCol = @()
foreach($clus in (Get-Cluster)){
 foreach($rp in (Get-ResourcePool -Location $clus | Get-View | Where-Object `
  {$_.Name -ne "Resources" -and `
   $_.Summary.QuickStats.BalloonedMemory -ne "0"})){
   $Details = "" | Select-Object Cluster, ResourcePool, `
   SwappedMemory ,BalloonedMemory

    $Details.Cluster = $clus.Name
    $Details.ResourcePool = $rp.Name
    $Details.SwappedMemory = $rp.Summary.QuickStats.SwappedMemory
    $Details.BalloonedMemory = $rp.Summary.QuickStats.BalloonedMemory

    $myCol += $Details
  }
}
$myCol

#$myCol | Export-Csv -NoTypeInformation C:\RPs-Ballooning.csv

This will be the output:

image

If you add the script to a powerpack within the Virtualization EcoShell, It will look like this:

image

If you want to report the VMs with active memory ballooning, you can run the following script:

$myCol = @()
foreach($vm in (Get-View -ViewType VirtualMachine | Where-Object `
  {$_.Summary.QuickStats.BalloonedMemory -ne "0"})){
   $Details = "" | Select-Object VM, `
   SwappedMemory ,BalloonedMemory

    $Details.VM = $vm.Name
    $Details.SwappedMemory = $vm.Summary.QuickStats.SwappedMemory
    $Details.BalloonedMemory = $vm.Summary.QuickStats.BalloonedMemory

    $myCol += $Details
  }
$myCol

And within a couple of seconds, you’ll get a list with all the VMs with active ballooning:

image

If you add the script to a powerpack within the Virtualization EcoShell, It will look like this:

image

Beta: Vizioncore Virtualization EcoShell


image

Vizioncore released the beta version of the Virtualization EcoShell.

The goal of the Vizioncore Virtualization EcoShell is to provide a freeware desktop application for novice and expert IT administrators leveraging Windows PowerShell scripts across their multi-platform virtual environments.   

Fostered and supported by The Virtualization EcoShell Initiative (VESI) – an online community-driven Web site sponsored by Vizioncore – the Virtualization EcoShell is enhanced by the participation of community members through the exchange of new ideas, value-add services and extendable scripts. To become a member of the VESI community, please visit VESI Registration.

 

One of the best features is based on a script from Alan Renouf (vdiagram) and it’s called Generate vDiagram.

image

With this feature/script you can generate a Visio drawing of your VI environment. You can choose the following options:

image

If all the options are set to true, the script will generate three workspaces in Visio with three different vDiagrams. The diagram will look like this:

image

If you are managing a VI environment, this will be a must have tool. So take a look and get your download here: http://www.thevesi.org/downloads.jspa