Map AHV VM Drives to OS | Nutanix Community
Skip to main content

I have started to code this but thought maybe someone might have already completed this. My issue is I have a windows server in AHV with 10 disk drives. When I get a call from my windows team to expand a drive they will give me the drive letter. However I cannot use that to map back to Nutanix AHV. So outside of coding a tool that will map these 2 systems is there a way to correlate what drive is what? I do not want to have to log into a VM every time I get this request if possible.

So maybe I will spark some conversation here. I have created the following code to map between the Nutanix system and the OS.

 

$PCServer = Read-host “What is the name or IP of the Prism Central server?”

$ServerName = Read-Host "What is the name of the server?"

Import-module Nutanix.Prism.Common, Nutanix.Prism.PS.Cmds

$NTNXcred = Get-Credential -Message "Credentials used to connect to Nutanix Prism. "

Connect-PrismCentral -Server $PCServer -UserName $NTNXcred.UserName -Password $NTNXcred.Password -AcceptInvalidSSLCerts -ForcedConnection

 

Get-vm -Name $ServerName | select-object -ExpandProperty nutanixVirtualDiskUuids -OutVariable NutanixDrivesGuids

 

$ServerResults = Invoke-Command -Credential $NTNXcred -ComputerName  $ServerName -ArgumentList $NutanixDrivesGuids -ScriptBlock {

 $SerialNumbers = $args

 Foreach ($seralNumber in $SerialNumbers){

 $SeralNumber = $seralNumber.Replace('-','_')  

    Get-WmiObject Win32_DiskDrive | Where-Object SerialNumber -like "*$SeralNumber"| select-object Index,SerialNumber, @{name='SizeGB';Expression={$_.size / 1GB -as iint]}}

    }

}

Foreach ($NutanixDrivesGuid in $NutanixDrivesGuids){

 

        Foreach ($serverresult in $ServerResults){

            $SeralNumber = $serverresult.SerialNumber.Split('_')u4] + '-' +$serverresult.SerialNumber.Split('_')u5] + '-' +$serverresult.SerialNumber.Split('_')u6] + '-' + $serverresult.SerialNumber.Split('_')u7] + '-' + $serverresult.SerialNumber.Split('_')u8]

            IF ( $SeralNumber -eq $NutanixDrivesGuid){

                $DriveInfo = New-Object -TypeName psobject -Property @{

                DriveNumber = $serverresult.Index

                DriveSize = $serverresult.SizeGB

                NutanixGuid = $NutanixDrivesGuid

                DriveSeralNumber = $serverresult.SerialNumber

                Computername = $serverresult.PSComputerName

                }

                aarray]$Drives = $Drives + $DriveInfo

            }

        }


 

}

$Drives | Out-GridView

 

I cannot seem to find anything on the Nutanix side that can either give me the file path of the drive in Nutanix or a way to expand the drive programmatically. 

 

Any help here would be greatly appreciated.


Hi there,

Take a look at: Common VM disk management workflows on AHV cluster

This should help with: acli vm.disk_update