And the screenshots as I got the hang of it…
Short examples of a mix of passing and failing Pester tests being rendered in a browser, using ReportUnit, available on NuGet, and ingesting NUnit output format. Check out the browser screenshots below first for the end result.
# Runs all test suites, passes the output to the NUnit format, renders it, displays in a browser # see my article here for installing nuget via Choco: # https://dennisaa.wordpress.com/2017/04/26/powershell-updating-jpg-metadata/ # https://www.nuget.org/packages/ReportUnit/ nuget.exe install ReportUnit #Then, for example... # Execute all the tests $outputName = Get-Random $outputFile = "$PSScriptRoot/$outputName.xml" $htmlFile = "$PSScriptRoot/$outputName.html" Invoke-Pester -PassThru -Strict -OutputFile $outputFile -OutputFormat NUnitXml .\ReportUnit.1.2.1\tools\ReportUnit.exe $outputFile Start-Process chrome $htmlFile
$PSScriptRoot returns the parent of the current script/invocation.
Write-Output "1.`$PSScriptRoot:[$PSScriptRoot]" Write-Output "2.Parent:[$(Split-Path -Parent $MyInvocation.MyCommand.Path)]" Write-Output "3.Leaf:[$(Split-Path -Leaf $MyInvocation.MyCommand.Path)]" Write-Output "4.Full path:[$($MyInvocation.MyCommand.Path)]"
I’ve been using Handbrake CLI wrapped in PowerShell to convert some bulky old AVI files to MP4, and then to copy those to DVD for another layer of backup.
I have just finished a pretty extensive repo and Wiki on this subject, on GitHub, here. The intended audience for this is those who can find their way around Windows, but who know nothing about PowerShell.
I’ve now made a video here to illustrate just the AVI to mp4 conversion part.
My use case: Google Photos have removed the ability to save and search by tag. OneDrive Photos do have that ability to save and search tags, but since they have started charging for photos over a certain volume, right now, I want to stick with Google.
To start with, if I can prove that I can programmatically update 1 metadata element in 1 photo, in PowerShell, then everything else (searching, bulk updating) can wait until another day.
Marcel wrote his jpg metadata utility in C#, with, quite reasonably, no assembly/dll saved on Github. But let’s assume I have no C# compiler available. Well helpfully, he also made an entry on Nuget, which indirectly gives me access to the DLL.
However, natively, Nuget is not available to PowerShell. But Chocolatey hosts an implementation of Nuget, so I can run that:
choco install nuget.commandline
A quick check that we have a working Nuget:
Now, because we know that NuGet knows of the metadata utility, we can ask NuGet to install it:
NuGet.exe install Xpericode.JpegMetadata
The dll [XperiCode.JpegMetadata.dll] is concealed at the bottom level of the created folder [XperiCode.JpegMetadata.0.9.0], so find the dll, and copy it to the current folder, for ease of reference. Load the assembly:
Add-Type -Path .\XperiCode.JpegMetadata.dll
Now you have to find a test jpg from somewhere… in fact cos I’m nice you can use my one here:
Save that to a place, and then run this (adjusted for your location):
$jpg = New-Object XperiCode.JpegMetadata.JpegMetadataAdapter("c:\sandbox\powershell\BartonOnSea01.jpg")
How do I know that is the command? Because Marcel helpfully said so:
And now the money shot – the expected result from this next action is that on opening the jpeg from File Explorer, the Title element is set as requested:
$jpg.Metadata.Title = "Work, damn you, WORK!" $jpg.Save() $jpg = $null
Finally, all the key commands together:
choco install nuget.commandline NuGet.exe install Xpericode.JpegMetadata Add-Type -Path .\XperiCode.JpegMetadata.dll $jpg = New-Object XperiCode.JpegMetadata.JpegMetadataAdapter("c:\sandbox\powershell\BartonOnSea01.jpg") $jpg.Metadata.Title = "Work, damn you, WORK!" $jpg.Save() $jpg = $null