Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
LinuxWindows
Ce document explique comment obtenir l'identifiant unique universel (UUID) d'une instance de machine virtuelle (VM) à l'aide d'un outil spécifique au système d'exploitation de la VM.
Chaque VM possède un UUID ayant les propriétés suivantes :
Ce service est unique parmi les VM de Compute Engine.
Il est généré à partir de l'ID du projet, de la zone et du nom de la VM.
Il est stable pendant la durée de vie de la VM. Si la VM est supprimée et recréée dans le même projet et la même zone, avec le même nom, la VM reçoit le même UUID.
Les UUID ne sont disponibles que pour les VM créées à compter du 30 octobre 2014. Si vous avez créé une VM avant cette date, recréez la VM pour que Compute Engine puisse lui attribuer un UUID.
Utiliser les outils du système d'exploitation pour obtenir l'UUID d'une VM
Pour obtenir l'UUID d'une VM, exécutez la commande correspondant au système d'exploitation de la VM :
Linux
À partir de la VM Linux, exécutez la commande dmidecode suivante :
sudo dmidecode -t system | grep UUID
Vérifiez que vous obtenez une réponse semblable à la suivante :
UUID: 3748eb17-a207-5bc3-aa4f-3113a1b9409d
Invite de commande Windows (cmd.exe)
À partir de l'invite de commande sur la VM Windows, exécutez la commande wmic suivante :
wmic path win32_computersystemproduct get uuid
Vérifiez que vous obtenez une réponse semblable à la suivante :
Vérifiez que vous obtenez une réponse semblable à la suivante :
81CBB42C-73A0-9660-6C7D-2FE94627F3A3
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/05/29 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/05/29 (UTC)."],[[["\u003cp\u003eThis guide provides instructions on how to retrieve the Universally Unique Identifier (UUID) of a virtual machine (VM) instance using operating system-specific tools.\u003c/p\u003e\n"],["\u003cp\u003eEach Compute Engine VM has a unique and stable UUID, which is generated from the VM's project ID, zone, and name, and remains consistent throughout the VM's lifetime.\u003c/p\u003e\n"],["\u003cp\u003eFor Linux VMs, you can use the \u003ccode\u003edmidecode\u003c/code\u003e command to obtain the UUID, while for Windows VMs, you can use either the \u003ccode\u003ewmic\u003c/code\u003e command in the Command Prompt or a Windows Management Instrumentation (WMI) command in PowerShell.\u003c/p\u003e\n"],["\u003cp\u003eVMs created before October 30, 2014, do not have UUIDs and will require recreation to be assigned one.\u003c/p\u003e\n"]]],[],null,["# Get the UUID of a VM\n\nLinux Windows\n\n*** ** * ** ***\n\nThis document shows you how to get the universally unique identifier (UUID) of a\nvirtual machine (VM) instance by using a tool that is specific to the VM's\noperating system.\n\nEach VM has a UUID that has the following properties:\n\n- It is unique among Compute Engine VMs.\n\n- It is generated from the VM's project ID, zone, and name.\n\n- It is stable for the lifetime of the VM. If the VM is deleted and\n recreated in the same project, zone, and with the same name, the VM receives\n the same UUID.\n\nUUIDs are only available for VMs created on or after October 30, 2014. If you\nhave a VM created before that date, recreate the VM so Compute Engine\ncan assign it a UUID.\n\nUse operating system tools to get the UUID of a VM\n--------------------------------------------------\n\nTo get the UUID of a VM, run the command that corresponds to the VM's\noperating system: \n\n### Linux\n\n1. From the Linux VM, run the following\n [`dmidecode`](http://www.nongnu.org/dmidecode/) command:\n\n ```\n sudo dmidecode -t system | grep UUID\n ```\n2. Verify a response similar to the following:\n\n ```\n UUID: 3748eb17-a207-5bc3-aa4f-3113a1b9409d\n ```\n\n### Windows (Cmd.exe)\n\n1. From the Command Prompt on the Windows VM, run the following\n [`wmic`](https://docs.microsoft.com/windows/win32/wmisdk/wmic) command:\n\n ```\n wmic path win32_computersystemproduct get uuid\n ```\n2. Verify a response similar to the following:\n\n ```\n UUID\n 81CBB42C-73A0-9660-6C7D-2FE94627F3A3\n ```\n\n### Windows (PowerShell)\n\n1. From PowerShell, run the following [Windows Management Instrumentation (WMI)](https://docs.microsoft.com/powershell/scripting/learn/ps101/07-working-with-wmi) command:\n\n ```\n (Get-WmiObject -Class Win32_ComputerSystemProduct).UUID\n ```\n2. Verify a response similar to the following:\n\n ```\n 81CBB42C-73A0-9660-6C7D-2FE94627F3A3\n ```"]]