Notification

Icon
Error

Virtual machines and their host

Posted: Tuesday, January 22, 2019 10:37:31 AM(UTC)
Esben.D

Esben.D

Member Administration Original PosterPosts: 1,956
4
Like
The report below will show all virtual machines and their hosts.


The report will only list assets that meet all of the following criteria:
  • You are running Lansweeper 7
  • The asset state is set to active.
  • Your ESXi hosts are directly scanned or via vCenter scanning
Code:
Select Distinct Top 1000000 tblAssets.AssetID,
  tblAssets.AssetName,
  tsysAssetTypes.AssetTypename,
  tblVmwareGuest.Ipv4Address,
  tblAssets1.AssetName As Host,
  tblAssets1.IPAddress As HostIP,
  tblAssets.Lastseen,
  tblAssets.Lasttried,
  tsysAssetTypes.AssetTypeIcon10 As icon
From tblAssets
  Inner Join tblVmwareGuest On tblAssets.AssetID = tblVmwareGuest.AssetID
  Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
  Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
  Inner Join tblState On tblState.State = tblAssetCustom.State
  Left Join tblVmwareInfo On tblVmwareGuest.HostID = tblVmwareInfo.VmwareID
  Left Join tblAssets tblAssets1 On tblAssets1.AssetID = tblVmwareInfo.AssetID
Where tblState.Statename = 'Active'
Order By tblVmwareGuest.Ipv4Address,
  tblAssets.AssetName
RayHeathTSS
#1RayHeathTSS Member Posts: 5  
posted: 2/22/2019 6:00:01 PM(UTC)
This only returned VMWare Guests and Hosts.

Can this be easily modified to also include HyperV?
Jack of All Trades
#2Jack of All Trades Member Posts: 4  
posted: 2/25/2019 1:56:40 PM(UTC)
I would also appreciate report for HyperV hosts.
ajokerst
#3ajokerst Member Posts: 6  
posted: 3/6/2019 7:57:44 PM(UTC)
I would also like the Hyper-V report
b.c
#4b.c Member Posts: 1  
posted: 3/28/2019 9:14:29 PM(UTC)
Add another that would like to see a Hyper-V report for hosts and associated guests.
klaus
#5klaus Member Posts: 14  
posted: 9/17/2019 8:44:57 AM(UTC)
Code:
Select Distinct Top 1000000 tblAssets.AssetID,
  tblAssets.AssetName,
  tsysAssetTypes.AssetTypename,
  tblVmwareGuest.Ipv4Address,
  case when tblAssets1.AssetName is not null then tblAssets1.AssetName else hvasset.assetname end As Host,
  case when tblAssets1.IPAddress is not null then tblAssets1.IPAddress else hvasset.IPAddress end As HostIP,
  case when tblassets1.assetname is not null then 'VMware' else 'HyperV' end as Type,
  tblAssets.Lastseen,
  tblAssets.Lasttried,
  tsysAssetTypes.AssetTypeIcon10 As icon
From tblAssets
  left outer Join tblVmwareGuest On tblAssets.AssetID = tblVmwareGuest.AssetID
  Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
  Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
  Inner Join tblState On tblState.State = tblAssetCustom.State
  Left Join tblVmwareInfo On tblVmwareGuest.HostID = tblVmwareInfo.VmwareID
  Left Join tblAssets tblAssets1 On tblAssets1.AssetID = tblVmwareInfo.AssetID
  OUTER apply
      (SELECT        TOP 1 *
       FROM            tblhypervguest js
       WHERE        js.Name = tblassets.AssetName
       ORDER BY js.Lastchanged DESC) js
  left outer join tblassets AS hvasset ON hvasset.AssetID = js.AssetID 
Where tblState.Statename = 'Active' and ( hvasset.assetid is not null or tblAssets1.assetid is not null)
Order By tblVmwareGuest.Ipv4Address,
  tblAssets.AssetName
The Techguy
#6The Techguy Member Posts: 1  
posted: 11/21/2019 7:48:22 PM(UTC)
When I try to save this I get, Invalid "SELECT" statement. Unexpected token "OUTER" at line 18, pos 3. Any ideas how to fix this? This seems like a good report for my Hyper-V clusters.

Active Discussions

Lansweeper iManage Client deployment
by  CyberCitizen   Go to last post Go to first unread
Last post: Today at 3:09:47 AM(UTC)
Lansweeper Missing hyperv host details for guest asset LAN-4130
by  danielm  
Go to last post Go to first unread
Last post: 12/7/2019 7:15:56 AM(UTC)
Lansweeper Lansweeper showing MAC address instead of name
by  crashff   Go to last post Go to first unread
Last post: 12/6/2019 10:26:25 PM(UTC)
Lansweeper Dell Warranty Lookup - Incorrect Information
by  Trenton Knew  
Go to last post Go to first unread
Last post: 12/6/2019 10:17:15 PM(UTC)
Lansweeper Incoming Email Parse
by  UEFT   Go to last post Go to first unread
Last post: 12/6/2019 5:46:22 PM(UTC)
Lansweeper SSH - Keyboard Interactive Authentication
by  KevinA-REJIS  
Go to last post Go to first unread
Last post: 12/6/2019 5:22:21 PM(UTC)
Lansweeper Custom OID Scanning / multible OIDs with wildcards
by  Esben.D  
Go to last post Go to first unread
Last post: 12/6/2019 11:57:18 AM(UTC)