FU.WhyAmIBlocked.psm1
$Public = @(Get-ChildItem -Path "$($PSScriptRoot)\Public\*.ps1" -ErrorAction SilentlyContinue) $Private = @(Get-ChildItem -Path "$($PSScriptRoot)\Private\*.ps1" -ErrorAction SilentlyContinue) $script:Prefix = "fu" $script:Path = "C:\FeatureUpdateBlocks" $pythonPath = $env:Path.split(';') | Where-Object {$_ -Like "*Python*" -and $_ -notlike "*scripts*"} try { $PythonVersion = & python --version } catch { } If(!($PythonVersion)) { If(!(Test-Path -Path "$($pythonPath)\python.exe")) { $pythonPath = Read-Host -Enter "Enter the folder path to python.exe" If(!(Test-Path -Path $pythonPath -ErrorAction SilentlyContinue)) { $pythonPath = $null } } Else { $pythonPath = $null } If($PythonPath -and (Test-Path -Path "$($pythonPath)\python.exe" -ErrorAction SilentlyContinue)) { $PythonVersion = & "$($pythonPath)\python.exe" --version } Else { $PythonVersion = & python --version } } If($pythonVersion) { [switch]$script:PythonInstalled = $true } Else { Write-Warning "Python is not installed. Install Python then re-import the module then run 'Initialize-FUModule -Reset'. You may need to close PowerShell and re-launch after install. " Write-Host " + You can install the Windows Store version from here https://www.microsoft.com/store/productId/9MSSZTT1N39L" -foregroundcolor blue } $initCfg = @{ Path = "$($script:Path)" ConfigFile = "$($script:Path)\Config.json" SDBUnPackerFile = Join-Path -Path $PSScriptRoot -ChildPath "SDBUnpacker.py" sdb2xmlPath = Join-Path -Path $PSScriptRoot -ChildPath "sdb2xml.exe" UserConfigFile = "$($env:USERPROFILE)\.$($script:Prefix)cfgpath" PythonPath = If($pythonPath) {$pythonPath} Else {""} } $cfg = Get-Content $initCfg["UserConfigFile"] -ErrorAction SilentlyContinue $script:tick = [char]0x221a if ($cfg) { if (Get-Content -Path $cfg -raw -ErrorAction SilentlyContinue) { $script:Config = Get-Content -Path $cfg -raw -ErrorAction SilentlyContinue | ConvertFrom-Json } else { $script:Config = $initCfg } } else { $script:Config = $initCfg } #endregion #region Dot source the files foreach ($import in @($Public + $Private)) { try { . $import.FullName } catch { Write-Error -Message "Failed to import function $($import.FullName): $_" } } #endregion |