VMware Cloud Community
fborges555
Enthusiast
Enthusiast

List VDI hostname and username

HI gurus

I am looking to get a list of VDI from a folder and brin the following information:

VDI name(Name-xxx) , IP address of the VDI and the username

I have so far this but got stuck.

"get-folder Folder | get-vm | select name,@{N="IP";E={@($_.Guest.IPAddress)}}", this brings the VDI name and the IP address but I can't find how to bring the username assigned to this machines

 

Thanks for any help

 

0 Kudos
3 Replies
fabio1975
Commander
Commander

Ciao 

When you talk about VDI do you mean virtual machines assigned to a Horizon infrastructure? So you need to know which users are assigned via Horizon to that VM?

Fabio

Visit vmvirtual.blog
If you're satisfied give me a kudos

0 Kudos
fborges555
Enthusiast
Enthusiast

Fabio.

 

You are correct, Horizon , VDI machine name, ip and user assigned to that VDI

 

Thanks

 

0 Kudos
fabio1975
Commander
Commander

Ciao 

try this script

#####

$User = Get-Credential
$VMFolder = "<FolderofVM>"
$vcenterserver = "<FQDNvCenter>"
$connectionServer = "<FQDNConnectionServer>"
$ExportFilePath = "c:\temp\Export-VMInfo.csv"
Connect-ViServer $vcenterserver -Credential $User
Connect-HvServer -server $connectionServer -User <domain\user> -Password <password>
$Report = @()
$VMs = Get-Folder $VMFolder | Get-VM
ForEach ($VM in $VMs) {
    $VMInfo = {} | Select VMName,IPAddress,UserHorizon
    $VMInfo.VMName = $vm.name
    $VMInfo.IPAddress = $vm.Guest.IPAddress[0]
    $HVM = get-hvmachinesummary -MachineName $VM | Select-Object @{Name='User';Expression={$_.NamesData.Username}}
    $VMInfo.UserHorizon = $HVM.User
    $Report += $VMInfo
}
$Report = $Report | Sort-Object VMName
IF ($Report -ne "") {
$report | Export-Csv $ExportFilePath -NoTypeInformation
}
######
 
For install of Horizon Powercli (Connect-HvServer and get-hvmachinesummary)  check this link 
Set Up the Horizon PowerCLI Module (vmware.com)

Fabio

Visit vmvirtual.blog
If you're satisfied give me a kudos

0 Kudos