Ok I got the script working. Here it is, hope it's not looking too bad
#$vcenter = Read-Host 'enter vcenter server name'
$theVM = Read-Host 'enter the VM name'
$ESX = get-vmhost -VM $theVM
$vCluster = Get-Cluster -VMHost $ESX
$path = "C:\PS\"
Connect-VIServer $vcenter
$RDMs = get-vm -name $theVM | get-harddisk -disktype "RawPhysical","RawVirtual" | select scsicanonicalname,name | Export-Csv "$path\scsiCN.csv" -NoTypeInformation
sleep -Seconds 2
#$RDMs | Export-Csv "$path\scsiCN.csv" -NoTypeInformation
$scsiCN = Import-Csv "$path\scsiCN.csv" -UseCulture | select -ExpandProperty ScsiCanonicalName
Foreach($CN in $scsiCN){
$storSys = Get-View -Id $ESX.ExtensionData.ConfigManager.StorageSystem
[string]$hdname = Get-VM -Name $theVM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | Where-Object {$_.ScsiCanonicalName -eq $CN} | select -ExpandProperty name
[string]$newname = $theVM,$hdname
Get-ScsiLun -VMHost $ESX -LUNType disk -CanonicalName $CN | %{
$storSys.UpdateScsiLunDisplayName($_.ExtensionData.Uuid,$newname)
}
}
Starting from the VM name it gets all necessary info to rename the RDM display name with VM name + HD number. I'll see now if I can also add the Windows drive letter. However I'm still worried to run it on large scale for the reasons above. I'd better have a device without a label than a device incorrectly labelled. Any insight?