diff --git a/api.asp b/api.asp index 01f5766..cea3c21 100644 --- a/api.asp +++ b/api.asp @@ -607,7 +607,7 @@ Sub UpdateInstalledApps() ' Insert new app mappings Dim appCount, i, appName, appVersion, appid, appversionid, cmdInsert, appidStr, insertSQL - Dim debugLoopError, safeVer, verSQL, rsVer + Dim debugLoopError, safeVer, verSQL, rsVer, isActiveStr, isActive debugLoopError = "" appCount = 0 Err.Clear @@ -622,7 +622,12 @@ Sub UpdateInstalledApps() appVersion = Trim(GetJSONValue(appsArray(i), "version") & "") appName = Trim(GetJSONValue(appsArray(i), "appname") & "") - LogToFile "App " & i & ": appid=" & appid & ", appname='" & appName & "', version='" & appVersion & "'" + ' Get isactive status (for UDC/CLM process detection) + isActive = 1 ' Default to active + isActiveStr = Trim(GetJSONValue(appsArray(i), "isactive") & "") + If isActiveStr <> "" And IsNumeric(isActiveStr) Then isActive = CLng(isActiveStr) + + LogToFile "App " & i & ": appid=" & appid & ", appname='" & appName & "', version='" & appVersion & "', isactive=" & isActive If appid > 0 Then appversionid = 0 @@ -658,11 +663,11 @@ Sub UpdateInstalledApps() If rs.State = 1 Then rs.Close End If - ' Insert app + ' Insert app with isactive status If appversionid > 0 Then - insertSQL = "INSERT INTO installedapps (machineid, appid, appversionid) VALUES (" & CLng(machineid) & ", " & CLng(appid) & ", " & CLng(appversionid) & ")" + insertSQL = "INSERT INTO installedapps (machineid, appid, appversionid, isactive) VALUES (" & CLng(machineid) & ", " & CLng(appid) & ", " & CLng(appversionid) & ", " & isActive & ")" Else - insertSQL = "INSERT INTO installedapps (machineid, appid) VALUES (" & CLng(machineid) & ", " & CLng(appid) & ")" + insertSQL = "INSERT INTO installedapps (machineid, appid, isactive) VALUES (" & CLng(machineid) & ", " & CLng(appid) & ", " & isActive & ")" End If objConn.Execute insertSQL @@ -726,7 +731,7 @@ Function SaveInstalledApps(machineid, installedAppsJson) ' Insert new app mappings Dim appCount, i, appName, appVersion, appid, appversionid, appidStr, insertSQL - Dim safeVer, verSQL, rsVer + Dim safeVer, verSQL, rsVer, isActiveStr, isActive appCount = 0 Err.Clear @@ -740,6 +745,11 @@ Function SaveInstalledApps(machineid, installedAppsJson) appVersion = Trim(GetJSONValue(appsArray(i), "version") & "") appName = Trim(GetJSONValue(appsArray(i), "appname") & "") + ' Get isactive status (for UDC/CLM process detection) + isActive = 1 ' Default to active + isActiveStr = Trim(GetJSONValue(appsArray(i), "isactive") & "") + If isActiveStr <> "" And IsNumeric(isActiveStr) Then isActive = CLng(isActiveStr) + If appid > 0 Then appversionid = 0 Err.Clear @@ -772,11 +782,11 @@ Function SaveInstalledApps(machineid, installedAppsJson) If rs.State = 1 Then rs.Close End If - ' Insert app + ' Insert app with isactive status If appversionid > 0 Then - insertSQL = "INSERT INTO installedapps (machineid, appid, appversionid) VALUES (" & CLng(machineid) & ", " & CLng(appid) & ", " & CLng(appversionid) & ")" + insertSQL = "INSERT INTO installedapps (machineid, appid, appversionid, isactive) VALUES (" & CLng(machineid) & ", " & CLng(appid) & ", " & CLng(appversionid) & ", " & isActive & ")" Else - insertSQL = "INSERT INTO installedapps (machineid, appid) VALUES (" & CLng(machineid) & ", " & CLng(appid) & ")" + insertSQL = "INSERT INTO installedapps (machineid, appid, isactive) VALUES (" & CLng(machineid) & ", " & CLng(appid) & ", " & isActive & ")" End If objConn.Execute insertSQL diff --git a/displaymachines.asp b/displaymachines.asp index d862596..136cc6c 100644 --- a/displaymachines.asp +++ b/displaymachines.asp @@ -82,14 +82,14 @@ <% ' Build WHERE clause with optional BU filter - ' NOTE: pctypeid IS NULL filters out PCs; also exclude LocationOnly (1) and network devices (16-20) + ' NOTE: Exclude LocationOnly (1), network devices (16-20), and PC types (33+) Dim whereClause whereClause = "models.machinetypeid = machinetypes.machinetypeid AND " &_ "machines.modelnumberid = models.modelnumberid AND " &_ "models.vendorid = vendors.vendorid AND " &_ "machines.businessunitid = businessunits.businessunitID AND " &_ - "machines.isactive = 1 AND islocationonly=0 AND machines.pctypeid IS NULL AND " &_ - "models.machinetypeid NOT IN (1, 16, 17, 18, 19, 20)" + "machines.isactive = 1 AND islocationonly=0 AND " &_ + "models.machinetypeid NOT IN (1, 16, 17, 18, 19, 20) AND models.machinetypeid < 33" ' Add BU filter if specified If filterBU <> "" And IsNumeric(filterBU) Then diff --git a/displaypc.asp b/displaypc.asp index 6398c39..2ff3ab8 100644 --- a/displaypc.asp +++ b/displaypc.asp @@ -372,10 +372,13 @@ End If If hasVncEnabled And vncHostname <> "" Then Response.Write("

" & Server.HTMLEncode(vncHostname) & "

") +ElseIf hasVncEnabled And primaryIP <> "" Then + ' Fallback to IP address if no hostname + Response.Write("

" & Server.HTMLEncode(primaryIP) & "

") ElseIf hasVncEnabled Then - Response.Write("

VNC Enabled (No hostname)

") + Response.Write("

VNC Enabled (No hostname or IP)

") Else - Response.Write("

VNC: N/A

") + Response.Write("

N/A

") End If ' Display WinRM status (text instead of badge) diff --git a/displaypcs.asp b/displaypcs.asp index a1c1a83..1035e05 100644 --- a/displaypcs.asp +++ b/displaypcs.asp @@ -39,9 +39,9 @@ <% -Dim currentPCStatus, recentFilter, deviceTypeFilter, pcTypeFilter, uptimeFilter, sel +Dim currentPCStatus, winrmFilter, deviceTypeFilter, pcTypeFilter, uptimeFilter, sel currentPCStatus = Request.QueryString("pcstatus") -recentFilter = Request.QueryString("recent") +winrmFilter = Request.QueryString("winrm") deviceTypeFilter = Request.QueryString("devicetype") pcTypeFilter = Request.QueryString("pctype") uptimeFilter = Request.QueryString("uptime") @@ -107,9 +107,11 @@ rsStatus.Close Set rsStatus = Nothing %> - + + + + - <% If currentPCStatus <> "" Or recentFilter <> "" Or deviceTypeFilter <> "" Or pcTypeFilter <> "" Or uptimeFilter <> "" Or Request.QueryString("needsrelationship") <> "" Then %> + <% If currentPCStatus <> "" Or winrmFilter <> "" Or deviceTypeFilter <> "" Or pcTypeFilter <> "" Or uptimeFilter <> "" Or Request.QueryString("needsrelationship") <> "" Then %> Clear @@ -145,10 +147,10 @@ Set rsStatus = Nothing <% ' Build query based on filters - Dim pcStatusFilter, recentDaysFilter, deviceTypeFilterSQL, pcTypeFilterSQL, uptimeFilterSQL, needsRelationshipFilter, whereClause + Dim pcStatusFilter, winrmFilterSQL, deviceTypeFilterSQL, pcTypeFilterSQL, uptimeFilterSQL, needsRelationshipFilter, whereClause Dim displayName, hasVnc, vncHost, hasWinrm, uptimeDays pcStatusFilter = Request.QueryString("pcstatus") - recentDaysFilter = Request.QueryString("recent") + winrmFilterSQL = Request.QueryString("winrm") deviceTypeFilterSQL = Request.QueryString("devicetype") pcTypeFilterSQL = Request.QueryString("pctype") uptimeFilterSQL = Request.QueryString("uptime") @@ -178,8 +180,15 @@ Set rsStatus = Nothing whereClause = whereClause & " AND m.machinestatusid = " & pcStatusFilter End If - If recentDaysFilter <> "" And IsNumeric(recentDaysFilter) Then - whereClause = whereClause & " AND m.lastupdated >= DATE_SUB(NOW(), INTERVAL " & recentDaysFilter & " DAY)" + ' Filter by WinRM status + If winrmFilterSQL = "needswinrm" Then + ' PCs with equipment relationships but no WinRM + whereClause = whereClause & " AND (m.iswinrm = 0 OR m.iswinrm IS NULL)" & _ + " AND EXISTS (SELECT 1 FROM machinerelationships mr2 WHERE (mr2.machineid = m.machineid OR mr2.related_machineid = m.machineid) AND mr2.isactive = 1 AND mr2.relationshiptypeid = 3)" + ElseIf winrmFilterSQL = "haswinrm" Then + whereClause = whereClause & " AND m.iswinrm = 1" + ElseIf winrmFilterSQL = "nowinrm" Then + whereClause = whereClause & " AND (m.iswinrm = 0 OR m.iswinrm IS NULL)" End If ' Filter by device type (laptop vs desktop) based on model name patterns @@ -259,8 +268,11 @@ Set rsStatus = Nothing If hasVnc And Not IsNull(rs("hostname")) And rs("hostname") <> "" Then vncHost = rs("hostname") & ".logon.ds.ge.com" Response.Write("VNC") + ElseIf hasVnc And Not IsNull(rs("ipaddress")) And rs("ipaddress") <> "" Then + ' Fallback to IP address if no hostname + Response.Write("VNC") ElseIf hasVnc Then - Response.Write("VNC") + Response.Write("VNC") Else Response.Write("-") End If diff --git a/scripts/Update-PC-CompleteAsset.ps1 b/scripts/Update-PC-CompleteAsset.ps1 index a4ea698..6443856 100644 --- a/scripts/Update-PC-CompleteAsset.ps1 +++ b/scripts/Update-PC-CompleteAsset.ps1 @@ -854,6 +854,30 @@ function Collect-SystemInfo { } } + # Detect running processes for UDC and CLM to set isactive + $udcRunning = $false + $clmRunning = $false + $udcProcess = Get-Process -Name "UDC" -ErrorAction SilentlyContinue + if ($udcProcess) { $udcRunning = $true } + $clmProcess = Get-Process -Name "PPMon" -ErrorAction SilentlyContinue + if ($clmProcess) { $clmRunning = $true } + + # Update tracked apps with isactive status + foreach ($app in $trackedApps) { + if ($app.appid -eq 2) { + # UDC + $app.isactive = if ($udcRunning) { 1 } else { 0 } + Write-Host " UDC process running: $udcRunning" -ForegroundColor $(if ($udcRunning) { "Green" } else { "Yellow" }) + } elseif ($app.appid -eq 4) { + # CLM + $app.isactive = if ($clmRunning) { 1 } else { 0 } + Write-Host " CLM (PPMon) process running: $clmRunning" -ForegroundColor $(if ($clmRunning) { "Green" } else { "Yellow" }) + } else { + # Other apps - default to active if installed + $app.isactive = 1 + } + } + $systemInfo.TrackedApplications = $trackedApps Write-Host " Found $($trackedApps.Count) tracked applications for database" -ForegroundColor Cyan } diff --git a/scripts/Update-ShopfloorPCs-Remote.ps1 b/scripts/Update-ShopfloorPCs-Remote.ps1 index cb61bf4..35ffb9b 100644 --- a/scripts/Update-ShopfloorPCs-Remote.ps1 +++ b/scripts/Update-ShopfloorPCs-Remote.ps1 @@ -245,9 +245,9 @@ function Add-TrustedHosts { Write-Log "Current TrustedHosts: $(if ($currentHosts) { $currentHosts } else { '(empty)' })" -Level "INFO" if ($TrustAllInDomain) { - # Trust all hosts in the domain (wildcard) - $newValue = "*.$DnsSuffix" - Write-Log "Adding wildcard trust for: $newValue" -Level "INFO" + # Trust all hosts in the domain (wildcard) AND the shopfloor IP subnet for IP fallback + $newValue = "*.$DnsSuffix,10.134.*" + Write-Log "Adding wildcard trust for: *.$DnsSuffix and 10.134.* (IP fallback)" -Level "INFO" } else { # Build list of FQDNs to add $fqdnsToAdd = @() @@ -296,9 +296,9 @@ function Show-TrustedHostsHelp { Write-Host "Since you're not on the same domain as the shopfloor PCs," -ForegroundColor White Write-Host "you need to add them to your TrustedHosts list." -ForegroundColor White Write-Host "" - Write-Host "OPTION 1: Trust all PCs in the domain (Recommended)" -ForegroundColor Yellow + Write-Host "OPTION 1: Trust all PCs in the domain + IP fallback (Recommended)" -ForegroundColor Yellow Write-Host " Run as Administrator:" -ForegroundColor Gray - Write-Host ' Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*.logon.ds.ge.com" -Force' -ForegroundColor Green + Write-Host ' Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*.logon.ds.ge.com,10.134.*" -Force' -ForegroundColor Green Write-Host "" Write-Host "OPTION 2: Trust specific PCs" -ForegroundColor Yellow Write-Host " Run as Administrator:" -ForegroundColor Gray @@ -546,6 +546,37 @@ function Get-RemotePCInfo { } } } + # ================================================================ + # Detect running processes for UDC and CLM to set isactive + # ================================================================ + $udcRunning = $false + $clmRunning = $false + + # Check for UDC process + $udcProcess = Get-Process -Name "UDC" -ErrorAction SilentlyContinue + if ($udcProcess) { $udcRunning = $true } + + # Check for CLM process (PPMon.exe) + $clmProcess = Get-Process -Name "PPMon" -ErrorAction SilentlyContinue + if ($clmProcess) { $clmRunning = $true } + + # Update matched apps with isactive status + foreach ($app in $matchedApps) { + if ($app.appid -eq 2) { + # UDC + $app.isactive = if ($udcRunning) { 1 } else { 0 } + } elseif ($app.appid -eq 4) { + # CLM + $app.isactive = if ($clmRunning) { 1 } else { 0 } + } else { + # Other apps - default to active if installed + $app.isactive = 1 + } + } + + $result.UDCRunning = $udcRunning + $result.CLMRunning = $clmRunning + # Store matched apps as JSON string to survive WinRM serialization $result.MatchedAppsCount = $matchedApps.Count $result.MatchedAppNames = ($matchedApps | ForEach-Object { $_.appname }) -join ", "