Update export-to-serenade.ps1

This commit is contained in:
Markus Fleschutz 2021-11-23 07:53:19 +01:00
parent af8f300a40
commit cf4c1c6ffa

View File

@ -1,6 +1,6 @@
<#
.SYNOPSIS
Exports all scripts to Serenade for voice control
Exports all scripts to Serenade
.DESCRIPTION
This script exports all PowerShell scripts to Serenade to execute them by voice.
.PARAMETER WakeWord
@ -13,8 +13,9 @@
Specifies the target file ("$HOME\.serenade\scripts\PowerShell.js" by default)
.EXAMPLE
PS> ./export-to-serenade.ps1 Computer
Exporting 496 PowerShell scripts to C:\Users\Markus\.serenade\scripts\PowerShell.js...
exported 496 scripts with wake word "Computer" to Serenade in 3 sec
Found 499 PowerShell scripts...
Writing to C:\Users\Markus\.serenade\scripts\PowerShell.js using wake word "Computer"...
export to Serenade finished in 3 sec
.NOTES
Author: Markus Fleschutz · License: CC0
.LINK
@ -29,7 +30,8 @@ try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()
$Scripts = Get-ChildItem "$FilePattern"
"⏳ Found $($Scripts.Count) scripts, exporting them to $TargetFile..."
"⏳ Found $($Scripts.Count) PowerShell scripts..."
"⏳ Writing $TargetFile using wake word `"$WakeWord`"..."
"/* NOTE: This file has been generated automatically by export-to-serenade.ps1 */" | Set-Content "$TargetFile"
foreach ($Script in $Scripts) {
@ -39,7 +41,7 @@ try {
}
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ exported $($Scripts.Count) PowerShell scripts with wake word `"$WakeWord`" to Serenade in $Elapsed sec"
"✔️ export to Serenade finished in $Elapsed sec"
exit 0 # success
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"