Skip to content

PoshWeb/OP

OP

OP

An Overpowered little module for Open Packages

Anything can be a package.

This command helps you make anything into a package.

The following types of packages are currently supported:

  • Any Open Packaging Convention files
  • Any directory
  • Any *.zip file
  • Any *.tar.gz file
  • Any nuget package
  • Any git repository
  • Any public at protocol URI
  • Any dictionary (including nested dictionaries)
  • Any url
  • Any file

Anything can be a package.

Once we start to treat anything as a package, we can do amazing things with packages.

Like:

  • Inspect any packages before we work with them.
  • Modify the packages to customize their content.
  • Split packages
  • Filter our components.
  • Join them back together.
  • Search package content.
  • Work with compressed trees of data.
  • Have an in-memory containerized virtual filesystem.
  • Serve a package from memory.
  • Store data to N package layers.

To put it simply, open packages are overpowered.

Installing and Importing

You can install OP from the PowerShell gallery

Install-Module OP -Scope CurrentUser -Force

Once installed, you can import the module with:

Import-Module OP -PassThru

You can also clone the repo and import the module locally:

git clone https://github.com/PoshWeb/OP
cd ./OP
Import-Module ./ -PassThru

Functions

OP has 17 functions

Copy-OpenPackage

Copies Open Packages

Copies Contents from one packages to another.

Examples
Example 1
Copy-OpenPackage -DestinationPath ./Examples/Copy.docx -InputObject ./Examples/Sample.docx -Force
Parameters
Name Type Description
Destination PSObject The destination.
If this is not a [IO.Packaging.Package], it will be considered a file path.
Include String[] Includes the specified parts.

Enter a wildcard pattern, such as *.txt

Wildcards are permitted.
Exclude String[] Excludes the specified parts.

Enter a wildcard pattern, such as *.txt

Wildcards are permitted.
IncludeContentType String[] Includes the specified content types.

Enter a wildcard pattern, such as text/*
ExcludeContentType String[] Excludes the specified content types.

Enter a wildcard pattern, such as text/*
InputObject PSObject The input object
Force SwitchParameter If set, will update existing packages.

Export-OpenPackage

Exports OpenPackage packages

Exports loaded packages to a file or directory.

Parameters
Name Type Description
DestinationPath String The package file path.
If this has no extension, it will be considered a directory name.
If the path already exists and is a directory, it will be considered a directory name.
Include String[] Includes the specified parts.

Enter a wildcard pattern, such as *.txt
Exclude String[] Excludes the specified parts.

Enter a wildcard pattern, such as *.txt
IncludeContentType String[] Includes the specified content types.

Enter a wildcard pattern, such as text/*
InputObject PSObject The input object.
This must be a package loaded with this module.
Force SwitchParameter If set, will force the export even if a file already exists.

Format-OpenPackage

Formats Open Package

Formats Open Packages using any view.

Parameters
Name Type Description
View PSObject The name of the view, or a view command or scriptblock
ArgumentList PSObject[] The Any Positional arguments for the view
InputObject PSObject[] Any input objects.
Option IDictionary Any options or parameters to pass to the View

Get-OpenPackage

Gets Open Packages

Gets Open Packages from almost anything.

Anything can be a package.

This command helps you make anything into a package.

The following types of packages are currently supported:

  • Any Open Packaging Convention files
  • Any directory
  • Any *.zip file
  • Any *.tar.gz file
  • Any url
  • Any public nuget package
  • Any git repository
  • Any public at protocol URI
  • Any dictionary (including nested dictionaries)
  • Any single file

Anything can be a package.

Once we start to treat anything as a package, we can do amazing things with packages.

Like:

  • Inspect any packages before we work with them.
  • Modify the packages to customize their content.
  • Split packages
  • Filter our components.
  • Join them back together.
  • Search package content.
  • Work with compressed trees of data.
  • Have an in-memory containerized virtual filesystem.
  • Serve a package from memory.
  • Store data to N package layers.
Examples
Example 1

Make the current directory into a package (do not try this at $home)

Get-OpenPackage .
Example 2

Make the module into a package

$opPackage = Get-Module OP | Get-OpenPackage
Example 3
$opPackage = Get-Module OP | 
    Get-OpenPackage -Include *.ps1
Example 4

Another way to make the current directory into a package (do not try this at $home)

Get-Item . | Get-OpenPackage
Example 5

Get a package from nuget

$Avalonia = OP https://www.nuget.org/packages/Avalonia/
Example 6

Get a package from Chocolatey

$chocoPackage = op https://community.chocolatey.org/packages/chocolatey
Example 7

Get a package from the PowerShell gallery

$turtlePackage = op https://powershellgallery.com/packages/Turtle
Example 8

Get a package from a single URL

$imagePackage = op https://MrPowerShell.com/MrPowerShell.png
Example 9

Create a package from multiple URLs by piping back to ourself

$svgAndPng = op https://MrPowerShell.com/MrPowerShell.png |
    op https://MrPowerShell.com/MrPowerShell.svg
Example 10

Get a package from an at protocol URI

$atPost = op at://mrpowershell.com/app.bsky.feed.post/3k4hf5dy6nf2g
Example 11

Get the most recent 50 posts

$atLast50 = op at://mrpowershell.com/app.bsky.feed.post/ -First 50
Example 12

Get all standard.site.documents for a user

$standardSiteDocuments = op at://mrpowershell.com/site.standard.document/

Links

Parameters
Name Type Description
ArgumentList PSObject[] Any unnamed arguments to the command.
Each argument will be treated as a potential -FilePath or -Uri.
Once the first related verb is detected, these will become arguments to that verb
(For example, op . start will get an open package and then start a server for that package)
FilePath String The path of a file to import
At String[] Gets Open Packages with @ syntax.
Without a domain, @ will be presumed to be a github
With a domain, @ will look for an https url, and check at protocol
Uri Uri[] A URI to package.
If this URI is a git repository, will make a package out of the repository
If this URI is a nuget package url or powershell gallery url, will download the package.
Headers IDictionary Any additional headers to pass into a web request.
Repository String A Repository to package.
This can be the root of a repo or a link to a portion of the tree.
If a portion of the tree is provided, will perform a sparse clone of the repository
Branch String The github branch name.
SparseFilter String[] One or more optional sparse filters to a repository.
If these are provided, only files matching these filters will be downloaded.
AtUri String[] An At Uri to package.
This can be a single post or a collection of all posts of a type.
PDS String The personal data server. This is used in At Protocol requests.
Dictionary IDictionary Adds a dictionary of content to the package
BasePath String The base path within the package.
Content should be added beneath this base path.
NuGet Uri A Nuget Uri to package.
The package at this location will be downloaded and opened directly.
NodePackage String[] One or more Node Packages.
PythonPackage String[] One or more Python Packages.
Module PSObject A module to package
A loaded module name or moduleinfo object to package.
The loaded module must have a path property.
The files in this path will be packaged.
Include String[] A list of file wildcards to include.
Exclude String[] A list of file wildcards to exclude.
TypeMap IDictionary A content type map.
This maps extensions and URIs to a content type.
CompressionOption CompressionOption The compression option.
InputObject PSObject One or more input objects.
Installed SwitchParameter Gets the packages that are currently installed
Running SwitchParameter Gets packages that are currently running in a server
Force SwitchParameter If set, will force the redownload of various resources and remove existing files or directories
IncludeHidden SwitchParameter If set, will include hidden files and folders, except for files beneath .git
IncludeGit SwitchParameter If set, will include the .git directory contents if found.
By default, this content will be excluded.
IncludeNodeModule SwitchParameter If set, will include any content found in /node_modules.
By default, this content will be excluded.
IncludeSite SwitchParameter If set, will include any content found in /_site.
By default, this content will be excluded.
IncludeTotalCount SwitchParameter
Skip UInt64
First UInt64

Install-OpenPackage

Installs an OpenPackage

Installs an OpenPackage into a destination on disk.

Parameters
Name Type Description
ArgumentList PSObject[] The arguments to Get-OpenPackage.
DestinationPath String The destination path.

If provided, this should be a directory, but can be a file.

If multiple packages will be installed and a -DestinationPath was provided,
all packages will be installed into that destination path.

If no destination path is provided,
only packages with an identifier will be installed.

Packages will install beneath the first $env:OpenPackagePath.

If the package has a version, it will install into a versioned subdirectory.
Include String[] Includes the specified parts.

Enter a wildcard pattern, such as *.txt
Exclude String[] Excludes the specified parts.

Enter a wildcard pattern, such as *.txt
IncludeContentType String[] Includes the specified content types.

Enter a wildcard pattern, such as text/*
ExcludeContentType String[] Excludes the specified content types.

Enter a wildcard pattern, such as text/*
InputObject PSObject The input object. If this is not a package, it will be passed thru.
Force SwitchParameter If set, will overwrite existing files.
Clear SwitchParameter If set, will clear the destination directory before installing.
PassThru SwitchParameter If set, will output the files that are expanded from the package.
WhatIf SwitchParameter
Confirm SwitchParameter

Join-OpenPackage

Joins Open Packages

Joins multiple open packages into a single open package

Parameters
Name Type Description
InputObject PSObject
Include String[] Includes the specified parts.

Enter a wildcard pattern, such as *.txt

Wildcards are permitted.
Exclude String[] Excludes the specified parts.

Enter a wildcard pattern, such as *.txt

Wildcards are permitted.
IncludeContentType String[] Includes the specified content types.

Enter a wildcard pattern, such as text/*
ExcludeContentType String[] Excludes the specified content types.

Enter a wildcard pattern, such as text/*
Force SwitchParameter

Lock-OpenPackage

Locks an Open Package

Locks an Open Package.

Closes the package and copies it into a read-only package.

Examples
Example 1

Import OP, make it a package, and lock it

Import-Module OP -PassThru | 
    Get-OpenPackage |
    Lock-OpenPackage
Example 2

Import OP, make it a package, and lock it

impo OP -PassThru | op | lkop
Parameters
Name Type Description
InputObject PSObject The input object. This should be a package.

New-OpenPackage

Creates an empty open package

Creates an new empty open package

Publish-OpenPackage

Publishes Open Package

Publishes Open Packages using any OpenPackage.Publisher or command.

Parameters
Name Type Description
Publisher PSObject[] The name of the Publisher, or a command or script block used to Publish.
One or more publishers may be provided. They will be processed in the order provided.
ArgumentList PSObject[] The Any Positional arguments for the view
InputObject PSObject[] Any input objects.
Option IDictionary Any options to pass to the View
WhatIf SwitchParameter
Confirm SwitchParameter

Read-OpenPackage

Reads Open Package Bytes

Reads Bytes within an Open Package

Examples
Example 1
$package = OP @{"hello.txt" = "Hello world"}
$package |
    Read-OpenPackage -Uri /hello.txt
Example 2
$package = OP @{"hello.txt" = "Hello world"}
($package |
    Read-OpenPackage -Uri /hello.txt -RangeStart 0 -RangeEnd 5) -as 'char[]'
Example 3
$package = OP @{"hello.txt" = "Hello world"}
($package |
    Read-OpenPackage -Uri /hello.txt -RangeStart 0 -RangeEnd 5) -as 'char[]' -join ''
Parameters
Name Type Description
Uri Uri[] One or more part uris
RangeStart Int64 A start range
RangeEnd Int64 An ending range
InputObject PSObject The input object.
If this is not a package, it will be passed thru.

Remove-OpenPackage

Removes parts from an open package

Removes content parts from an open package.

Examples
Example 1
Get-OpenPackage @{
    "a.html" = "<h1>a html file</h1>"
} |
    Remove-OpenPackage -Uri '/a.html'
Example 2
Get-OpenPackage @{
    "a.html" = "<h1>a html file</h1>"
    "a.css" = "body { max-width: 100vw; height: 100vh}"
} |
    Select-OpenPackage -Include *.html |
    Remove-OpenPackage
Parameters
Name Type Description
Uri Uri[] One or more URIs to remove
InputObject PSObject The input object.
If this is not a package, the input will be passed thru and nothing will be removed.
WhatIf SwitchParameter
Confirm SwitchParameter

Select-OpenPackage

Selects Open Package content

Selects content from an Open Package using Regular Expressions or XPath

Parameters
Name Type Description
Pattern PSObject[] A list of patterns to match.
SimpleMatch SwitchParameter Indicates that the cmdlet uses a simple match rather than a regular expression match.
CaseSensitive SwitchParameter Indicates that the cmdlet matches are case-sensitive. By default, pattern matches aren't case-sensitive.
Quiet SwitchParameter Indicates that the cmdlet returns a simple response instead of a [MatchInfo] object.
The returned value is $true if the pattern is found or $null if the pattern is not found.
List SwitchParameter Only the first instance of matching text is returned from each input file.
This is the most efficient way to retrieve a list of files that have contents matching the regular expression.
NoEmphasis SwitchParameter By default, Select-String highlights the string that matches the pattern you searched for with the
-Pattern parameter. The -NoEmphasis parameter disables the highlighting.
Include String[] Includes the specified parts.

Enter a wildcard pattern, such as *.txt

Wildcards are permitted.
Exclude String[] Excludes the specified parts.

Enter a wildcard pattern, such as *.txt

Wildcards are permitted.
IncludeContentType String[] Includes the specified content types.

Enter a wildcard pattern, such as text/*
ExcludeContentType String[] Excludes the specified content types.

Enter a wildcard pattern, such as text/*
NotMatch SwitchParameter The -NotMatch parameter finds text that doesn't match the specified pattern.
AllMatches SwitchParameter Indicates that the cmdlet searches for more than one match in each line of text.
Without this parameter, Select-String finds only the first match in each line of text.

When Select-String finds more than one match in a line of text, it still emits only one
[MatchInfo] object for the line, but the .Matches property of the object contains all the
matches.
Context Int32[] Captures the specified number of lines before and after the line that matches the pattern.

If you enter one number as the value of this parameter, that number determines the number of lines
captured before and after the match. If you enter two numbers as the value, the first number
determines the number of lines before the match and the second number determines the number of lines
after the match. For example, -Context 2,3.
Raw SwitchParameter Causes the cmdlet to output only the matching strings, rather than MatchInfo objects. This is
the results in behavior that's the most similar to the Unix grep or Windows findstr.exe
commands.
XPath PSObject Specifies an XPath search query. The query language is case-sensitive.
Namespace IDictionary Specifies a hash table of the namespaces used in the XML.

Use the format@{<namespaceName> = <namespaceValue>}.

When the XML uses the default namespace, which begins with xmlns, use an arbitrary key for the
namespace name. You cannot use xmlns. In the XPath statement, prefix each node name with the
namespace name and a colon, such as //namespaceName:Node.
AstCondition ScriptBlock[] One or more Abstract Syntax Tree conditions.
These will select elements in any PowerShell scripts that match the condition.
InputObject PSObject The input object. This should be a package.

Set-OpenPackage

Sets Open Package content

Sets content in an Open Packaging Conventions archive.

Examples
Example 1
$miniServer = Get-OpenPackage |
    Set-OpenPackage -Uri '/index.html' -Content ([xml]"<h1>Hello World</h1>") -ContentType text/html |
    Start-OpenPackage
Start-Process -FilePath $miniServer.Name
Parameters
Name Type Description
Uri Uri The uri to set
Content PSObject The content to set.
ContentType String The content type. By default, text/plain
Depth Int32 The serialization depth.
Option IDictionary The options used to write the content.
InputObject PSObject The input object.
This must be a package, and it must be writeable.
Force SwitchParameter Sets a part, even if it already exists.

Split-OpenPackage

Splits Open Packages

Splits Open Packages into multiple parts

Examples
Example 1
Get-Module OP |
    OP | 
    Split-OpenPackage
Parameters
Name Type Description
Property PSObject[] One or more properties to group.
Include String[] Includes the specified parts.

Enter a wildcard pattern, such as *.txt

Wildcards are permitted.
Exclude String[] Excludes the specified parts.

Enter a wildcard pattern, such as *.txt

Wildcards are permitted.
IncludeContentType String[] Includes the specified content types.

Enter a wildcard pattern, such as text/*
ExcludeContentType String[] Excludes the specified content types.

Enter a wildcard pattern, such as text/*
InputObject PSObject

Start-OpenPackage

Starts a OpenPackage Server

Starts a server, using one or more archive packages as the storage.

Parameters
Name Type Description
ArgumentList PSObject[] The path to an Open Package file, or a glob that matches multiple Open Package files.
RootUrl String The root url.
By default, this will be automatically to a random local port.
If running elevated, can be any valid http listener prefix, including http://*/
InputObject PSObject[] The input object. This can be provided to avoid loading a file from disk.
Allow String[] The allowed http verbs.
TypeMap IDictionary The content type map
Invokable SwitchParameter If set, the scripts in the package will be invokable.
This turns allows every PowerShell script in the package into server side code.
This should be used cautiously, and only with known packages.
ThrottleLimit UInt16 The throttle limit.
This is the number of concurrent jobs that can be running at once.
BufferSize UInt32 The buffer size.
If parts are smaller than this size, they will be streamed.
If parts are larger than this size, they will be handled in the background
(and may use a buffer of this size when accepting range requests)
Lifespan TimeSpan The lifespan of the server.
If provided, will automatically stop the server after it's life is over.
NodeCount Byte The number of nodes to run.
Each node can handle incoming requests.

Uninstall-OpenPackage

Uninstalls OpenPackages

Uninstalls one or more OpenPackages.

Parameters
Name Type Description
Identifier String[] The package identifier.
If this is a fully qualified directory or file name, it will be removed.
Version String[] The package version
PackagePath String[] The direct path to any number of packages.
This will Remove-Item these paths
PackageRoot String[] The root location where packages are stored.
By default, this will be the locations specified in $env:OpenPackagePath
WhatIf SwitchParameter
Confirm SwitchParameter

Write-OpenPackage

Writes bytes to an Open Package

Writes bytes directly to an Open Package part. The part must already exist.

This can be used to rapidly update small segments of a package.

It can also corrupt package contents, and should be used with care.

To set package parts, use Set-OpenPackage

Examples
Example 1
$package = OP @{"hello.txt" = "Hello world"}
$package |
    Write-OpenPackage -Uri /hello.txt -Buffer ($outputEncoding.GetBytes("y")) |
    Get-OpenPackage ./hello.txt
Parameters
Name Type Description
Uri Uri The Package Part Uri. This is the path to the content within a package.
Content PSObject The content to write.
Depth Int32 The serialization depth.
Option IDictionary The options used to write the content.
RangeStart Int64 The starting location for the write.
InputObject PSObject The package.

2025-2026 Start-Automating

LICENSE

About

Overpowered module for Open Packages

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors