var numArgs = $.Arguments.Count();
// ParseToInt
var siteType = numArgs > 4 ? parseInt($.Arguments(4)) : undefined;
var siteDef, relationship;
// Create SiteInstance
// this siteType come from registry (1:Primary, 2:Secondary, 8:CAS)
switch (siteType) {
case 1:
siteDef = data.CreateClassInstance("$MPElement[Name='MECM.PrimarySite']$");
break;
case 2:
siteDef = data.CreateClassInstance("$MPElement[Name='MECM.SecondarySite']$");
break;
case 4:
case 8:
siteDef = data.CreateClassInstance("$MPElement[Name='MECM.CentralSite']$");
break;
}
siteDef.AddProperty("$MPElement[Name='MECM.Site']/SiteServer$", sccm.SiteServer);
// Find ChildSites
sccm("SMS_Site").Where("Status != 4 AND ReportingSiteCode = '" + sccm.SiteCode + "'").each(function () {
var endPoint;
var siteCode = this.SiteCode;
var parentSite = this.ReportingSiteCode;
var serverFqdn = sccm.SiteServer;
var isSP1 = this.buildnumber > 7711? "1" : "0";
//var isSP1 = "true";
switch (this.Type) {
case 1:
endPoint = data.CreateClassInstance("$MPElement[Name='MECM.ReplicationToSecondarySite']$");
break;
case 2:
endPoint = data.CreateClassInstance("$MPElement[Name='MECM.ReplicationToPrimarySite']$");
break;
}
// Display Name
endPoint.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", sccm.SiteCode + " - " + siteCode);
// Source Site
endPoint.AddProperty("$MPElement[Name='MECM.Replication']/SiteCode$", sccm.SiteCode);
// Destination Site
endPoint.AddProperty("$MPElement[Name='MECM.Replication']/TargetSiteCode$", siteCode);
// Site Server FQDN
endPoint.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $.Trim(serverFqdn, "/\\").toUpperCase());
// Is Site SP1 or not
endPoint.AddProperty("$MPElement[Name='MECM.Replication']/IsSP1$", isSP1);
// Find ParentSite
sccm("SMS_Site").Where("SiteCode = '" + sccm.SiteCode + "'").each(function () {
var endPoint;
var siteCode = this.SiteCode;
var parentSite = this.ReportingSiteCode;
var serverFqdn = sccm.SiteServer;
var isSP1 = this.buildnumber > 7711? "1" : "0";
//var isSP1 = "true";
if (parentSite != "")
{
switch (this.Type) {
case 1:
endPoint = data.CreateClassInstance("$MPElement[Name='MECM.ReplicationToPrimarySite']$");
break;
case 2:
endPoint = data.CreateClassInstance("$MPElement[Name='MECM.ReplicationToCentralSite']$");
break;
}
// Display Name
endPoint.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", sccm.SiteCode + " - " + parentSite);
// Source Site
endPoint.AddProperty("$MPElement[Name='MECM.Replication']/SiteCode$", sccm.SiteCode);
// Destination Site
endPoint.AddProperty("$MPElement[Name='MECM.Replication']/TargetSiteCode$", parentSite);
// Site Server FQDN
endPoint.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $.Trim(serverFqdn, "/\\").toUpperCase());
// Is Site SP1 or not
endPoint.AddProperty("$MPElement[Name='MECM.Replication']/IsSP1$", isSP1);
var serverQuery = $.Format("\
SELECT res.ServerRemoteName, res.ServerName FROM SMS_SystemResourceList as res \n\
WHERE res.SiteCode ='{0}' AND res.ServerRemoteName = '{1}' AND res.RoleName ='SMS Site System'", targetSiteCode, targetServerFqdn);
var isSiteSystem = false;
// Find all servers
sccm.Query(serverQuery, function () {
isSiteSystem = true;
});
var numArgs = $.Arguments.Count();
// ParseToInt
var siteType = numArgs > 4 ? parseInt($.Arguments(4)) : undefined;
var parentSiteCode = numArgs > 6 ? $.Arguments(6) : undefined;
var targetSiteCode = sccm.SiteCode;
var siteDef, relationship;
// only available for CAS and Standalone Primary
if ($.IsNullOrEmpty(parentSiteCode) == false)
{
return;
}
// Create SiteInstance
// this siteType come from registry (1:Primary, 2:Secondary, 8:CAS)
switch (siteType) {
case 1:
siteDef = data.CreateClassInstance("$MPElement[Name='MECM.PrimarySite']$");
break;
case 2:
siteDef = data.CreateClassInstance("$MPElement[Name='MECM.SecondarySite']$");
break;
case 4:
case 8:
siteDef = data.CreateClassInstance("$MPElement[Name='MECM.CentralSite']$");
break;
}
siteDef.AddProperty("$MPElement[Name='MECM.Site']/SiteServer$", sccm.SiteServer);
// Configuration Baselines
roleQuery = $.Format("\
SELECT al.Name, al.TypeID, al.TypeInstanceID from SMS_Alert as al \n\
WHERE al.TypeID = 14 \n\
AND al.MonitoredByScom = 1 \n\
AND (al.SourceSiteCode IS NULL OR al.SourceSiteCode='{0}')", targetSiteCode);
sccm.Query(roleQuery, function () {
var roleDef;
var typeId = this.TypeID;
var typeInstanceId = this.TypeInstanceID;
var alertName = this.Name;