diff --git a/vHC/HC_Reporting/Functions/Collection/CCollections.cs b/vHC/HC_Reporting/Functions/Collection/CCollections.cs index e2c9f62..8e31022 100644 --- a/vHC/HC_Reporting/Functions/Collection/CCollections.cs +++ b/vHC/HC_Reporting/Functions/Collection/CCollections.cs @@ -9,6 +9,7 @@ using Microsoft.Management.Infrastructure; using VeeamHealthCheck.Functions.Collection.PSCollections; using System.Windows; +using VeeamHealthCheck.Shared.Logging; namespace VeeamHealthCheck.Functions.Collection { @@ -86,17 +87,34 @@ private void ExecPSScripts() { try { - if (!TestPsMFA(p)) + + if (CGlobals.IsVbr) { - if(CGlobals.IsVbr) - ExecVbrScripts(p); - if(CGlobals.IsVb365) - ExecVb365Scripts(p); + CGlobals.Logger.Info("Checking VBR MFA Access...", false); + if (!TestPsMFA(p)) + { + if (CGlobals.IsVbr) + ExecVbrScripts(p); + } + else + { + WeighSuccessContinuation(); + } } - else + if (CGlobals.IsVb365) { - WeighSuccessContinuation(); + CGlobals.Logger.Info("Checking VB365 MFA Access...", false); + if (!TestPsMFAVb365(p)) + { + if (CGlobals.IsVb365) + ExecVb365Scripts(p); + } + else + { + WeighSuccessContinuation(); + } } + } catch (Exception ex) @@ -138,6 +156,12 @@ private bool TestPsMFA(PSInvoker p) return p.TestMfa(); } + private bool TestPsMFAVb365(PSInvoker p) + { + CScripts scripts = new(); + + return p.TestMfaVB365(); + } private void ExecVbrScripts(PSInvoker p) { if (CGlobals.IsVbr) diff --git a/vHC/HC_Reporting/Functions/Collection/DB/CDbAccessor.cs b/vHC/HC_Reporting/Functions/Collection/DB/CDbAccessor.cs index b7bcbff..b963532 100644 --- a/vHC/HC_Reporting/Functions/Collection/DB/CDbAccessor.cs +++ b/vHC/HC_Reporting/Functions/Collection/DB/CDbAccessor.cs @@ -3,6 +3,7 @@ using System; using System.Data.SqlClient; using System.Security.Principal; +using VeeamHealthCheck.Shared; namespace VeeamHealthCheck.Functions.Collection.DB { @@ -67,6 +68,7 @@ private bool TestConnection() } catch (Exception e) { + CGlobals.Logger.Warning("Sql Test Connection Failed: " + e.Message); return false; } diff --git a/vHC/HC_Reporting/Functions/Collection/DB/CRegReader.cs b/vHC/HC_Reporting/Functions/Collection/DB/CRegReader.cs index 501f9e4..d3a725d 100644 --- a/vHC/HC_Reporting/Functions/Collection/DB/CRegReader.cs +++ b/vHC/HC_Reporting/Functions/Collection/DB/CRegReader.cs @@ -50,7 +50,7 @@ public void GetDbInfo() } catch (Exception e2) { - log.Error(logStart + "Failed to get v11 DB info from Registry. Trying v12 registry hives"); + log.Error(logStart + "Failed to get v11 DB info from Registry. Trying v12 registry hives:\t" + e2.Message); } if (string.IsNullOrEmpty(_databaseName)) { @@ -67,7 +67,7 @@ public void GetDbInfo() } catch (Exception e3) { - log.Error(logStart + "Failed to get v12 DB info from Registry."); + log.Error(logStart + "Failed to get v12 DB info from Registry:\t" + e3.Message); } diff --git a/vHC/HC_Reporting/Functions/Collection/LogParser/CLogParser.cs b/vHC/HC_Reporting/Functions/Collection/LogParser/CLogParser.cs index fc71101..e5112a3 100644 --- a/vHC/HC_Reporting/Functions/Collection/LogParser/CLogParser.cs +++ b/vHC/HC_Reporting/Functions/Collection/LogParser/CLogParser.cs @@ -55,7 +55,7 @@ public string InitLogDir() } catch (Exception e) { - log.Error(logStart + "Failed to return log location."); + log.Error(logStart + "Failed to return log location. Error:\t" + e.Message); } return logs; } @@ -69,9 +69,9 @@ private void InitWaitCsv() sw.WriteLine("JobName,StartTime,EndTime,Duration"); } } - catch (Exception) + catch (Exception e ) { - log.Error(logStart + "Failed to init waits.csv"); + log.Error(logStart + "Failed to init waits.csv. Error:\t" + e.Message); } } private void DumpWaitsToFile(string JobName, DateTime start, DateTime end, TimeSpan diff) diff --git a/vHC/HC_Reporting/Functions/Collection/PSCollections/PSInvoker.cs b/vHC/HC_Reporting/Functions/Collection/PSCollections/PSInvoker.cs index ce451ac..59d90f1 100644 --- a/vHC/HC_Reporting/Functions/Collection/PSCollections/PSInvoker.cs +++ b/vHC/HC_Reporting/Functions/Collection/PSCollections/PSInvoker.cs @@ -91,6 +91,46 @@ public bool TestMfa() return failed; } + public bool TestMfaVB365() + { + var res = new Process(); + if (CGlobals.REMOTEHOST == "") + CGlobals.REMOTEHOST = "localhost"; + string argString = $"Connect-VBOServer -Server \"{CGlobals.REMOTEHOST}\""; + var startInfo = new ProcessStartInfo() + { + FileName = "powershell.exe", + Arguments = argString, + UseShellExecute = false, + CreateNoWindow = false, //true for prod, + RedirectStandardError = true + }; + res.StartInfo = startInfo; + res.Start(); + + res.WaitForExit(); + + List errorarray = new(); + + bool failed = false; + string errString = ""; + while ((errString = res.StandardError.ReadLine()) != null) + { + var errResults = ParseErrors(errString); + if (!errResults.Success) + { + log.Error(errString, false); + log.Error(errResults.Message); + failed = true; + return failed; + + } + errorarray.Add(errString); + } + PushPsErrorsToMainLog(errorarray); + + return failed; + } public bool RunVbrConfigCollect() { bool success = true; diff --git a/vHC/HC_Reporting/Functions/Collection/REST/RestInvoker.cs b/vHC/HC_Reporting/Functions/Collection/REST/RestInvoker.cs deleted file mode 100644 index 1eb9aa1..0000000 --- a/vHC/HC_Reporting/Functions/Collection/REST/RestInvoker.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http.Headers; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; - -namespace VeeamHealthCheck.Functions.Collection.REST -{ - internal class RestInvoker - { - private readonly IHttpClientFactory _httpClientFactory = null!; - private string _token; - - public RestInvoker() - { - } - public async void Run() - { - var t = SetRestToken().Result; - - } - public void GetVbrVersion() - { - //string token = RestLoginToken(); - - using HttpClient client = new(); - client.DefaultRequestHeaders.Accept.Clear(); - client.DefaultRequestHeaders.Accept.Add( - new MediaTypeWithQualityHeaderValue("application/vnd.github.v3+json")); - client.DefaultRequestHeaders.Add("User-Agent", ".NET Foundation Repository Reporter"); - - //await CollectServerVersion(client); - CollectServerVersion(client); - } - static async Task CollectServerVersion(HttpClient client) - { - - } - - public async Task SetRestToken() - { - var client = _httpClientFactory.CreateClient(); - client.DefaultRequestHeaders.Add("x-api-version", "1.1-rev0"); - - List> postData = new List>(); - postData.Add(new KeyValuePair("grant_type", "password")); - postData.Add(new KeyValuePair("username", "administrator")); - postData.Add(new KeyValuePair("password", "Veeam123!")); - //postData.Add(new KeyValuePair("refresh_token", "string")); - //postData.Add(new KeyValuePair("code", "string")); - postData.Add(new KeyValuePair("use_short_term_refresh", "true")); - postData.Add(new KeyValuePair("vbr_token", "string")); - - var request = await client.PostAsync("https://vbr-12-beta3/api/oauth2/token", new FormUrlEncodedContent(postData)); - var response = await request.Content.ReadAsStringAsync(); - - Console.WriteLine(response); - return response; - } - } -} diff --git a/vHC/HC_Reporting/Functions/Reporting/Html/CHtmlExporter.cs b/vHC/HC_Reporting/Functions/Reporting/Html/CHtmlExporter.cs index dd91c60..90f410e 100644 --- a/vHC/HC_Reporting/Functions/Reporting/Html/CHtmlExporter.cs +++ b/vHC/HC_Reporting/Functions/Reporting/Html/CHtmlExporter.cs @@ -50,7 +50,7 @@ private void CheckOutputDirsExist() Directory.CreateDirectory(_origPath); } - public int ExportVb365Html(string htmlString) + public int ExportVb365Html(string htmlString, bool scrub) { log.Info("writing HTML to file..."); @@ -67,12 +67,12 @@ public int ExportVb365Html(string htmlString) if (!Directory.Exists(n)) Directory.CreateDirectory(n); string htmlCore = ""; - if (CGlobals.Scrub) + if (scrub) htmlCore = "\\" + _htmlName + "_VB365" + "_" + installID + dateTime.ToString("_yyyy.MM.dd.HHmmss") + ".html"; - else if (!CGlobals.Scrub) + else if (scrub) htmlCore = "\\" + _htmlName + "_VB365" + "_" + _backupServerName + dateTime.ToString("_yyyy.MM.dd.HHmmss") + ".html"; string name = n + htmlCore; - _latestReport = name;//SetReportNameAndPath(CGlobals.Scrub, "VB365"); + _latestReport = SetReportNameAndPath(scrub, "VB365"); WriteHtmlToFile(htmlString); log.Info("writing HTML to file..done!"); @@ -84,6 +84,34 @@ public int ExportVb365Html(string htmlString) + } + public int ExportHtmlVb365(string htmlString, bool scrub) + { + + + try + { + log.Info("exporting xml to html"); + _latestReport = SetReportNameAndPath(scrub, "VB365"); + WriteHtmlToFile(htmlString); + log.Info("exporting xml to html..done!"); + + //test export to PDF: + if (!scrub && CGlobals.EXPORTPDF) + { + ExportHtmlStringToPDF(htmlString); + } + + OpenHtmlIfEnabled(CGlobals.OpenHtml); + return 0; + } + catch (Exception e) + { + log.Error("Failed at HTML Export:"); + log.Error("\t" + e.Message); return 1; + } + + } public int ExportVbrHtml(string htmlString, bool scrub) { diff --git a/vHC/HC_Reporting/Functions/Reporting/Html/Shared/CHtmlFormatting.cs b/vHC/HC_Reporting/Functions/Reporting/Html/Shared/CHtmlFormatting.cs index 36e0aa6..d28cf3f 100644 --- a/vHC/HC_Reporting/Functions/Reporting/Html/Shared/CHtmlFormatting.cs +++ b/vHC/HC_Reporting/Functions/Reporting/Html/Shared/CHtmlFormatting.cs @@ -321,20 +321,19 @@ public string SetVb365Intro()
CSV Raw Data Output
{0}

-
Individual Job Session Reports
+
{1}

-
PDF Report Output
+
{2}
-
-
Excel Report Output
-
{3}
+ + ", Vb365ResourceHandler.HtmlIntroLine2, Vb365ResourceHandler.HtmlIntroLine4, -Vb365ResourceHandler.HtmlIntroLine5vb365 +Vb365ResourceHandler.HtmlIntroLine5vb365, "" ); s += ""; return s; @@ -360,8 +359,45 @@ public string SetHeaderAndLogo(string licenseHolder) {0}

- Veeam Backup & Recovery Health Check Report + Veeam Backup & Recovery +

+

Health Check Report

+

{1}|{2}{3}

+ + + + + +", licenseHolder, DateTime.Now.ToString("MMMM dd yyyy"), CGlobals.ReportDays.ToString(), " day report", bannerString); + + return s; + + } + + public string SetHeaderAndLogoVB365(string licenseHolder) + { + + //string s = ""; + string s = "";// "", bannerString); + + + //s += "
"; + + + s += String.Format(@" +
+
+

+ {0} +

+

+ Veeam Backup For Microsoft 365

+

Health Check Report

{1}|{2}{3}

diff --git a/vHC/HC_Reporting/Functions/Reporting/Html/VB365/CM365Tables.cs b/vHC/HC_Reporting/Functions/Reporting/Html/VB365/CM365Tables.cs index 58a37e6..9eea921 100644 --- a/vHC/HC_Reporting/Functions/Reporting/Html/VB365/CM365Tables.cs +++ b/vHC/HC_Reporting/Functions/Reporting/Html/VB365/CM365Tables.cs @@ -66,7 +66,17 @@ public string Globals() s += _form.TableData(gl.SupportExpiry, ""); s += _form.TableData(gl.LicenseType, ""); - s += _form.TableData(gl.LicensedTo, ""); + if (CGlobals.Scrub) + { + var licName = CGlobals.Scrubber.ScrubItem(gl.LicensedTo, Scrubber.ScrubItemType.Item); + s += _form.TableData(licName, ""); + + } + else + { + s += _form.TableData(gl.LicensedTo, ""); + + } s += _form.TableData(gl.LicenseContact, ""); s += _form.TableData(gl.LicensedFor, ""); @@ -100,7 +110,7 @@ public string Globals() s += ""; // summary - s += _summary.GlobalSummary(); + //s += _summary.GlobalSummary(); s += "
"; return s; @@ -280,7 +290,7 @@ public string Vb365Proxies() } s += ""; - s += _summary.ProxySummary(); + //s += _summary.ProxySummary(); s += ""; return s; @@ -380,7 +390,7 @@ public string Vb365Repos() s += ""; - s += _summary.RepoSummary(); + // s += _summary.RepoSummary(); s += ""; return s; } @@ -429,7 +439,7 @@ public string Vb365Rbac() s += ""; - s += _summary.RbacSummary(); + //s += _summary.RbacSummary(); s += ""; return s; } @@ -591,7 +601,7 @@ public string Vb365Security() s += ""; - s += _summary.SecSummary(); + //s += _summary.SecSummary(); s += ""; return s; @@ -759,7 +769,7 @@ public string Vb365Controllers() } s += ""; - s += _summary.ControllerSummary(); + //s += _summary.ControllerSummary(); s += ""; return s; @@ -877,7 +887,7 @@ public string Vb365ControllerDrives() } s += ""; - s += _summary.ControllerDrivesSummary(); + //s += _summary.ControllerDrivesSummary(); s += ""; return s; } @@ -927,7 +937,7 @@ public string Vb365JobSessions() } s += ""; - s += _summary.JobSessSummary(); + //s += _summary.JobSessSummary(); s += ""; return s; @@ -1040,7 +1050,7 @@ public string Vb365JobStats() } s += ""; - s += _summary.JobStatSummary(); + //s += _summary.JobStatSummary(); s += ""; return s; } @@ -1163,7 +1173,7 @@ public string Vb365ObjectRepos() } s += ""; - s += _summary.ObjRepoSummary(); + //s += _summary.ObjRepoSummary(); s += ""; return s; @@ -1225,7 +1235,7 @@ public string Vb365Orgs() } s += ""; - s += _summary.OrgSummary(); + //s += _summary.OrgSummary(); s += ""; return s; } @@ -1270,7 +1280,7 @@ public string Vb365Permissions() } s += ""; - s += _summary.PermissionSummary(); + //s += _summary.PermissionSummary(); s += ""; return s; @@ -1350,7 +1360,7 @@ public string Vb365ProtStat() s += ""; - s += _summary.ProtStatSummary(); + //s += _summary.ProtStatSummary(); s += ""; return s; @@ -1512,7 +1522,7 @@ public string Jobs() s += ""; - s += _summary.JobsSummary(); + //s += _summary.JobsSummary(); s += ""; return s; diff --git a/vHC/HC_Reporting/Functions/Reporting/Html/VB365/CVb365HtmlCompiler.cs b/vHC/HC_Reporting/Functions/Reporting/Html/VB365/CVb365HtmlCompiler.cs index 1ea197d..043a106 100644 --- a/vHC/HC_Reporting/Functions/Reporting/Html/VB365/CVb365HtmlCompiler.cs +++ b/vHC/HC_Reporting/Functions/Reporting/Html/VB365/CVb365HtmlCompiler.cs @@ -42,21 +42,24 @@ private void FormVb365Body() _htmldoc += _form.body; - //_htmldoc += _form.SetHeaderAndLogo(SetLicHolder()); - if (!CGlobals.Scrub) - _htmldoc += _form.SetHeaderAndLogo(SetLicHolder()); - if (CGlobals.Scrub) - _htmldoc += _form.SetHeaderAndLogo(" "); + _htmldoc += FormBodyStartVb365(_htmldoc); + // add sections here _htmldoc += SetNavigation(); - _htmldoc += _form.SetVb365Intro(); + //_htmldoc += _form.SetVb365Intro(); // Navigation! + //expand all button: + _htmldoc += (string.Format("", "Expand All Sections")); + CM365Tables tables = new(); _htmldoc += _form.header1("Overview"); + _htmldoc += tables.Globals(); + _htmldoc += tables.Vb365ProtStat(); + // other workloads prompt?? _htmldoc += _form.header1("Backup Infrastructure"); _htmldoc += tables.Vb365Controllers(); @@ -94,11 +97,32 @@ private void FormVb365Body() } } + private string FormBodyStartVb365(string htmlString) + { + string h = _form.body; + h += _form.FormHtmlButtonGoToTop(); + if (CGlobals.Scrub) + { + h += _form.SetHeaderAndLogoVB365(" "); + //h += _form.SetBannerAndIntro(true); + } + else + { + h += _form.SetHeaderAndLogoVB365(SetLicHolder()); + //h += _form.SetBannerAndIntro(false); + } + + return h; + } private string SetNavigation() { log.Info("[VB365][HTML] forming navigation..."); string s = string.Empty; s += _form.SetNavTables("vb365"); + s += _form.SetVb365Intro(); + s += ""; + s += ""; + s += "
"; log.Info("[VB365][HTML] forming navigation...done!"); return s; } @@ -107,7 +131,13 @@ private void ExportHtml() { log.Info("[VB365][HTML] exporting HTML file..."); CHtmlExporter exporter = new(GetServerName()); - exporter.ExportVb365Html(_htmldoc); + //exporter.ExportVb365Html(_htmldoc); + //exporter.ExportVb365Html(_htmldocScrubbed); + + if (CGlobals.Scrub) + exporter.ExportHtmlVb365(_htmldoc, true); + else + exporter.ExportHtmlVb365(_htmldoc, false); log.Info("[VB365][HTML] exporting HTML...done!"); } private string GetServerName() diff --git a/vHC/HC_Reporting/Functions/Reporting/Html/VBR/CHtmlCompiler.cs b/vHC/HC_Reporting/Functions/Reporting/Html/VBR/CHtmlCompiler.cs index 94c3424..b5a132a 100644 --- a/vHC/HC_Reporting/Functions/Reporting/Html/VBR/CHtmlCompiler.cs +++ b/vHC/HC_Reporting/Functions/Reporting/Html/VBR/CHtmlCompiler.cs @@ -243,7 +243,8 @@ private string FormBodyStart(string htmlString, bool scrub) return h; } - + + private string SetVbrSecurityHeader() { return _form.SetHeaderAndLogo(SetLicHolder()); diff --git a/vHC/HC_Reporting/Properties/launchSettings.json b/vHC/HC_Reporting/Properties/launchSettings.json index fe88c31..b012be5 100644 --- a/vHC/HC_Reporting/Properties/launchSettings.json +++ b/vHC/HC_Reporting/Properties/launchSettings.json @@ -2,10 +2,10 @@ "profiles": { "VeeamHealthCheck": { "commandName": "Project", - "commandLineArgs": "/import\r\n", + "commandLineArgs": "/import /scrub:true", "remoteDebugEnabled": true, "authenticationMode": "Windows", - "remoteDebugMachine": "192.168.20.2:4026" + "remoteDebugMachine": "192.168.20.206:4026" } } } \ No newline at end of file diff --git a/vHC/HC_Reporting/VeeamHealthCheck.csproj b/vHC/HC_Reporting/VeeamHealthCheck.csproj index 326245f..66dd875 100644 --- a/vHC/HC_Reporting/VeeamHealthCheck.csproj +++ b/vHC/HC_Reporting/VeeamHealthCheck.csproj @@ -11,10 +11,10 @@ Veeam AdamC Health_Check_Icon.ico - 2.0.0.499 + 2.0.0.511 False false - 2.0.0.499 + 2.0.0.511 full true diff --git a/vHC/VhcXTests/VhcXTests.csproj b/vHC/VhcXTests/VhcXTests.csproj index 163a0a9..d7d1a52 100644 --- a/vHC/VhcXTests/VhcXTests.csproj +++ b/vHC/VhcXTests/VhcXTests.csproj @@ -7,8 +7,8 @@ false true - 1.0.0.244 - 1.0.0.244 + 1.0.0.250 + 1.0.0.250