This script helps people encode/decode any file to/from a byte-array encoded plain text file.
Simply install file-encoder script from the PowerShell Gallery.
Install-Module -Name file-encoder
-
When encoding, no need to enter the
-SavePath
parameter, it will default to changing the file name froma.zip
toa.enc
Encode-File .\a.zip Decode-File .\a.enc .\b.zip
-
When encoding, pass in the file to be read and the new file to be written
Encode-File .\a.zip .\a.txt Decode-File .\a.txt .\b.zip
The encoded file will always be a ASCII encoding plain text file.
-
When encoding, pass in the file to be read and the new file to be written, but explicitly specify parameter names
Encode-File -FilePath .\a.zip -SavePath .\a.txt Decode-File -FilePath .\a.txt -SavePath .\b.zip
-
Validate the script using
Invoke-ScriptAnalyzer
cmdletInstall-Module -Name PSScriptAnalyzer
Invoke-ScriptAnalyzer -Path ./file-encoder.psm1
-
Test publishing for PowerShell Gallery
With the following command, you can test whether the module can be successfully published. The
-WhatIf
parameter here will not actually publish your module, but rather test if there are any issues during the publishing process.Publish-Module ` -Path "G:\Projects\linqpad-folders-powershell-module\" ` -NuGetApiKey $env:PowerShellGalleryApiKey ` -WhatIf ` -Verbose
-
Publish to PowerShell Gallery
Simply remove the
-WhatIf
parameter to perform the actual publishing operation.Publish-Module ` -Path "G:\Projects\linqpad-folders-powershell-module\" ` -NuGetApiKey $env:PowerShellGalleryApiKey ` -Verbose
Finally, if you see the following message, it means the publishing was successful!
VERBOSE: Successfully published module 'linqpad-folders-powershell-module' to the module publish location 'https://www.powershellgallery.com/api/v2/package/'. Please allow few minutes for 'linqpad-folders-powershell-module' to show up in the search results.