So this is my first button/script post.
I needed something to do Ham Radio Call signs without having to go to a Web Browser. So I wrote a PowerShell Script and created a button for it. Sharing here in case there are any other HAMS out there.
Here is the Button Code.
<?xml version="1.0"?>
<button backcol="none" display="both" textcol="#00ffff">
<label>Call Sign Lookup</label>
<tip>Lookup a Ham Radio Call Sign</tip>
<icon1>#newcommand</icon1>
<function type="normal">
<instruction>powershell.exe -noexit C:\Scripts\Callookinfo.ps1 {dlgstring|Enter Call Sign} {dlgchoose|Select Output Type|TEXT=text+JSON=json+XML=xml}</instruction>
</function>
</button>
Here is the PowerShell script Callookinfo.ps1.
<#
.SYNOPSIS
Ham Radio Call Sign Lookup
.DESCRIPTION
This will do a Call Sign Lookup from https://callook.info
.PARAMETER CallSign
<Ham Radio Call Sign>
OutputFormat
<Format desired for output (json, xml, text)>
.INPUTS
CallSign
OutputFormat
.OUTPUTS
Call Sign Information in format Requested.
Output options: XML, JSON, TEXT
.NOTES
Script Name: Callookinfo.ps1
Version: 1.0
Author: Richard Knechtel
Creation Date: 11/08/2017
Purpose/Change: Initial script development
.EXAMPLE
powershell.exe C:\Scripts\Callookinfo.ps1 KD9HSO text
#>
#---------------------------------------------------------[Script Parameters]------------------------------------------------------
param(
[Parameter(Mandatory=$true)]
[string]$CallSign,
[Parameter(Mandatory=$true)]
[ValidateSet("json","xml","text")]
[string]$OutputFormat
)
#---------------------------------------------------------[Initialisations]--------------------------------------------------------
#Set Error Action to Silently Continue
$ErrorActionPreference = 'SilentlyContinue'
$global:ReturnCodeMsg = "Completed Successfully"
#----------------------------------------------------------[Declarations]----------------------------------------------------------
#Script Version
$sScriptVersion = "1.0"
#-----------------------------------------------------------[Execution]------------------------------------------------------------
try
{
# Lookup Call Sign
$Response=Invoke-WebRequest -Uri "https://callook.info/index.php?callsign=$CallSign&display=$OutputFormat"
Write-Host $Response
}
catch
{
# catch any errors and report them
$ErrorMessage = $_.Exception.Message;
$FailedItem = $_.Exception.ItemName;
# Set return code/message
$global:ReturnCodeMsg="There was an Error in Callookinfo.ps1."
}
finally
{
# Do any Clean up here
}
# Some Value or Variable
return $ReturnCodeMsg