# ESXI notes
## Enable SSH
https://phoenixnap.com/kb/esxi-enable-ssh
## Liste des commandes utiles en CLI :
Obtenir la version de ESXI
```shell
esxcli system version get
```
## VM
lister les VM
```
# tout les vm
vim-cmd vmsvc/getallvms
# les vm allumées
esxcli vm process list
```
Allumer une VM:
```shell
vim-cmd vmsvc/power.on {VMid}
```
Eteindre une VM
```shell
vim-cmd vmsvc/power.off {VMid}
# forcer l'arrêt soft
esxcli vm process kill -t soft -w {wID}
# forcer l'arrêt force (en dernier recours)
esxcli vm process kill -t force -w {wID}
```
Reboot une VM
```shell
vim-cmd vmsvc/power.reboot {VMid}
```
Supprimer tout les Snapshots d'une VM
```shell
vim-cmd vmsvc/snapshot.removeall {VMid}
```
Détails d'une VM
```shell
vim-cmd vmsvc/get.summary {VMid}
```
## Configuration réseau
### Groupe de ports
Lister les groupes de ports
```shell
esxcli network vswitch standard portgroup list
```
Ajouter un groupe de ports
```shell
esxcli network vswitch standard portgroup add -p "Nom du groupe de port" -v vSwitch0
```
### NIC physiques
Avoir la liste des interfaces réseau physique
```shell!
esxcli network nic list
```
Obtenir la configuration
```shell
esxcli network nic get -n vmnic
```
### vSwitch
Créer un vSwitch:
```shell
esxcli network vswitch standard add -v vSwitch1
```
Ajouter une interface physique à un groupe de ports
```shell
esxcli network vswitch standard portgroup policy failover set -a vmnic0,vmnic1 -p LAN
```
#### VMkernel
liste les interfaces VMkernel
```shell
esxcli network ip interface list
```
Liste des adresses IPv4 attribuées aux interfaces VMkernel
```shell
esxcli network ip interface ipv4 get
```
Ajouter une nouvelle interface VMkernel
```shell
esxcli network ip interface add -p "Nom du groupe de ports"
```
Définir l’IP statique d’une interface VMkernel:
```shell
esxcli network ip interface ipv4 set -i vmk1 -I 10.40.1.1 -N 255.255.255.0 -t static
```
Passer en DHCP une interface VMkernel:
```shell
esxcli network ip interface ipv4 set -i vmk1 -t dhcp
```
Logs de VMkernel
```shell
cat /var/log/vmkernel.log
```
#### VMDK , VMX
Lister les VMDK
```shell
find /vmfs/volumes/ -name *.vmdk
```
Lister les VMX
```shell
find /vmfs/volumes/ -name *.vmx
```
#### Fichiers de machine virtuelle

Source :
http://www.menaud.fr/Cours/Cloud/TP/support/cmd-esxi.html<br>
https://docs.vmware.com/fr/VMware-vSphere/index.html<br>
https://vdc-download.vmware.com/vmwb-repository/dcr-public/26334f54-ee84-47c2-b2f3-901f51cbc98a/d3f55719-4d3f-47c4-a3c5-fe9c7e5a67f6/doc/esxcli_network.html