Friday, March 18, 2011

Get/Set custom field in Vmware - Is your VM replicated example ?

For billing and production information, I need to know if SAN is replicated or not.
I use a powershell script to indicate me if ESX host is replicate or not using Virtual Center Custom Field.

First, I must set a value to all ESX for indicate me if this ESX have replicated LUN

To set "Replication" in all your hosts

$VMHosts = Get-VMHost | Sort Name
$CustomField = "Replication"
Foreach ($VMHost in $VMHosts){
Write-Host ($VMHost).Name
Set-CustomField -Entity $VMHost -name $CustomField -Value "Yes"
}



Now, for some ESX with no replication set Custom Field Replication manually to No

To do that, select your host then in summary tab in annotations click on edit


















Then in "Edit Annotations" window change value of Replication field











Now, if you need to know if your VM is replicated use this powershell code

$ArrVM = Get-VM
foreach ($VM in $arrVM) {
$VMHost = Get-VMHost -VM $VM
$Replication = $True
If ($VMHost.CustomFields["Replication"].ToUpper() -eq "NO") {
$Replication = $False
}
Write-Host $VM.Name "replication:" $Replication
}

Wednesday, March 9, 2011

Calcul des Indemnités Kilométriques

A french post today, only for french people.

Si vous souhaitez calculer vos indemnités kilométriques, voici un fichier excel que j'ai réalisé qui vous permettra de le faire facilement: Calcul_Indemnites_Kilometrique_2010.xls

[MAJ des IK en avril 2011]
Ci-dessous le même fichier avec la MAJ du barème d'indice kilométrique faite par l'administatrion en avril 2011 Calcul_Indemnites_Kilometrique_2010_maj_2011-04.xls

[MAJ des IK en mars 2012]
La circulaire 5 f-5-12 de février 2012 ne change pas les données IK de 2010. J'ai cependant modifié le fichier Calcul_Indemnites_Kilometrique_2011.xls

[MAJ des IK en avril 2017]
Suite à la demande faite en commentaire, j'ai utilisé le Barème du site des Impôts 2017. Voici donc une version modifié Calcul_Indemnites_Kilometrique_2016-2017.xls

Comment utiliser cette feuille excel:
1) Mettre le nom de la société
2) Choisir le type de véhicule (choix liste)
3) Mettre le modèle de véhicule (pour information comptable)
4) Choisir la puissance fiscale (pour le moment pas de liste mettre 3 CV,4 CV,5 CV,6 CV,7 CV,8 CV,9 CV,10 CV,11 CV,12 CV,13 CV,Cyclo_Inf_50,Cyclo_1_2,Cyclo_3_4_5,Cyclo_Sup_5)
5) Indiquer la date de début d'année fiscale
6) Indiquer le nom et prénom de la personne
7) Remplir les cases NB KM pour chaque mois

Tuesday, February 15, 2011

Get / Determine / Check your ESX version, major version or build version

To check your esx version, use in command line:


vmware -v
return for example in a 3.0.1 ESX
VMware ESX Server 3.0.1 build-32039

vmware -v
return for example in a 3.5 ESX
VMware ESX Server 3.5.0 build-238493

vmware -v
return for example in a 4.1 ESX
VMware ESX 4.1.0 build-260247



But If you need to know only version use

vmware -v | awk -F "uild" '{print $1}' | sed -e 's/[A-Za-z ]//g'

return in our 3 examples
3.0.1
3.5.0
4.1.0


In your script you can use this information into a variable

ESX_VERSION=`vmware -v | awk -F "uild" '{print $1}' | sed -e 's/[A-Za-z ]//g'`
echo $ESX_VERSION

return in our 3 examples
3.0.1
3.5.0
4.1.0




To know major version only

vmware -v | awk -F "uild" '{print $1}' | sed -e 's/[A-Za-z ]//g' | cut '-d.' -f1

return in our 3 examples
3
3
4


To know major and minor version only

vmware -v | awk -F "uild" '{print $1}' | sed -e 's/[A-Za-z ]//g' | awk -F "." '{print $1"."$2}'

return in our 3 examples
3.0
3.5
4.1


If you need to know build only

vmware -v | awk -F "uild-" '{print $2}'

return in our 3 examples
32039
238493
260247

Wednesday, February 9, 2011

Powershell to help you to sort, manipulate or consolidate CSV file

To help you to sort, manipulate or consolidate your information, Powershell is a very interesting tool.

First, you need a .csv file with this format (use excel file save as)


col1,col2,col3
c,cc,ccc
a,aa,aaa
b,bb,bbb
c,cc,ccc
b,bb,bbb


For example, to select only one column, just use colum name

Import-Csv .\test.csv | select col2



col2
----
cc
aa
bb
cc
bb


If your .CSV has ";" and not "," as delimiter you can change this by adding -Delimiter switch like that


Import-Csv .\test.csv -Delimiter ";" | select col2

(Warning: This switch does not work on Powershell 1.0)

Moreover, be sure to have a header else you will have a error
Import-Csv : The member "xxxx" is already present
And do not forget # is considered as a remark

Now, if you only need distinct col2 use -unique switch and Sort-object if you need to have only distinct field

Import-Csv .\test.csv | select -unique col2 | Sort-Object col2



col2
----
aa
bb
cc


To display each line with column 3 then column 1 then column 2 you can do like this

$content = import-csv ".\test.csv"
foreach ($line in $content) {
write-host $line.col3 $line.col2 $line.col1
}


result:

ccc c cc
aaa a aa
bbb b bb
ccc c cc
bbb b bb


or like this:

Import-Csv .\test.csv | select col3, col1, col2


result:

col3 col1 col2
---- ---- ----
ccc c cc
aaa a aa
bbb b bb
ccc c cc
bbb b bb


Or like this:

$Content = Get-Content ".\test.csv"
$arrLine = @( )
Foreach ($line in $Content) {
$line =$line.Trim()
If ($line.length -gt 0) {
$arrLine=$line.split(",")
write-host $arrLine[2] $arrLine[0] $arrLine[1]
}
}


result:

col3 col1 col2
ccc c cc
aaa a aa
bbb b bb
ccc c cc
bbb b bb

Tuesday, January 25, 2011

Register all VM to a new ESX host

A standalone ESX has been reinstalled. All VM are on a shared storage.
I registered all VM with this following command:


find /vmfs/volumes -name "*.vmx" | xargs -i{} vmware-cmd -s register {}


For information, you can replace xargs -I{} by xargs -i{} for certain esx version

Friday, January 14, 2011

HP Virtual Connect Blank page problem

Some elements of your HP Virtual Connect didn't work anymore like "Ethernet Networks" ?
Do you have a blank page ?
If your are in a secure environment where only port 443 is opened, try to open port 80. It seems that flash player in some VC version only work on this port

Before (only port 443 opened)















After (Port 80 and 443 opened)

Monday, January 3, 2011

Unregister all VM in a ESX host

Problem with an old ESX v3.0.2. All VM have been stopped. I must unregister all VM from this ESX. So I use replace-str xargs option like this:

vmware-cmd -l | xargs -i{} vmware-cmd -s unregister {}


You can stop / start / suspend / reset all VM using the same tip:

vmware-cmd -l | xargs -i{} vmware-cmd {} stop
vmware-cmd -l | xargs -i{} vmware-cmd {} start
vmware-cmd -l | xargs -i{} vmware-cmd {} suspend
vmware-cmd -l | xargs -i{} vmware-cmd {} reset


For information, you can replace xargs -I{} by xargs -i{} for certain esx version