Sometimes it is just good to have all the network names of your VDI and IP. This will get the VM name, network adapter, network name defined in vSphere, and IP.
# Script to get network names for VDI machines. This was tested with VMware 7.x, Citrix Cloud connection configured with the "default" profile, and VDI with single NIC.
asnp Citrix*
Get-XDAuthentication -ProfileName "default"
$date = Get-Date -Format MMddyyyy
$report = @()
$CurrentItem = 0
$PercentComplete = 0
$ctxVDI = (Get-BrokerMachine -MaxRecordCount 100000 | Where-Object SessionSupport -eq "SingleSession" | Where-Object HostedMachineName -ne $null | Select-Object HostedMachineName).HostedMachineName
$totalItems = ($ctxVDI).count
foreach($ctx in $ctxVDI){
Write-Progress -Activity "Getting network name for $ctx" -Status "$PercentComplete% Complete:" -PercentComplete $PercentComplete
$line = "" | Select-Object VM, Name, NetworkName, IPAddress
$networkInfo = (Get-VM $ctx | Get-NetworkAdapter)
$ipAddress = (Get-VM $ctx | Select-Object @{N="IPAddress";E={@($_.guest.IPAddress[0])}})
if($networkInfo -ne $null){
$line.VM = $ctx
$line.Name = $networkInfo.Name
$line.NetworkName = $networkInfo.NetworkName
$line.IPAddress = ($ipAddress).IPAddress
}
$report += $line
$CurrentItem++
$PercentComplete = [int](($CurrentItem / $TotalItems) * 100)
}
$report | export-csv c:\scripts\logs\$date-vdinetworks.csv -NoTypeInformation -Append