Skip to content

Instantly share code, notes, and snippets.

View dfinke's full-sized avatar

Doug Finke dfinke

View GitHub Profile
# 📦 Install-Module: PSAISuite
# 🔗https://github.com/dfinke/psaisuite
# Get-ChatProviders
# PSAISuite supports 13 providers, and their models.
# $model = "github:openai/gpt-4.1"
$model = "anthropic:claude-opus-4-20250514"
param(
[int]$Year = (Get-Date).Year,
[int]$Month = (Get-Date).Month
)
# Set up day names
$days = @("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")
# Print header
Write-Host ""
$Inst = @"
You are powershell expert and an Excel expert and a ImportExcel expert.
I want to create an Excel template. I'll provide you with all the options to
include in the template, and when I have finished,
you'll format it as an .xlsx file to be saved in the current directory.
just the code, no explanation, no comments, no markdown, no fence blocks
"@
#Requires -Module PSAISuite
# Step 1: Generate PowerShell function from a prompt (Model A - GPT-4)
$genPrompt = @"
You're a PowerShell expert.
Write a function that takes a CSV file and creates an Excel file using ImportExcel module.
Return only the code.
"@
@dfinke
dfinke / MorseCodeConverter.ps1
Created March 15, 2025 17:46
A PowerShell script to convert text to Morse code and vice versa
function Convert-TextToMorse {
param (
[Parameter(Mandatory = $true)]
[string]$Text
)
$morseDict = @{
'A' = '.-'; 'B' = '-...'; 'C' = '-.-.'; 'D' = '-..'; 'E' = '.'; 'F' = '..-.'
'G' = '--.'; 'H' = '....'; 'I' = '..'; 'J' = '.---'; 'K' = '-.-'; 'L' = '.-..'
'M' = '--'; 'N' = '-.'; 'O' = '---'; 'P' = '.--.'; 'Q' = '--.-'; 'R' = '.-.'
@dfinke
dfinke / Show-GridView.ps1
Last active March 20, 2025 18:59
A PowerShell 7 function mimicking Out-GridView basics on Windows.
function Show-GridView {
param (
[Parameter(Mandatory, ValueFromPipeline)] $InputObject
)
begin {
Add-Type -AssemblyName System.Windows.Forms
$data = New-Object 'System.Collections.Generic.List[Object]'
}
process {
$data.Add([PSCustomObject]$InputObject)
function Save-JsonToExcel {
<#
.SYNOPSIS
Saves a JSON string to an Excel file.
.PARAMETER Json
The JSON string to save.
.PARAMETER Path
The path to save the Excel file to.
#>
param(
$config = @{
Preferences = @{
defaultAgent = "StockAgent"
}
WebSearchAgent = @{
Name = "WebSearch"
LLM = New-OpenAIChat 'gpt-4o-mini'
Instructions = "Today is $(Get-Date)"
@dfinke
dfinke / fafo.ps1
Last active November 13, 2024 01:59
function map {
param(
$func,
[Parameter(ValueFromRemainingArguments = $true)]
$arrays
)
$arrays | ForEach-Object {
if ($arrays[0].Length -ne $_.Length) {
throw "All arrays must be of the same length"
$text1 = Read-Host "Enter text"
Set-Clipboard -Value $text1
$text2 = Get-Clipboard
$text2