pslrm (PowerShell Local Resource Manager) is a thin wrapper for Microsoft.PowerShell.PSResourceGet.
pslrm saves PSResourceGet resources into a directory in your project. This gives you project-local (directory-based) dependency management. It also keeps the requirements format compatible with PSResourceGet.
- Installs/updates required resources from PowerShell Gallery into a project-local directory
- Writes a lockfile that records the resolved versions
- Restores the project-local directory to match the lockfile
- Uninstalls resources from the project-local directory
psreq.psd1Requirements file (compatible with PSResourceGet-RequiredResourceFileformat)psreq.lock.psd1Lockfile (versions that PSResourceGet saved)
In psreq.psd1, each entry is a hashtable keyed by module name.
The following keys are commonly used by PSResourceGet.
versionA version string. It can be a range expression like[0.0.1,1.3.0].repositoryThe repository name. pslrm supports PSGallery.prereleaseSet to$trueto allow prerelease versions.
The project root is the directory that contains psreq.psd1.
By default, pslrm saves resources under the project root at ./.pslrm/.
PSResourceGet decides the on-disk layout under ./.pslrm/.
pslrm does not impose a directory structure.
- Supported repository: PowerShell Gallery (PSGallery).
If you set
repositoryinpsreq.psd1, it must resolve to PSGallery. Otherwise, pslrm errors.
psreq.psd1Desired state for direct dependencies and version constraints.psreq.lock.psd1Resolved state for reproducible installs../.pslrm/Materialized local resources for the current project.
pslrm treats these files differently depending on the command.
Update-PSLResourceresolves from requirements and refreshes the lockfile.Restore-PSLResourcerestores from the lockfile.Install-PSLResourceis the convenience entry point:- If
psreq.lock.psd1exists, install uses the lockfile to reproduce the saved versions. - If
psreq.lock.psd1does not exist, install resolves frompsreq.psd1and creates the lockfile.
- If
Use restore when you want a lockfile-driven restore. Use update when you want to apply changes from requirements.
Install-PSLResourceInstall project-local resources. Ifpsreq.lock.psd1exists, it restores the saved versions from the lockfile. Ifpsreq.lock.psd1does not exist, it resolves frompsreq.psd1and writes a new lockfile. By default, it outputs direct resources. Use-IncludeDependenciesto output all saved resources.Update-PSLResourceRe-resolve project-local resources frompsreq.psd1. Rewritepsreq.lock.psd1and refresh./.pslrm/. By default, it outputs direct resources. Use-IncludeDependenciesto output all saved resources.Get-InstalledPSLResourceReadpsreq.lock.psd1and list installed resources for the project.Uninstall-PSLResourceRemove selected resources from the project by name. It updatespsreq.psd1(and may normalize it) and rewritespsreq.lock.psd1. If it removes all resources, it writes an empty lockfile.Restore-PSLResourceRestore project-local resources to matchpsreq.lock.psd1. This is the explicit lockfile-driven restore command. Ifpsreq.lock.psd1is missing, it errors. If./.pslrm/exists, it clears the directory before restore.
| Command | Primary input | Updates psreq.lock.psd1 |
Updates ./.pslrm/ |
Intended use |
|---|---|---|---|---|
Install-PSLResource |
Lockfile if present, otherwise requirements | Only when lockfile is missing | Yes | Convenience command for local setup |
Update-PSLResource |
Requirements | Yes | Yes | Re-resolve dependencies after changing requirements |
Restore-PSLResource |
Lockfile | No | Yes | Explicit reproducible restore, especially for CI |
Uninstall-PSLResource |
Requirements after removal | Yes | Yes | Remove direct dependencies from the project |
- pslrm does not include its own dependency solver. PSResourceGet resolves dependencies.
- pslrm does not attempt strict transitive dependency management. It records what PSResourceGet saved into the lockfile.
Invoke-PSLResourceruns commands in an isolated runspace. The outermost invocation shares the caller host. This keeps host-aware output alive through the async isolated-runspace forwarding path. NestedInvoke-PSLResourcecalls use the default nested runspace host. This avoids propagating child hosts across nested isolated invocations.- NOTE: PSResourceGet models prerelease versions separately from
Version. Example:Version = 6.0.0andPrerelease = alpha5. To preserve prerelease info, pslrm stores versions as normalized strings in the lockfile. Example:6.0.0-alpha5. Ideally, pslrm would use[System.Management.Automation.SemanticVersion]. Windows PowerShell 5.1 does not provide it.