See what I did there? 😉
I’ve talked about creating your own script repository in the past. I like having some sort of structure. GitHub goes further. It also helps with version control and so much more!. My idea of version control is adding -v# after any script, don’t judge me…
These days everything seems to be in GitHub! The PowerShell DSC Resource Modules are there. Azure PowerShell Module & Templates are there. You can even deploy Azure Resources from GitHub! You can also use Git for continuous deployment for website content/apps.
Visual Studio supports GitHub as well for continuous delivery
I just discovered Gist! Doug Finke created a GUI to help create a template to extract Data from text files. I noticed that the code was straight out of GitHub. So I did a little bit of googling and sure enough, I found out how! Gist lets you share snippets of code with others. All you need to do is copy & paste the url and you’re good to go!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Author: I. Strachan | |
Version: 1.0 | |
Version History: | |
Purpose: Extract The AppxManifest.xml file from the .appv file. | |
Get the Version,PackageID and VersionID from AppxManifest.xml | |
#> | |
function Get-AppxManifest { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory = $true)] | |
[ValidateScript({ Test-Path -Path $_ -PathType Container })] | |
[string]$Source | |
) | |
begin{ | |
#Load Assembly for Zip | |
Add-Type -assembly 'system.io.compression.filesystem' | |
#get AppV Files from parent Folder | |
$appVFiles = Get-ChildItem -Path $Source -Recurse -Filter ('*.appv') | |
$manifestFolder = "$($PSScriptRoot)\Manifest" | |
if(!(Test-Path -Path $manifestFolder)) { | |
Write-Verbose 'Manifest folder does not exist. Creating folder' | |
New-item -Path $manifestFolder -Type Directory | Out-Null | |
} | |
} | |
process{ | |
#get AppxManifest.xml content | |
$appVFiles | | |
ForEach-Object { | |
$FileName = $_.BaseName | |
$FilePath = $_.FullName | |
#Create handle in orde to dispose File later on | |
$hndZipFile = [System.IO.Compression.ZipFile]::OpenRead($_.FullName) | |
$hndZipFile.Entries | | |
Where-Object { $_.FullName -like 'AppxManifest.xml' } | | |
ForEach-Object { | |
$File = Join-Path $manifestFolder "$($FileName)_$($_.FullName)" | |
[IO.Compression.ZipFileExtensions]::ExtractToFile($_, $File, $true) | |
#Typecast to Get XML | |
[XML]$xml = Get-Content $File | |
[PSCustomObject]@{ | |
Version = $xml.Package.Identity.Version | |
PackageId = $xml.Package.Identity.PackageId | |
VersionId = $xml.Package.Identity.VersionId | |
DisplayName = $xml.Package.Properties.DisplayName | |
AppVPath = $FilePath | |
} | |
} | |
#Close handle on File | |
$hndZipFile.Dispose() | |
} | |
} | |
end{} | |
} |
Best part of Gist is having you code “As-Is”. Using WordPress plugins sometimes gets the “<#” , “#>” or “&” wrong, replacing it with HTML equivalent. This way you’ll never have to worry about your code being mutilated anymore! Sweet!!!
Here’s an article to help you on your way getting started with GitHub.
GitHub is (going to be) one of those things that you need to master…
Hope it’s worth something to you…
Ttyl,
Urv