Thank you
hadi@ithoqto.com.au for a "GREAT" help and hints. I make the change on the file with additional functions. Unforturenaly, there is a limitation or bugs that I cannot figure it out. I understand SC might not be happy because someone modified their extension. Sorry for that but people seem to need it. Anyway, the bugs or limitation is if you have two values fall into the same "Property", it doesn't display on the Info tab. Ex, if you have two HDDs, IPv4+IPv6 or two anti-virus programs. it will not display at all.
hadi@ithoqto.com.au told me he got it working on his site. I found out that if you are using Microsoft Edge, it will not display two values. If you are using Google Chrome, it works fine.
ONLY WORK WITH Windows 8 or above. Windows 7, Windows Server doesn't have Powershell command "Get-PhysicalDisk"
extension - Additional General Information
Here are the code and you can replace this: C:\Program Files (x86)\ScreenConnect\App_Extensions\d55008eb-fe3b-4285-a45c-b16d78156530\NewInitializer.js
After you replace the code, you need to "DISABLE" and "ENABLE" the extension - Additional General Information
var hasSentCommand = false;
SC.event.addGlobalHandler(SC.event.InitializeTab, function (eventArgs) {
if (isGeneralTab(eventArgs.tabName)){
hasSentCommand = false;
//var descriptionList = SC.ui.findDescendentByTag(eventArgs.container, "dl");
var descriptionList = eventArgs.container.firstChild;
SC.ui.addElement(descriptionList, 'dt', {id: 'modelContainer', innerHTML: 'Model :'});
SC.ui.addElement(descriptionList, 'dd', {id: 'modelValueContainer'});
SC.ui.addElement(descriptionList, 'dt', {id: 'manufacturerContainer', innerHTML: 'Manufacturer:'});
SC.ui.addElement(descriptionList, 'dd', {id: 'manufacturerValueContainer'});
SC.ui.addElement(descriptionList, 'dt', {id: 'biosNameContainer', innerHTML: 'BIOS Name:'});
SC.ui.addElement(descriptionList, 'dd', {id: 'biosNameValueContainer'});
SC.ui.addElement(descriptionList, 'dt', {id: 'biosSerialContainer', innerHTML: 'BIOS Serial:'});
SC.ui.addElement(descriptionList, 'dd', {id: 'biosSerialValueContainer'});
//SC.ui.addElement(descriptionList, 'dt', {id: 'BiosAgeContainer', innerHTML: 'BIOS Age:'});
//SC.ui.addElement(descriptionList, 'dd', {id: 'BiosAgeValueContainer'});
//SC.ui.addElement(descriptionList, 'dt', {id: 'domainNameContainer', innerHTML: 'Domain:'});
//SC.ui.addElement(descriptionList, 'dd', {id: 'domainNameValueContainer'});
//SC.ui.addElement(descriptionList, 'dt', {id: 'DHCPEnabledContainer', innerHTML: 'DHCP Enabled:'});
//SC.ui.addElement(descriptionList, 'dd', {id: 'DHCPEnabledValueContainer'});
//SC.ui.addElement(descriptionList, 'dt', {id: 'DHCPServerContainer', innerHTML: 'DHCP Server:'});
//SC.ui.addElement(descriptionList, 'dd', {id: 'DHCPServerValueContainer'});
//SC.ui.addElement(descriptionList, 'dt', {id: 'defaultGatewayContainer', innerHTML: 'Default Gateway:'});
//SC.ui.addElement(descriptionList, 'dd', {id: 'defaultGatewayValueContainer'});
SC.ui.addElement(descriptionList, 'dt', {id: 'mediaFriendlyNameContainer', innerHTML: 'HDD Brand:'});
SC.ui.addElement(descriptionList, 'dd', {id: 'mediaFriendlyNameValueContainer'});
SC.ui.addElement(descriptionList, 'dt', {id: 'mediaSerialNumberContainer', innerHTML: 'HDD SN#:'});
SC.ui.addElement(descriptionList, 'dd', {id: 'mediaSerialNumberValueContainer'});
SC.ui.addElement(descriptionList, 'dt', {id: 'mediaSizeContainer', innerHTML: 'HDD Size (bytes):'});
SC.ui.addElement(descriptionList, 'dd', {id: 'mediaSizeValueContainer'});
SC.ui.addElement(descriptionList, 'dt', {id: 'mediatypeContainer', innerHTML: 'HDD Type:'});
SC.ui.addElement(descriptionList, 'dd', {id: 'mediatypeValueContainer'});
SC.ui.addElement(descriptionList, 'dt', {id: 'mediaHealthStatusContainer', innerHTML: 'HDD Health:'});
SC.ui.addElement(descriptionList, 'dd', {id: 'mediaHealthStatusValueContainer'});
SC.ui.addElement(descriptionList, 'dt', {id: 'mediaPredictFailureContainer', innerHTML: 'HDD Predict Failure:'});
SC.ui.addElement(descriptionList, 'dd', {id: 'mediaPredictFailureValueContainer'});
SC.ui.addElement(descriptionList, 'dt', {id: 'antivirusContainer', innerHTML: 'Antivirus:'});
SC.ui.addElement(descriptionList, 'dd', {id: 'antivirusValueContainer'});
SC.ui.addElement(descriptionList, 'dt', {id: 'internalIPAddressContainer', innerHTML: 'Internal IP Address:'});
SC.ui.addElement(descriptionList, 'dd', {id: 'internalIPAddressValueContainer'});
}
});
SC.event.addGlobalHandler(SC.event.RefreshTab, function (eventArgs) {
if (isGeneralTab(eventArgs.tabName)) {
SC.ui.clear($('modelValueContainer'));
SC.ui.clear($('manufacturerValueContainer'));
SC.ui.clear($('biosNameValueContainer'));
SC.ui.clear($('biosSerialValueContainer'));
//SC.ui.clear($('BiosAgeValueContainer'));
//SC.ui.clear($('domainNameValueContainer'));
//SC.ui.clear($('DHCPEnabledValueContainer'));
//SC.ui.clear($('DHCPServerValueContainer'));
SC.ui.clear($('internalIPAddressValueContainer'));
//SC.ui.clear($('defaultGatewayValueContainer'));
SC.ui.clear($('antivirusValueContainer'));
SC.ui.clear($('mediaFriendlyNameValueContainer'));
SC.ui.clear($('mediaSerialNumberValueContainer'));
SC.ui.clear($('mediaSizeValueContainer'));
SC.ui.clear($('mediatypeValueContainer'));
SC.ui.clear($('mediaHealthStatusValueContainer'));
SC.ui.clear($('mediaPredictFailureValueContainer'));
//SC.ui.clear($('antispywareValueContainer'));
}
if (isSupportedOperatingSystem(eventArgs.session.GuestOperatingSystemName))
displayInformationRequest(
getLatestInformationRequestEvent(
eventArgs.sessionDetails,
eventArgs.tabName
), eventArgs
);
});
function isSupportedOperatingSystem(operatingSystemName){
if (operatingSystemName.startsWith("Windows") || operatingSystemName.startsWith("Microsoft"))
return true;
else
return false;
}
function sendCommand() {
window.addEventToSessions(
window.getSessionGroupUrlPart()[0],
SC.types.SessionType.Access,
[window.getSessionUrlPart()],
SC.types.SessionEventType.QueuedCommand,
null,
getInputCommand(
"General"
),
false,
false,
true
);
}
function getInputCommand(commandType) {
var headers = getHeaders();
headers.CommandType = commandType;
var commandText = "$computer = get-wmiobject win32_computersystem | select Manufacturer, Model" + "\n" +
"$bios = get-wmiobject win32_bios | select Name, SerialNumber" + "\n" +
"$bay = Get-WmiObject -Class Win32_BIOS" + "\n" +
//"$BIOSageInYears = (New-TimeSpan -Start ($bay.ConvertToDateTime($bay.releasedate).ToShortDateString()) -End $(Get-Date)).Days / 365" + "\n" +
"$av = get-wmiobject -Namespace \"root/SecurityCenter2\" -Class AntiVirusProduct | Where {$_.displayName -notlike 'Windows Defender'} | select displayName" + "\n" +
//"$network = get-wmiobject Win32_NetworkAdapterConfiguration |Where {$_.ipaddress -notlike $null}| select DHCPEnabled, DHCPServer,IPAddress, DefaultIPGateway" + "\n" +
//"$network = get-wmiobject Win32_NetworkAdapterConfiguration |Where {$_.ipaddress -notlike $null} | select IPAddress" + "\n" +
"$network = get-WmiObject Win32_NetworkAdapterConfiguration|Where {$_.Ipaddress.length -gt 1}" + "\n" +
"$mediatype = Get-PhysicalDisk | Select MediaType, FriendlyName, SerialNumber, HealthStatus, Size" + "\n" +
"$mediafail = Get-WmiObject -namespace \"root/wmi\" -Class MSStorageDriver_FailurePredictStatus | select PredictFailure" + "\n" +
//"write-output $computer.Manufacturer, $computer.Model, $bios.Name, $bios.SerialNumber,$BIOSageInYears, $computer.Domain, $network.DHCPEnabled, $network.DHCPServer, $network.IPAddress, $network.DefaultIPGateway, $av.displayName, $mediatype.MediaType, $as.displayName| ConvertTo-Xml -As Stream";
"write-output $computer.Manufacturer, $computer.Model, $bios.Name, $bios.SerialNumber, $mediatype.FriendlyName, $mediatype.SerialNumber, $mediatype.Size $mediatype.MediaType, $mediatype.HealthStatus, $mediafail.PredictFailure $av.displayName, $network.IPAddress[0] $as.displayName| ConvertTo-Xml -As Stream";
var emptyLinePrefix = '';
if (headers.Processor == 'sh')
emptyLinePrefix = 'echo ';
else{
emptyLinePrefix = 'echo ""';
commandText = "$Host.UI.RawUI.BufferSize = New-Object Management.Automation.Host.Size (500, 25)" + "\n" + commandText;
}
return "#!" + headers.shaBang + "\n" +
"#maxlength=100000" + "\n" +
"#timeout=90000" + "\n" +
headers.modifier + "INFORMATIONREQUEST-RESPONSE/0" + headers.delimiter + "\n" +
headers.modifier + "CommandType: " + headers.CommandType + headers.delimiter + "\n" +
headers.modifier + "ContentType: " + headers.ContentType + headers.delimiter + "\n" +
emptyLinePrefix + "\n" + commandText;
}
function getHeaders() {
return { Processor: "ps", Interface: "powershell", ContentType: "xml", shaBang: "ps", modifier: "echo \"", delimiter: '\"' };
}
function isGeneralTab(tabName) {
switch (tabName) {
case 'General':
return true;
default:
return false;
}
}
function isInformationRequestContent(eventData) {
return eventData.startsWith("INFORMATIONREQUEST-RESPONSE/0");
}
function getLatestInformationRequestEvent(sessionDetails, CommandEventType) {
return sessionDetails.Connections
.map(function(c) { return c.Events; })
.reduce(function(outputArray, events) { Array.prototype.push.apply(outputArray, events); return outputArray; }, [])
.filter(function(e) {
return e.EventType === SC.types.SessionEventType.RanCommand &&
isInformationRequestContent(e.Data)
})
.sort(function (x, y) { return x.Time - y.Time; })
[0];
}
function parseDataHeaders(eventData) {
var currentIndex = 0;
var headers = {};
var isStatusLine = true;
while (true) {
var nextNewLineIndex = eventData.indexOf('\n', currentIndex);
if (isStatusLine) {
isStatusLine = false;
} else if (nextNewLineIndex == currentIndex + 2 || nextNewLineIndex < 0) {
break;
} else {
var lineParts = eventData.substring(currentIndex, nextNewLineIndex).split(': ');
headers[lineParts[0]] = lineParts[1];
}
currentIndex = nextNewLineIndex + 1;
}
return headers;
}
function displayInformationRequest(latestCommandEvent, eventArgs) {
if (typeof latestCommandEvent === 'undefined' && !hasSentCommand && window.isCommandEnabled("RunCommand", null, [eventArgs.session], eventArgs.session.Permissions)) {
sendCommand();
hasSentCommand = true;
return;
} else {
var headers = parseDataHeaders(latestCommandEvent.Data);
displayCommandData(getEventDataXml(latestCommandEvent.Data));
}
}
function getEventDataXml(eventData) {
return parseXml(eventData.substring(eventData.indexOf('<?xml'), eventData.length));
}
function displayCommandData(xml) {
var x = xml.getElementsByTagName("Object");
if (isUsingInternetExplorerOrEdge())
{
$('manufacturerValueContainer').innerHTML = x[0].childNodes[0].textContent;
$('modelValueContainer').innerHTML = x[1].childNodes[0].textContent;
$('biosNameValueContainer').innerHTML = x[2].childNodes[0].textContent;
$('biosSerialValueContainer').innerHTML = x[3].childNodes[0].textContent;
//$('BiosAgeValueContainer').innerHTML = x[4].childNodes[0].textContent;
//$('domainNameValueContainer').innerHTML = x[5].childNodes[0].textContent;
//$('DHCPEnabledValueContainer').innerHTML = x[6].childNodes[0].textContent;
//$('DHCPServerValueContainer').innerHTML = x[7].childNodes[0].textContent;
//$('defaultGatewayValueContainer').innerHTML = x[9].childNodes[0].textContent;
$('mediaFriendlyNameValueContainer').innerHTML = x[4].childNodes[0].textContent;
$('mediaSerialNumberValueContainer').innerHTML = x[5].childNodes[0].textContent;
$('mediaSizeValueContainer').innerHTML = x[6].childNodes[0].textContent;
$('mediatypeValueContainer').innerHTML = x[7].childNodes[0].textContent;
$('mediaHealthStatusValueContainer').innerHTML = x[8].childNodes[0].textContent;
$('mediaPredictFailureValueContainer').innerHTML = x[9].childNodes[0].textContent;
$('antivirusValueContainer').innerHTML = x[10].childNodes[0].textContent;
$('internalIPAddressValueContainer').innerHTML = x[11].childNodes[0].textContent;
//$('antispywareValueContainer').innerHTML = x[10].childNodes[0].textContent;
} else {
$('manufacturerValueContainer').innerHTML = x[0].innerHTML;
$('modelValueContainer').innerHTML = x[1].innerHTML;
$('biosNameValueContainer').innerHTML = x[2].innerHTML;
$('biosSerialValueContainer').innerHTML = x[3].innerHTML;
//$('BiosAgeValueContainer').innerHTML = x[4].innerHTML;
//$('domainNameValueContainer').innerHTML = x[5].innerHTML;
//$('DHCPEnabledValueContainer').innerHTML = x[6].innerHTML;
//$('DHCPServerValueContainer').innerHTML = x[7].innerHTML;
//$('defaultGatewayValueContainer').innerHTML = x[9].innerHTML;
$('mediaFriendlyNameValueContainer').innerHTML = x[4].innerHTML;
$('mediaSerialNumberValueContainer').innerHTML = x[5].innerHTML;
$('mediaSizeValueContainer').innerHTML = x[6].innerHTML;
$('mediatypeValueContainer').innerHTML = x[7].innerHTML;
$('mediaHealthStatusValueContainer').innerHTML = x[8].innerHTML;
$('mediaPredictFailureValueContainer').innerHTML = x[9].innerHTML;
$('antivirusValueContainer').innerHTML = x[10].innerHTML;
$('internalIPAddressValueContainer').innerHTML = x[11].innerHTML;
//$('antispywareValueContainer').innerHTML = x[10].innerHTML;
}
}
function parseXml(xml) {
var dom = null;
if (window.DOMParser) {
try {
dom = (new DOMParser()).parseFromString(xml, "text/xml");
}
catch (e) { dom = null; }
}
else if (window.ActiveXObject) {
try {
dom = new ActiveXObject('Microsoft.XMLDOM');
dom.async = false;
if (!dom.loadXML(xml)) // parse error ..
window.alert(dom.parseError.reason + dom.parseError.srcText);
}
catch (e) { dom = null; }
}
else
alert("cannot parse xml string!");
return dom;
}
function isUsingInternetExplorerOrEdge() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf("Trident");
if (ua.indexOf("Trident") > 0 || ua.indexOf("Edge") > 0)
return true;
else
return false;
}
Edited by user Monday, May 7, 2018 9:42:10 PM(UTC)
| Reason: Not specified