PowerShell.PersistentPathStack.psm1

<#
  ╓──────────────────────────────────────────────────────────────────────────────────────
  ║ PowerShell PowerShell.PersistentPathStack Module
  ║ Version 1.0.73 , Generated on 2023-02-14 07:40:52
  ║ Description:
  ║ Current Git Revision d8f7d2f7d78834106f60dc0cfdd38a67dd5eb0dd
  ╙──────────────────────────────────────────────────────────────────────────────────────
 #>



# ------------------------------------
# Script file - Aliases -
# ------------------------------------
$ScriptBlockAliases = "H4sIAAAAAAAACqWOuwoCMRBF+0D+Ydh+PiLgA0F2A4J9DIMbGHdCHtj48Y4siIWNWN7HgWPNSHd0nEIFHMONYMiS8wB4Dtw1ecnoqdRUGy3NhzbrtpMSCXBDNZaUW5JFj+8TKANHieE16Hvr4HBdpChxipIJ9iyXwIDTijrmtX/A1BuOndka+0Ws1/nTTOPvagr96Waeg//eUjQBAAA="

# ------------------------------------
# Script file - PersistentPath -
# ------------------------------------
$ScriptBlockPersistentPath = "H4sIAAAAAAAACu1XbW/bOAz+XqD/QfAZmA0kQT8HyLAua28BcqnR7OVDEQyezczebCsnye2CIv99lGTF8kuyLbs73Ib5ky2RD8mHFCmfn52fucuIpRsxDkKRzGIyIU4AjKdcQCHkmnOOQuuyiERKC7KAh2Fz/1HuE3zupnmcgXieFnFafPCW5WZDmeDLhJZZHDAaAef+SstuQhbmnn5XuoFcAAHM+yss4lBQtp24gpUwCChPpenJhVFWCpdZGnLvyeZJY3UpGNpeudKxwdfg12HGoQ+U94MuRRh9WiDOxIlhHZaZQG6khG8okOzcwoclCCVLahW97x4i+d3jxc4hw3VHo0acCcjJcBajRrpOgRGnQkM97aGGPz/bNTJ2Czm9h3bSyL+XtX+S1tNIUxoo/yeIirx5yI8S+AKQg0p7mkHIWnwpA1zvMxAlKxpkW3S/Ai7+uxPy83F9kMM9gxKpj/0foNFvWK1dNWn9mgP8/53CEzodf0hFlKzcyywzoWmS9Hu69uSW/1iruLcgMM93yy3Sko+mNMtA8cVHl4yF2znStRqPC3gwdMvnLUsFDN8Ae085EAepFbJThVlGuCLfsSyo0CROo57ssyefa8quwijxXJ7GJC0sNdvdPus1vtS1LMun+fUNBwEhDHV7rY7z8iCoxSOHoaE9pWUhIdTHSH01pbqMtk0Z32u4Grllcs8lYuaKzF4eu2YV+ZOnRClWoF0ll8qKCXhUckHzm/cfsWJWz3rQ5VM1EoXYL6GH6qSivr2Lh7i9dHdP03glK3d0GceeS63K7FGpv6wN06oQRC/uTm6VJ1WHsS/l2p2qb1TxX3rcVLeZb6OvPZuDkie/b691Lpp1b3JyxRhlN1FUMpCZca9l0k1NuQGD+5SWvDqtnizmOY1CSbA/0vNcCcrkmGampFplKm+tVWqtLPum5WkUwbZWt1hatszdQZ1IXIoSS7ATwyv8k9if3nrE2WJ209PN7iXF0nJmxX2YYbNTASujyBtW5i1UPWgHyI+lLIHr4IfwN7loN9TuX1SL2F5urPbU7VjudZllJilu8PaFnYxDNvc6R+ztes4R3fxUV9zeOm8NtG5MVav6Q/ZrIhIgWSjwco9uI2E4KuWSusM0L8K9/1vHCMZ6wfuY9n48nvEFJuWGXeUbscVEorJPurVZ+6284WTxej63hruZGhKsMbZa6gv4LAyE24h6SnNMEBC8KCYqVjwlDMNR8Q/Qa8IxhAGJEvhE1pQpmQLhCC3MwJtWKkf6hCEPEGXS9/d0jLpWMJW5fTzV94BsJLryDfOmcqYtOnUGNNXquBo9nwyxDIl3ODkI4WsV1SSbiXKDEwuiJzKN0QmhzleV3e+spYNV0rk5dzpvZbevJSPG2RfAvUPIWhIAAA=="

# ------------------------------------
# Script file - Registry -
# ------------------------------------
$ScriptBlockRegistry = "H4sIAAAAAAAACu1Y/0/iSBT/3cT/YYIkloQS1N+8kGwVVJIViKBcsiGm0gF6aae9manoufu/35uZtsyUgrDGZC97JbGl8+Z9/bzPGzw8OJSfWUKm3I8IGiRPgc8W9h2e+4zT18uFS+aYIYSOjlCv3/lz0L8bHR68qW3wGn27DL0A8wufeD6ZW8MkjiPK2XARJYE3oNEUM1abKNnYpW6ILPVFbh6IN5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tzuchxC2mJM+SvSdCFVS0eVpzsnEcUrylYaJF0Lb2tvmTWJisyO6mUgFyXf0EIRSgjsVDqUoC2gIx8bXzGZCx/S7jGDEXGYyMqnvAauHFoiyt8ZWWrqv48jM0cKBHJTKaxE8QxUwU6didJub1lbQfYdDkQBnnK7//QX3AB0LzGEnMsq++vW9XNFjgZJVmgHX8spaPib4ySzIlKuW4nXrbSKNk5LNcks/sRPnLNS/IpjYutYfTveVaupaekDQiCP6teiMQ0LnbETxfbwUkLb5M2riMJB0uRPX/InwB3ODrYBx9LmAeMlLWmysyhg2h/mAQDOs2H0jLcwu9iktu7l7aqB8nwVzgTmUSJLz/tOpJSThZnKi4Kr34mZm2UeiUmSFrT2tvJlw38EfnyUS8xxuj5t0uT/TyTrRPKxPlWt+V9tly1t8msAWIOw6NvPxe/eU3DL8VgfintPxA3j8J3T+J7mTnfRa8zKHRWf7aJY8Od7es0W3NZ/m5tP9Yo2KQtt9rEm/clG3bVPC71a+IVd8GXb2N9AAp8yFNH3EmO/Js3A35RrDv4F67dFx7wXAAA="

# ------------------------------------
# Script file - RegistrySet -
# ------------------------------------
$ScriptBlockRegistrySet = "H4sIAAAAAAAACu1abW/aSBD+Hin/YeVaApQY9b6m4iSakBQ1AQSkuSqNGgcvwYrxcuvlCKL57zf7Yntt1kBScsddQ6uA17PztjPPzK69v7cP/+zegPoTdtTF9+fkvhG6dwH2UA3Zp24QYU6xvzechgPmkxBdUZ9hR5KiBYLPu3eo1W780Wl3+5KWD14fj70As49+6Pnhfbk3nUwIZVFvRKaB16FkgKOociNpJy51x2X5W8zt8AHMMC1fuKHnMkLnNZvRKT7skMjnatTex5PFhHrgu1G5NC5lRnuMguwb+wJkuff4cJ2EITfXxJdl+X5xAx/m4B5m5dKMhqXDUkjH8BdTCn89Epr16M8nuCZJX6xKjnU089lgdGO3SBezKQ3lrUq8Cv6wbF5cB/+plreyoGLmUzIDle1O7yOZhl6iWlQ9JiFz/TD6jOfl0hdM70iES5UKctoUlVEsB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bTVM5De6rQQXDy2gK2apcRoORGTytzwk8zQpCx3zJtENacRThG/ZQN9ayk9ilvxlfkmejrZiccteXr6Z+5CpKMFXv/fYrbwvM6DOD3BgfnUDm4Ao5+NVLlz03Fq61UgkxDZZtKUEJmkyJGvToo03DdNjuyMn8H+lVki1Gk8wtSo9pLilC0jktHSRkryStb6JcUvliBDa2nfHbtI3kYQC9VqNTddeT4IQJOCXd0zlNEiSC9pgtNGu0DQEXkER2GJISz8pu8D9QBY2g0KU2EXiBwmDyeTQrwepjhE8Q3V7sBUYdMYp8buNY+y1bnuzeEIdAysggAO4sDAqFqncIjN/XtzdBTiGd86G06h8huu5Q60qAtd3YmuBpd8V7q1zvR1N2TFPSoEuiHFt4Jm61Ft2+iWhygeZNW655WlABVI+scELvHnjmL34YNhjsFhoqvXio2g4390PHohFGVa/Qw2FR1RcoCSGLBLEHWIXnsLkG3zN+vMDpGIjVNKxh1/ggM/xEoI+oSDiXrCVLMY5AIiYTC3jP0aT5V4MAO2SNy6IB7WHpu/BFQ18MoeXsc/2pf9zmVfHqJmVUke4MLjkrUyr0Yuaw5L4vntWmJuG2i3Ur9+o9dH7db5V5NqSx5KcTquFG/Vaier1dIyv1bh2mbvm0SaqIFyayaKYMYyRSxlCEqJKIX1a2stcYFvjYw38K61tnoVFcCkFxHeOkIzXhuQJ/cGm6yrsRUwldSlw7FMzeSfV6ibqyrnrrX226mbb8Xurdi9bc12vtg9q0htue68TtH5JStMUl2OA+xSx/Cul3ixYDtPHeNjnfZw6A98N1CtUlYovABXh2D5gXrg4QG8Std4nEB1iF8YQEKpuON+wOCIueEtBUlwSmjDHYzKNsTLGPngATVjxWudxyM8eACD4EQXJmWfncGmJNY92V5I5vw10uQR8lLnm5cheYNH+1wp8W5IdAirxOMYDjP1k2TxWX6vBznJ2yiSmRYpyeI/7f0NaGGTfR0tAAA="



# ------------------------------------
# Loader
# ------------------------------------
function ConvertFrom-Base64CompressedScriptBlock {

    [CmdletBinding()] param(
        [String]
        $ScriptBlock
    )

    # Take my B64 string and do a Base64 to Byte array conversion of compressed data
    $ScriptBlockCompressed = [System.Convert]::FromBase64String($ScriptBlock)

    # Then decompress script's data
    $InputStream = New-Object System.IO.MemoryStream(, $ScriptBlockCompressed)
    $GzipStream = New-Object System.IO.Compression.GzipStream $InputStream, ([System.IO.Compression.CompressionMode]::Decompress)
    $StreamReader = New-Object System.IO.StreamReader($GzipStream)
    $ScriptBlockDecompressed = $StreamReader.ReadToEnd()
    # And close the streams
    $GzipStream.Close()
    $InputStream.Close()

    $ScriptBlockDecompressed
}

$AssembliesFound = $False
$AssemblyFolder = "$PSScriptRoot\assemblies"
if(Test-Path "$AssemblyFolder" -PathType 'Container'){
    $Assembly = @( Get-ChildItem -Path "$AssemblyFolder\*.dll" -ErrorAction SilentlyContinue )    
    $AssemblyCount = $Assembly.Count
    if($AssemblyCount -gt 0 ){ $AssembliesFound = $True }
}


if($AssembliesFound){
    $FoundErrors = @(
      Foreach ($Import in @($Assembly)) {
        try {
            Add-Type -Path $Import.Fullname -ErrorAction Stop
        } catch [System.Reflection.ReflectionTypeLoadException] {
            Write-Warning "Processing $($Import.Name) Exception: $($_.Exception.Message)"
            $LoaderExceptions = $($_.Exception.LoaderExceptions) | Sort-Object -Unique
            foreach ($E in $LoaderExceptions) {
                Write-Warning "Processing $($Import.Name) LoaderExceptions: $($E.Message)"
            }
            $true
            #Write-Error -Message "StackTrace: $($_.Exception.StackTrace)"
        } catch {
            Write-Warning "Processing $($Import.Name) Exception: $($_.Exception.Message)"
            $LoaderExceptions = $($_.Exception.LoaderExceptions) | Sort-Object -Unique
            foreach ($E in $LoaderExceptions) {
                Write-Warning "Processing $($Import.Name) LoaderExceptions: $($E.Message)"
            }
            $true
            #Write-Error -Message "StackTrace: $($_.Exception.StackTrace)"
        }
      }
    )

    if ($FoundErrors.Count -gt 0) {
        $ModuleName = (Get-ChildItem $PSScriptRoot\*.psd1).BaseName
        Write-Warning "Importing module $ModuleName failed. Fix errors before continuing."
        break
    }
}

# For each scripts in the module, decompress and load it.
# Set a flag in the Script Scope so that the scripts know we are loading a module
# so he can have a specific logic
$Script:LoadingState = $True
$ScriptList = @('Aliases','PersistentPath','Registry','RegistrySet')
$ScriptList | ForEach-Object {
    $ScriptId = $_
     $ScriptBlock = "`$ScriptBlock$($ScriptId)" | Invoke-Expression
    $ClearScript = ConvertFrom-Base64CompressedScriptBlock -ScriptBlock $ScriptBlock
    try{
        $ClearScript | Invoke-Expression
    }catch{
        Write-Host "===============================" -f DarkGray
        Write-Host "$ClearScript" -f DarkGray
        Write-Host "===============================" -f DarkGray
        Write-Error "ERROR IN script $ScriptId . Details $_"
    }
}
$Script:LoadingState = $False