Archive

Archive for the ‘vsphere’ Category

Import-Export VM notes with PowerCLI

24 Jul 2014 Leave a comment

In a previous post I blogged about exporting and importing custom attributes, but sometimes you need to do the same also for notes.

A little PowerCLI and all is done quickly.

Export

Just connect to our source vCenter, export all notes and disconnect:

Connect-VIserver -server VCsource.vlab.local
$vmList = Get-VM
$noteList = @()
foreach ($vm in $vmList) {
$row = “” | Select Name, Notes
$row.name = $vm.Name
$row.Notes = $vm | select Notes
$notelist += $row
}
$noteList | Export-Csv “.\exported-notes.csv” –NoTypeInformation

Disconnect-VIServer “*” -Confirm:$False

 

Import

And now lets import all notes:

Connect-VIserver -server VCdest.vlab.local

$noteList = Import-Csv “.\exported-notes.csv”
foreach($nLine in $noteList){
if ( $nLine.Notes -ne “”){
Set-VM -VM $nLine.Name -Notes $nLine.Notes -Confirm:$false
}
}

Disconnect-VIServer “*” -Confirm:$False

Categories: vmware, vsphere Tags: ,

Import-Export delle note delle VM tramite PowerCLI

24 Jul 2014 Leave a comment

Nel precedente post ho presentato un paio di script per importare e esportare i custom attributes, ma capita di aver bisogno di fare la stessa cosa anche per le note delle vm.

Anche in questo caso, con pochissime righe in PowerCLI il tutto si risolve velocemente.

Export

Per esportare è sufficiente connettersi al vCenter, esportare tutte le note e disconnettersi:

Connect-VIserver -server VCsource.vlab.local
$vmList = Get-VM
$noteList = @()
foreach ($vm in $vmList) {
    $row = "" | Select Name, Notes
    $row.name = $vm.Name
    $row.Notes = $vm | select Notes
    $notelist += $row
}
$noteList | Export-Csv ".\exported-notes.csv" –NoTypeInformation

Disconnect-VIServer "*" -Confirm:$False

 

Import

E ora reimportiamo il tutto:

Connect-VIserver -server VCdest.vlab.local

$noteList = Import-Csv ".\exported-notes.csv"
foreach($nLine in $noteList){
    if ( $nLine.Notes -ne ""){
        Set-VM -VM $nLine.Name -Notes $nLine.Notes -Confirm:$false
    }
}

Disconnect-VIServer "*" -Confirm:$False

Categories: vmware, vsphere Tags: ,

Import–Export VM custom attributes from vCenter with PowerCLI

21 Jul 2014 1 comment

Some time ago, during a migration, I needed to migrate all VM custom attributes from a cluster in a first vCenter to another one.

As easy (and boring…) as is to just retype the attributes value, there was over 400 VMs, and I didn’t want to do this by hand.

So…PowerCLI to the rescue! Here the two little script I used for this task.

 

Export

First lets connect to our source vCenter and export all custom attributes:

Connect-VIserver -server VCsource.vlab.local

$attList = @()
$attList = Get-CustomAttribute -TargetType VirtualMachine
$attList | Export-Csv “.\exported-attributes.csv” –NoTypeInformation

then lets export all attributes values and disconnect:

$valueList =@()
Get-cluster CL01 | get-vm | % {
for($i = 0; $i -lt $_.CustomFields.Count; $i ++ ){
$row = “” | Select VMname, FieldKey, FieldValue
$row.VMname = $_.Name
$row.FieldKey = $_.CustomFields.Keys[$i]
$row.FieldValue = $_.CustomFields.Values[$i]
$valueList += $row
}
}
$valueList | Export-Csv “.\exported-attributes-value.csv” -NoTypeInformation

 

Disconnect-VIServer –server “*” -Confirm:$False

 

Import

Ok, now we have all vm moved to the destination vCenter and is time to import all attributes.

First connect to destination vCenter and re-create attributes:

Connect-VIserver -server VCdest.vlab.local

$attList = @()
$attList = Import-Csv “.\exported-attributes.csv”
foreach ($CustAttrib in $attList){
New-CustomAttribute -Name $CustAttrib.Name -TargetType $CustAttrib.TargetType
}

and, at last, lets import all attribute values and disconnect:

$NewAttribs = Import-Csv “.\exported-attributes-value.csv”
foreach($line in $NewAttribs){
# if value is empty, skip it (just to have all the import go faster)
if( $line.FieldValue -ne “”) {
Set-CustomField -Entity (get-vm $line.VMName) -Name $line.FieldKey -Value $line.FieldValue -confirm:$false
}
}

Disconnect-VIServer “*” -Confirm:$False

 

Easy peasy, doesn’t it?  Occhiolino

Categories: vmware, vsphere Tags: ,

Import–Export dei custom attributes delle VM tramite PowerCLI

21 Jul 2014 Leave a comment

Qualche tempo fa, durante una migrazione, mi e’ capitato di dover migrare tutti i valori degli attributi custom delle VM da un vCenter ad un altro.

Per quanto fosse un compito facile (basta ricreare gli attributi e copiare via via i valori), c’erano più di 400 VM e non volevo farlo a mano.

Niente di meglio che usare un po’ di PowerCLI ! Ecco qui i due piccoli script che ho usato.

 

Export

Per prima cosa connettiamoci al vCenter sorgente e esportiamo tutti i custom attribute:

Connect-VIserver -server VCsource.vlab.local

$attList = @()
$attList = Get-CustomAttribute -TargetType VirtualMachine
$attList | Export-Csv “.\exported-attributes.csv” –NoTypeInformation

ora esportiamo anche tutti i valori dei custom attibute delle varie VM e disconnettiamoci:

$valueList =@()
Get-cluster CL01 | get-vm | % {
for($i = 0; $i -lt $_.CustomFields.Count; $i ++ ){
$row = “” | Select VMname, FieldKey, FieldValue
$row.VMname = $_.Name
$row.FieldKey = $_.CustomFields.Keys[$i]
$row.FieldValue = $_.CustomFields.Values[$i]
$valueList += $row
}
}
$valueList | Export-Csv “.\exported-attributes-value.csv” -NoTypeInformation

 

Disconnect-VIServer –server “*” -Confirm:$False

 

Import

Ok, ora è il momento di importare tutto nel vCenter destinazione (ovviamente dopo aver migrato le varie VM).

Per prima cosa connettiamoci al vCenter destinazione e ricreiamo gli attribute:

Connect-VIserver -server VCdest.vlab.local

$attList = @()
$attList = Import-Csv “.\exported-attributes.csv”
foreach ($CustAttrib in $attList){
New-CustomAttribute -Name $CustAttrib.Name -TargetType $CustAttrib.TargetType
}

ed infine importiamo i valori e disconnettiamoci:

$NewAttribs = Import-Csv “.\exported-attributes-value.csv”
foreach($line in $NewAttribs){
# if value is empty, skip it (just to have all the import go faster)
if( $line.FieldValue -ne “”) {
Set-CustomField -Entity (get-vm $line.VMName) -Name $line.FieldKey -Value $line.FieldValue -confirm:$false
}
}

Disconnect-VIServer “*” -Confirm:$False

 

Meglio così che farsi un lungo e noioso lavoro di copiatura no?  Occhiolino

Categories: vmware, vsphere Tags: ,

vMotion fails at 10% – Necessary module isn’t loaded

11 Feb 2013 Leave a comment

I’ve recently had a problem with a host ESXi 5.0: all vMotion failed at 10% showing error "Necessary module isn’t loaded".

After a short search I’ve found two KB regarding this issue: KB1013150 and KB2013128.

Here is quick steps to restore vMotion functionality:

  1. Using vSphere Client, connect to the host directly or throught vCenter
  2. Go to Configuration -> Advanced Settings
  3. Select Migrate, set Migrate.Enabled to 0 e click OK
  4. Connect by SSH to host and run this command:
    esxcli system module load -m migrate
  5. Reconnecto to host using vSphere Client and set back Migrate.Enabled to 1

Hope this helps someone else Sorriso

Categories: vsphere Tags: , ,

vMotion si blocca al 10% – Necessary module isn’t loaded

11 Feb 2013 4 comments

Mi è capitato poco tempo fa di avere un problema ad un host ESXi 5.0: tutti i vMotion si bloccavano al 10% con l’errore "Necessary module isn’t loaded".

Dopo una breve ricerca ho trovato due KB dedicate a questo problema: la KB1013150 e la KB2013128.

Ecco in breve gli step per risolvere e ripristinare la funzionalità di vMotion:

  1. Connettetevi con il vSphere Client all’host problematico via vCenter o direttamente
  2. Portarsi in Configuration -> Advanced Settings
  3. Selezionate Migrate, settate il valore di Migrate.Enabled a 0 e date OK
  4. Connettetevi via SSH all’host ed eseguite il comando:
    esxcli system module load -m migrate
  5. Riconnettetevi all’host con il vSphere Client e riportate il valore di Migrate.Enabled a 1
    Spero questo post sia di aiuto ad altri in questa situazione Sorriso
Categories: vmware, vsphere Tags: , ,

vCenter 5.1 on Windows 2003: solving some issues

10 Dec 2012 Leave a comment

Recently I had to install vCenter 5.1 on Windows 2003 and I had hit a couple of issues.

Here how I solved them: hopefully someone else will have a smoother installation process (and I have some notes just in case of another installation Occhiolino )

SSO: Error 29155

The first issue was about an error encountered when installing SSO: “Error 29155 Identity source discovery error”. I’m not sure if it’s something tied to that specific environment  (a complex AD with multiple windows 2008 dc) or not, but even trying a couple of reinstallation I had always this error.
According to KB 2034374 this is due to a failed attempt to automatically discover an Active Directory domain. You can click OK on this error and continue installation and add manually AD Authentication to SSO later.

My advice is to solve this issue before installing the vCenter Server component.

To add AD Authentication, you can follow these steps:

  • conclude the SSO installation,
  • proceed with the installation of Inventory Service and vSphere Web Client.
  • login to the vSphere Web Client as the user “admin@System-Domain”,
  • go to Administration – Sign-On Discovery,
  • add your Active Directory
  • finally add the newly created identity source to the default domains.
Hardware Health and Health Status plug-ins are disabled in the vSphere Client

The second issue was about Hardware Health and Health Status plug-is disabled in the vSphere Client: this happens only in the vSphere Client installed on the vCenter server and not in the vSphere Web Client.

This issue is a Microsoft issue! As per KB 2031053 the only way to solve it, is by downloading and installing a Microsoft hotfix that you can find in this Microsoft Knowledge Base article. Be aware that after installing this hotfix a reboot is needed.

Follow

Get every new post delivered to your Inbox.

Join 914 other followers