Skip to content

Instantly share code, notes, and snippets.

View dfinke's full-sized avatar

Doug Finke dfinke

View GitHub Profile
$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
@dfinke
dfinke / ExcelPlots.ps1
Created September 20, 2024 13:43
Create Excel bar chart using PowerShell by repeating symbols based on values with custom styling
$data = ConvertFrom-Csv @"
Name,UnitsSold
John,100
Jane,200
Tom,120
Jane,300
Jim,150
Mary,250
"@
@dfinke
dfinke / Invoke-GitHubChat.ps1
Last active September 20, 2024 02:02
PowerShell script for querying AI models via GitHub API and retrieving chat completions
$prompt = "capital of france?"
$model = "gpt-4o-mini"
# $model = "o1-preview"
$headers = @{
    "Content-Type"  = "application/json"
    "Authorization" = "Bearer $($env:GITHUB_TOKEN)"
}
$body = @{