Solved

Map AHV VM Drives to OS


Badge +1

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.

icon

Best answer by Kcmount 3 July 2022, 10:29

View original

This topic has been closed for comments

2 replies

Badge +1

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 [int]}}

    }

}

Foreach ($NutanixDrivesGuid in $NutanixDrivesGuids){

 

        Foreach ($serverresult in $ServerResults){

            $SeralNumber = $serverresult.SerialNumber.Split('_')[4] + '-' +$serverresult.SerialNumber.Split('_')[5] + '-' +$serverresult.SerialNumber.Split('_')[6] + '-' + $serverresult.SerialNumber.Split('_')[7] + '-' + $serverresult.SerialNumber.Split('_')[8]

            IF ( $SeralNumber -eq $NutanixDrivesGuid){

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

                DriveNumber = $serverresult.Index

                DriveSize = $serverresult.SizeGB

                NutanixGuid = $NutanixDrivesGuid

                DriveSeralNumber = $serverresult.SerialNumber

                Computername = $serverresult.PSComputerName

                }

                [array]$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.

Userlevel 4
Badge +6

Hi there,

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

This should help with: acli vm.disk_update