InstallDependency
0.3.14
Apteco PS Modules - PowerShell install dependencies
Module to install dependencies from PowerShell Gallery and NuGet.
Downloads and installs the latest versions of some modules and packages (saved in current folder or machine folder) from the PowerShell Gallery and NuGet.
Minimum PowerShell version
5.1
Installation Options
Owners
Copyright
(c) 2026 Apteco GmbH. All rights reserved.
Package Details
Author(s)
- florian.von.bracht@apteco.de
Tags
powershell Windows Linux Apteco
Functions
Install-Dependency Install-NuGetPackage Install-VcRedist Grant-LogonAsBatchRight
PSEditions
Dependencies
Release Notes
0.3.14 Hardened dependency installation for pwsh on hosts where the only PackageManagement/PowerShellGet
reachable on PSModulePath is the Windows PowerShell inbox 1.0.0.1 build. Loading that .NET Framework
build in pwsh throws a TypeInitializationException in
Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicType the moment a *-Package* cmdlet
touches it, which then cascades into "NuGet provider not found" and a PSGallery re-register prompt.
Install-Dependency now force-loads a modern build (PackageManagement >= 1.4.7 / PowerShellGet >= 2.0)
before the first package call and logs an actionable warning if none is available. Added -Scope
(CurrentUser when not elevated) to the PackageManagement/PowerShellGet self-update so it no longer
silently no-ops against the read-only C:\Program Files\WindowsApps\...\Modules, and the in-session
re-import now pins a minimum version so it cannot rebind to the 1.0.0.1 inbox build. Replaced the
blocking $Host.UI.PromptForChoice / Request-Choice / "exit 0" repository prompts with automatic
registration of the default PSGallery / public NuGet v2 feed and automatic source selection
(prefer PSGallery, else the first), so a non-interactive/service/CI run no longer hangs or kills
the host; module installs/updates now pass -Force so an untrusted repository does not prompt either.
The PackageManagement/PowerShellGet re-imports now use -Global -- imported from inside the module
function they were only visible to InstallDependency, so the internal
"PackageManagement\Get-Package" calls of PowerShellGet failed with "The module PackageManagement could not be
loaded". A Store/MSIX pwsh now always installs with -Scope CurrentUser (its AllUsers folder is
read-only even for admins). On Windows PowerShell the module no longer sorts PSModulePath and PATH
alphabetically (it keeps their order and only drops duplicates) and removes pwsh module folders
inherited from a pwsh parent process, which made Windows PowerShell load the pwsh
Microsoft.PowerShell.Security and fail with "TypeData ... is already present". Reading the
execution policy at import can no longer stop the module from loading.
0.3.13 Added Grant-LogonAsBatchRight to grant an account the "Log on as a batch job" right, needed to run a
scheduled task under a service account. Rescued from an old local-only script, previously duplicated
across a couple of one-off deployment scripts
0.3.12 Re-import PackageManagement/PowerShellGet in-session right after updating them, since Import-Module -Force
merely stacks the new version alongside the old one still loaded in-process and cmdlets kept resolving
to the stale binaries until the whole PowerShell session was restarted.
Fix with -AllowClobber when installing local packages
0.3.11 Added a pinned version support to keep the same version of a package installed for all environments.
This is needed for DuckDB.NET to keep the same version for Windows PowerShell 5.1 (netstandard2.0)
and PowerShell Core (Windows and Linux)
0.3.10 Found the real cause behind the 0.3.9 "Cannot install local packages!" abort: $pack (the list of
packages to install) was not forced into an array, so a single match collapsed to a scalar
object. Windows PowerShell 5.1 (Desktop) has no .Count on scalars (unlike PS 6+), so
$pack.Count was $null, and Write-Progress's $i/$pack.Count division threw "Attempted to divide
by zero", aborting the whole install loop before the .nupkg cleanup was ever reached. $pack is
now always wrapped in @() so .Count is well-defined regardless of match count or PS edition
0.3.9 Fixed the 0.3.8 .nupkg cleanup being able to abort the entire local/global package install loop:
Install-Package -Destination can still hold a lock on the freshly written .nupkg for a moment
(observed on Windows PowerShell 5.1's legacy PackageManagement NuGet provider), so an immediate
open/delete could fail with a sharing violation, which was unhandled and aborted the rest of the
run with an unhelpful "Cannot install local packages!" warning. The cleanup now retries a few
times with a short delay and never lets a single package's cleanup failure abort the others, and
the outer warning now includes the actual exception message
0.3.8 Initial release of the InstallDependency modul to replace Install-Dependencies script
Fixed the 0.4.6 cleanup deleting the .nupkg outright, which removed the package's only remaining
metadata source (no .nuspec, no .nupkg left) -- Get-LocalPackage could no longer discover it at
all, so Import-Dependency silently stopped finding/loading it. Now extracts just the tiny .nuspec
out of the .nupkg before removing it, so the package stays discoverable via Get-LocalPackage's
fast nuspec path without needing to keep the full .nupkg around
0.3.7 Added -KeepPackage switch (default: off, matching Install-NuGetPackage) that removes the raw .nupkg
files Install-Package -Destination leaves behind as siblings of the extracted lib/ref/runtimes
folders in LocalPackageFolder after a successful install. Only ever touches LocalPackageFolder,
never the global/machine package cache
0.3.6 Fixed -LocalPackage/-GlobalPackage being typed [String[]], which silently coerced any
PSCustomObject (e.g. @{name="Npgsql"; version="8.0.7"}) passed for version pinning into its
string representation before the function body ever ran -- so version pinning never actually
worked, for any version. Changed to [Object[]] so PSCustomObject entries pass through intact.
This bug predates the module (inherited from the original Install-Dependencies script)
0.3.5 Fixed Install-Package failing with "multiple packages matched 'PackageManagement'" (NuGet.org
coincidentally hosts a same-named package) by specifying -ProviderName when updating PackageManagement/
PowerShellGet, and wrapped both updates in try/catch so a failure there cannot abort the whole run
0.3.4 Suppressed the return values of Install-Package/Install-Module/Update-Module/Register-PSRepository/
Set-PSRepository/Register-PackageSource/Set-PackageSource, which were being written to the pipeline
unsuppressed and dumped as full PackageManagement/PowerShellGet objects to the console/caller
0.3.3 Fixed module import failing with "Cannot index into a null array" when pwsh (PowerShell Core) is not
installed (e.g. Windows Sandbox) -> the pwsh version was read before checking whether pwsh was found at all
0.3.2 Fixed module import failing with "Access is denied" in locked-down environments like Windows Sandbox,
where the Get-CimInstance fallback for architecture detection is blocked. Now falls back further to
Is64BitOperatingSystem, which does not need WMI/CIM access
0.3.1 Added Install-VcRedist to check for and install the Visual C++ Redistributable (x64), moved here from
AptecoPSFramework's own installation script so any consumer can reuse it
0.3.0 Removed -Script support (PowerShellGet scripts are deprecated in favor of modules). Install-Dependency now
reuses Get-PSEnvironment (from ImportDependency) for already-installed modules and local/global NuGet
packages instead of querying Get-InstalledModule/Get-Package itself, and local/global packages are now
skipped when already installed at a current version, matching how modules already behaved
0.2.0 Migration of Install-Dependencies script to Install-Dependency module
FileList
- InstallDependency.nuspec
- InstallDependency.psd1
- InstallDependency.psm1
- Private\Get-VcRedistStatus.ps1
- Private\Request-Choice.ps1
- Public\Grant-LogonAsBatchRight.ps1
- Public\Install-Dependency.ps1
- Public\Install-NuGetPackage.ps1
- Public\Install-VcRedist.ps1
Version History
| Version | Downloads | Last updated |
|---|---|---|
| 0.3.14 (current version) | 99 | 11/20/2026 |
| 0.3.13 | 12,599 | 7/30/2026 |
| 0.3.12 | 28 | 7/29/2026 |
| 0.3.11 | 18 | 7/21/2026 |
| 0.3.10 | 11 | 7/21/2026 |