====== PowerCLI - Gestion des snapshots ======
===== Prérequis =====
Voir [[informatique:vmware:powercli_installation|PowerCLI - Installation]]
Se connecter au vCenter ou à un ESXi en PowerCLI.
===== Récupération de la liste des snapshots =====
Cela se fait comme ceci : ''Get-VM | Get-Snapshot''
Voici les informations que l'on peut récupérer :
PS C:\Users\utilisateur> Get-VM | Get-Snapshot | gm
TypeName: VMware.VimAutomation.ViCore.Impl.V1.VM.SnapshotImpl
Name MemberType Definition
---- ---------- ----------
ConvertToVersion Method T VersionedObjectInterop.ConvertToVersion[T]()
Equals Method bool Equals(System.Object obj)
GetClient Method VMware.VimAutomation.ViCore.Interop.V1.VIAutomation VIObjectCoreInterop.GetClient()
GetHashCode Method int GetHashCode()
GetType Method type GetType()
IsConvertableTo Method bool VersionedObjectInterop.IsConvertableTo(type type)
LockUpdates Method void ExtensionData.LockUpdates()
ToString Method string ToString()
UnlockUpdates Method void ExtensionData.UnlockUpdates()
Children Property VMware.VimAutomation.ViCore.Types.V1.VM.Snapshot[] Children {get;}
Created Property datetime Created {get;}
Description Property string Description {get;}
ExtensionData Property System.Object ExtensionData {get;}
Id Property string Id {get;}
IsCurrent Property bool IsCurrent {get;}
IsReplaySupported Property bool IsReplaySupported {get;}
Name Property string Name {get;}
Parent Property VMware.VimAutomation.ViCore.Types.V1.VM.Snapshot Parent {get;}
ParentSnapshot Property VMware.VimAutomation.ViCore.Types.V1.VM.Snapshot ParentSnapshot {get;}
ParentSnapshotId Property string ParentSnapshotId {get;}
PowerState Property VMware.VimAutomation.ViCore.Types.V1.Inventory.PowerState PowerState {get;}
Quiesced Property bool Quiesced {get;}
SizeGB Property System.Nullable[decimal] SizeGB {get;}
SizeMB Property decimal SizeMB {get;}
Uid Property string Uid {get;}
VM Property VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine VM {get;}
VMId Property string VMId {get;}
PS C:\Users\utilisateur>
Exemple sur la manière de récupérer des informations (j'ai choisi d'afficher la taille en Go et en Mo) :
PS C:\Users\utilisateur> Get-VM | Get-Snapshot | Select-Object VM, Name, created, description, sizegb, sizemb | fl
VM : ma-vm
Name : ma-vm
Created : 24/09/2019 11:42:43
Description : 24/09/2019
SizeGB : 7,2370182769373059272766113281
SizeMB : 7410,70671558380126953125
PS C:\Users\utilisateur> Get-VM | Get-Snapshot | Select-Object VM, Name, created, description, sizegb, sizemb | ft
VM Name Created Description SizeGB SizeMB
-- ---- ------- ----------- ------ ------
ma-vm ma-vm 24/09/2019 11:42:43 24/09/2019 7,2370182769373059272766113281 7410,70671558380126953125
PS C:\Users\utilisateur>
Il est possible ensuite d'exporter ces informations en CSV par exemple, de supprimer les snapshots, etc...
D'autres exemples viendront sur cette page par la suite.
{{tag> VMware Virtualisation PowerShell PowerCLI Snapshot }}