#Create the tenant instance. This is just to ensure that there the below objects doesnt get dropped if tenant is already discovered.
#The parameters will be filled when tenant discovery happens next time.
$rd = $discoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.RemoteAccess.Multitenant.2012.R2.Class.Tenant']$")
$rd.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $computerName)
$rd.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $routingDomain.ToString())
$rd.AddProperty("$MPElement[Name='Microsoft.Windows.RemoteAccess.Multitenant.2012.R2.Class.Tenant']/ServerName$", $computerName)
$rd.AddProperty("$MPElement[Name='Microsoft.Windows.RemoteAccess.Multitenant.2012.R2.Class.Tenant']/TenantName$", $routingDomain)
$rd.AddProperty("$MPElement[Name='Microsoft.Windows.RemoteAccess.Multitenant.2012.R2.Class.Tenant']/RoutingDomain$", $routingDomain)
$rd.AddProperty("$MPElement[Name='Microsoft.Windows.RemoteAccess.Multitenant.2012.R2.Class.Tenant']/RoutingDomainID$", $routingDomainID)
$rd.AddProperty("$MPElement[Name='Microsoft.Windows.RemoteAccess.Multitenant.2012.R2.Class.RemoteAccessServer']/ServerName$", $computerName)
$discoveryData.AddInstance($rd)
#Creating VPN group instance for this site
$vpnGroup = $discoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.RemoteAccess.Multitenant.2012.R2.Class.VPN']$")
$vpnGroup.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $computerName)
$vpnGroup.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "VpnConnections (" + $routingDomain + ")")
$vpnGroup.AddProperty("$MPElement[Name='Microsoft.Windows.RemoteAccess.Multitenant.2012.R2.Class.TenentComponents']/ServerName$", $computerName)
$vpnGroup.AddProperty("$MPElement[Name='Microsoft.Windows.RemoteAccess.Multitenant.2012.R2.Class.TenentComponents']/TenantName$", $routingDomain)
$vpnGroup.AddProperty("$MPElement[Name='Microsoft.Windows.RemoteAccess.Multitenant.2012.R2.Class.TenentComponents']/RoutingDomain$", $routingDomain)
$vpnGroup.AddProperty("$MPElement[Name='Microsoft.Windows.RemoteAccess.Multitenant.2012.R2.Class.TenentComponents']/RoutingDomainID$", $routingDomainID)