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" $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 = $env:Path.split(';') | Where-Object {$_ -Like "*Python*" -and $_ -notlike "*scripts*"} } $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 If($Script:Config.PythonPath -and (Test-Path -Path "$($Script:Config.PythonPath)")) { $PythonVersion = & "$($Script:Config.PythonPath)\python.exe" --version } Else { $PythonVersion = & python --version } If($pythonVersion) { [switch]$script:PythonInstalled = $true } Else { Throw "Python is not installed. Install Python before proceeding." } |