Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

WIP: PowerShell Archive Support #81

Open
wants to merge 30 commits into
base: master
Choose a base branch
from

Conversation

romero126
Copy link

PowerShell Archive Support

On of biggest desired features of mine has always been a PSProvider for Archive/ZipFile Support in powershell. So for the past few months I have been working on creating a PSProvider that supports opening and active manipulation of ZipFiles.

Motivation

The ability to utilize a ZipFile like a FileSystemProvider opens the door for Automation components by allowing automated tasks to work directly inside an Archive instead of FileSystem.

This implimentaiton would allow Sys admins to Preview/Modify configuration of tools like Nuget or log files.

User Experience

Prelimnary code has been uploaded to my Github under PS1C

Current Code base is Previewable on:

https://github.com/romero126/ps1c

It can be checkedout on Gallery for Windows Only Currently;

Install-Module PS1C
Import-Module PS1C
New-PSDrive -Name TestDrive -PSProvider ZipFile -Root "ZipFile.Zip" -ErrorAction "Stop"
Push-Location TestDrive:\
# Go to town

Specification

The Desire to feel as close to the FileSystem Provider as possible sets a very natural feel to the user experience.

Testing Requirements

Code must maintain rigourous testing standards and must meet all Applicable FileSystem Provider based tests

Current Provider Varience and Language Constraints

Currently PSProviders locked down certain features/functionality natively.

  • Invoke-Item is locked down to the FileSystemProvider
    • Both & and .
    • Invoke-Command
    • Invoke-Expression
  • Get-Content -Tail is limited to FileSystemProvider because BackReader is not publicly available.

Example of Use

PS>Install-Module PS1C -Force
PS>Import-Module PS1C
PS>New-PSDrive -Name NewDrive -PSProvider ZipFile -Root "$Pwd\ZipFile.zip"

Name        Used (GB)  Free (GB) Provider   Root                                CurrentLocation
----        ---------  --------- --------   ----                                ---------------
NewDrive                         ZipFile    C:\Users\Romero126\Documents\Softw…

PS>Push-Location NewDrive:\
PS>Get-ChildItem

LastWriteTime             Length   Name                      FullName
-------------             ------   ----                      --------
8/12/2019 3:04:26 PM      50       _InvokeCommand.ps1        TestDrive:\_InvokeCommand.ps1
8/3/2019 9:18:32 PM       4        Binary.txt                TestDrive:\Binary.txt
9/26/2019 12:33:16 PM     17       dynamicfile.txt           TestDrive:\dynamicfile.txt
9/26/2019 12:33:16 PM     14       dynamicfile2.txt          TestDrive:\dynamicfile2.txt
8/3/2019 9:18:02 PM       191      Multiline.txt             TestDrive:\Multiline.txt
9/27/2019 12:11:08 PM     0        newDirectory              TestDrive:\newDirectory\
8/7/2019 10:42:52 PM      62       Test.txt                  TestDrive:\Test.txt

PS>Get-Content Test.txt
8/12/2019 10:07:17 PM : 8ab0b829-9b71-4c11-9cfa-33d1295901db
PS>("{0} : {1}" -f (Get-Date).ToString(), (New-Guid)) | Set-Content Test.txt -PassThru
9/27/2019 2:32:19 PM : 44ef9073-71ec-41c4-8013-a4ce5cc2832d
PS>Get-Content Test.txt
9/27/2019 2:32:19 PM : 44ef9073-71ec-41c4-8013-a4ce5cc2832d
PS>Get-Item NewTestFile.txt

LastWriteTime             Length   Name                      FullName
-------------             ------   ----                      --------
9/27/2019 2:34:02 PM      11       NewTestFile.txt           TestDrive:\NewTestFile.txt

PS>Get-Item NewTestFile.txt | Get-Content
NewItemData
PS>

@romero126
Copy link
Author

Hey if your interested.. I got the module working.. Next step is to figure out how to integrate this with the actual module.

in the main project dotnet build should build everything.. but there are still a few things to do for a full build /test scenario

import-module .\src\Microsoft.PowerShell.Archive\bin\Debug\netcoreapp3.1\Microsoft.PowerShell.Archive.dll;New-PSDrive -Name dr -PSProvider Archive -Root $pwd\PathToAnArchive;

@romero126
Copy link
Author

Hey @anmenaga,
I am very interested in your feedback. What do you think about this PR?
Its getting quite a bit closer to a final product, I am very interested in if integrating this would be good.

Currently it works on PWSH Core only.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant