How to Get DeviceID (example: C: ) on Hyper V Host in powershell? / Comment Obtenir le DeviceID (exemple : C: ou E:) d'une VM sur Hôte Hyper V en powershell ?

doikine 26 Reputation points
2022-09-16T15:48:30.607+00:00

Bonjour,

Comment Obtenir le DeviceID (exemple : C: ou E:) d'une VM sur Hôte Hyper V en powershell ?
How to Get DeviceID (example: C: ) of a VM on Hyper V Host in powershell?

Serait-il possible d'avoir de l'aide s'il vous plaît sur ce sujet, j'ai essayer différente méthode mais sans succès. Je n'arrive pas à obtenir le

DeviceID par rapport à son stockage

de chaque VM depuis un hôte Hyper-V en PowerShell.

Je ne peux pas non plus me connecter sur chaque VM et récupérer les informations. Merci par avance pour votre aide.


English


Hello, Could you please help me on this subject, I tried different method but without success. I can't get the

DeviceID compared to its storage

of each VM from a Hyper-V host in PowerShell.

I also can't login to each VM and retrieve the information. Thank you in advance for your help.

Windows for business | Windows Client for IT Pros | Storage high availability | Virtualization and Hyper-V
Windows for business | Windows Server | User experience | PowerShell
{count} votes

4 answers

Sort by: Most helpful
  1. Anonymous
    2022-09-27T06:39:27.453+00:00

    Hi doikin,

    Based on your request, I made the following analysis:

    1. Your need is to get the disk information on the server through the powershell tool;
    2. The commands for the disk are as follows:
      (1) Get the physical disk on the computer:
      get-physicaldisk
      This will show you some basic information about all the disks present on your computer.
      (2) Get the uniqueID of the physical disk on the computer:
      get-physicaldisk | select *
      This command can help you get the uniqueID of each disk while possibly the disk information on your computer, and the main difference between each disk depends on the uniqueid.
      (3) Get the device id of the disk on the computer:
      get-wmiobject -class win32_logicaldisk -computername computer name

    Best Regards,
    Xu Gu

    0 comments No comments

  2. doikine 26 Reputation points
    2022-09-29T18:00:07.423+00:00

    Hi @Anonymous ,

    thank you for your
    help but I think I asked the wrong question,
    so I modified to make it clearer :

     I am looking for when to retrieve the **deviceID of VMs** on *Hyper V* host in powershell.  
     Has anyone ever managed to do this in powershell?  
    

    Merci pour votre aide mais je pense que j'ai mal poser ma question,
    du coup j'ai modifier pour que se soit plus claire:

    Je cherche quand récupérer le deviceID des VMs sur hôte Hyper V en powershell.
    Est-ce que quelqu'un à déjà réussi à faire ça en powershell ?


  3. doikine 26 Reputation points
    2022-10-06T17:58:01.243+00:00

    thanks i will try to see if can get the devicid of my VMs with from a hyper-v host. I'll get back to you as soon as I test

    0 comments No comments

  4. doikine 26 Reputation points
    2022-10-25T22:12:41.85+00:00

    254104-win2012-1.jpg

    Hi @Anonymous

    It's still not what I'm looking for, I'm going to go for another solution, this one:

    • $ListeMonIp = Get-VM | Get-VMNetworkAdapter | Format-Table IPAddresses
    • foreach($ip in $ListeMonIp){
      • $password = ConvertTo-SecureString "Josue972" -AsPlainText -Force
      • $cred= New-Object System.Management.Automation.PSCredential ("$VM\Administrateur", $password )
    • Invoke-Command -ComputerName 192.168.152.133 -ScriptBlock {Get-CimInstance -Class Win32_LogicalDisk |
    • Select-Object -Property DeviceID, @{
    • label='UsedSpace'
    • expression={(($.Size - $.FreeSpace)/1GB).ToString('F2')}
      • }
    • } -Credential $cred

    on the other hand I do not yet know how to export the result of this command.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.