OmadaSqlTroubleShooter.psm1
|
####################################################################################################################################################### # WARNING: DO NOT EDIT THIS FILE AS IT IS GENERATED AND WILL BE OVERWRITTEN ON THE NEXT UPDATE! # # # # Generated via psake on: 2025-10-12T08:29:30.552Z # # Version: 2025.10.12.3 # # Copyright Fortigi (C) 2025 # ####################################################################################################################################################### #requires -Module OmadaWeb.PS #requires -Version 7.0 [CmdLetBinding()] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'WebViewInstalled', Justification = 'The variable is used, but script analyzer does not recognize it')] param() try { $Script:Tracer = [System.Diagnostics.Trace] $Script:Tracer::AutoFlush = $true $ModuleName = "OmadaSqlTroubleshooter" "Loading {0} Module" -f $ModuleName | Write-Verbose $LocalAppDataPath = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::LocalApplicationData) $ModuleAppDataPath = (New-Item (Join-Path $LocalAppDataPath -ChildPath $ModuleName) -ItemType Directory -Force).FullName $BinPath = (New-Item (Join-Path $ModuleAppDataPath -ChildPath "Bin\$PowerShellType") -ItemType Directory -Force).FullName if (-not (Test-Path "$PSScriptRoot\Lib\Functions\Public" -PathType Container)) { $Public = @(Get-ChildItem "$PsscriptRoot\Lib\Functions\Functions.ps1") } else { $Public = @(Get-ChildItem -Path $PSScriptRoot\Lib\Functions\Public\*.ps1 -Recurse | Where-Object { $_.Name -notlike "_*.ps1" }) } if (-not(Test-Path "$PSScriptRoot\Lib\Functions\Private" -PathType Container)) { $Private = @() } else { $Private = @(Get-ChildItem -Path $PSScriptRoot\Lib\Functions\Private\*.ps1 -Recurse | Where-Object { $_.Name -notlike "_*.ps1" }) } foreach ($Import in @($Public + $Private)) { try { . $Import.FullName } catch { "Failed to import function {0}: {1}" -f $($Import.FullName), $_ | Write-Error -ErrorAction "Stop" } } try { $WebBinBasePath = New-Item $BinPath -ItemType Directory -Force } catch {} "{0} - Set paths" -f $MyInvocation.MyCommand | Write-Verbose if ($Env:PROCESSOR_ARCHITECTURE -eq "AMD64") { $WebView2BasePath = [System.IO.Path]::Combine($WebBinBasePath, "win-x64") } else { $WebView2BasePath = [System.IO.Path]::Combine($WebBinBasePath, "win-x86") } New-Item -ItemType Directory -Path $WebView2BasePath -Force | Out-Null $Script:WebView2CorePath = [System.IO.Path]::Combine($WebView2BasePath, "Microsoft.Web.WebView2.Core.dll") "{0} - {1}" -f $MyInvocation.MyCommand, $Script:WebView2CorePath | Write-Verbose $Script:WebView2WinFormsPath = [System.IO.Path]::Combine($WebView2BasePath, "Microsoft.Web.WebView2.WinForms.dll") "{0} - {1}" -f $MyInvocation.MyCommand, $Script:WebView2WinFormsPath | Write-Verbose $Script:WebView2WpfPath = [System.IO.Path]::Combine($WebView2BasePath, "Microsoft.Web.WebView2.Wpf.dll") "{0} - {1}" -f $MyInvocation.MyCommand, $Script:WebView2WpfPath | Write-Verbose $Script:WebView2LoaderPath = [System.IO.Path]::Combine($WebView2BasePath, "WebView2Loader.dll") "{0} - {1}" -f $MyInvocation.MyCommand, $Script:WebView2LoaderPath | Write-Verbose $Script:WebView2UserProfilePath = [System.IO.Path]::Combine($ModuleAppDataPath, "Edge User Data\OmadaWebView2Profile") "{0} - {1}" -f $MyInvocation.MyCommand, $Script:WebView2UserProfilePath | Write-Verbose $WebViewInstalled = Install-WebView2 -IncludeWpf if (!$WebViewInstalled) { "Cannot start module because the Microsoft Edge Webview2 RunTime was not found. You can download it from: https://developer.microsoft.com/en-us/microsoft-edge/webview2?form=MA13LH#download-section. When you are not able to install it, you can also add the Webview2 Fixed Version binaries to folder {0}" -f (Join-Path $WebBinBasePath -ChildPath "$ModuleName\bin\Webview2Runtime") | Write-Error -ErrorAction "Stop" } "Validate version" | Write-Verbose try { $InstalledModule = Get-InstalledModuleInfo -ModuleName $ModuleName if (-not $InstalledModule.RepositorySource -or $InstalledModule.RepositorySource -notlike "*powershellgallery.com*") { "Module '{0}' was not sourced from the PowerShell Gallery. Skipping version check." -f $ModuleName | Write-Verbose } else { $GalleryVersion = Get-GalleryModuleVersion -ModuleName $ModuleName if (-not $GalleryVersion) { } else { if ([version]$InstalledModule.Version -lt [version]$GalleryVersion) { "The installed version {0} of '{1}' is outdated. Latest version: {2}. Execute Update-Module {1} to update to the latest version!" -f ($($InstalledModule.Version)), $ModuleName, $GalleryVersion | Write-Warning } elseif ([version]$InstalledModule.Version -eq [version]$GalleryVersion) { "The installed version {0} of '{1}' is up-to-date." -f ($($InstalledModule.Version)) , $ModuleName | Write-Verbose } else { "The installed version {0} of '{1}' is newer than the gallery version {2}." -f ($($InstalledModule.Version)), $ModuleName, $GalleryVersion | Write-Warning } } } } catch {} Test-Shortcut } catch { throw } |