Skip to content

Instantly share code, notes, and snippets.

View dfinke's full-sized avatar

Doug Finke dfinke

View GitHub Profile
$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 = @{
@dfinke
dfinke / Get-WorkSummary.ps1
Created September 14, 2024 23:10
PowerShell script lists recent files; AI analyzes your work—instantly see what you've accomplished!
param(
$daysOld = 7
)
$targetDir = $(
'D:\mygit\GPTIdeas\Experiments\Livestream-GPT\'
'D:\mygit\PowerShellAIAssistant-ScratchPad'
'D:\mygit\PSAI'
'D:\mygit\PSAIAgent-Stealth-2\'
'D:\temp\Camtasia\scratch\'
@dfinke
dfinke / Show-ExcelSumProduct.ps1
Last active September 9, 2024 08:35
This script exports CSV data to an Excel file, formats it, and applies a SUMPRODUCT formula.
$sumData = ConvertFrom-Csv @"
ProductName, VendorName, TotalSales
Macbook, Apple
Desktop, DELL
RAM, Lenovo
HDD, HCL
Laptop, IBM
Mouse, Acer
"@
@dfinke
dfinke / Show-GitLikeDiff.ps1
Created August 25, 2024 18:31
Git-like Diff Tool in PowerShell
# Git-like Diff Tool in PowerShell
function Compare-Files {
param (
[string]$OldFilePath,
[string]$NewFilePath,
[int]$ContextLines = 3
)
$oldFile = Get-Content -Path $OldFilePath
@dfinke
dfinke / Compare-PicsUsingAI.ps1
Last active August 10, 2024 17:18
AI-powered image comparison in PowerShell using PSAI module
# Install-module PSAI
# Get OpenAI API key from https://platform.openai.com/account/api-keys
# Set $env:OpenAIKey
function Compare-PicsUsingAI {
param(
$pic1,
$pic2
)
@dfinke
dfinke / powershell-agent-team.ps1
Last active July 29, 2024 10:55
The difference between building LLM-powered applications in summer 2024 vs summer 2023?
<#
This PowerShell script is powered by my PSAI and PSAIAgent modules.
PSAI - Is a port of the OpenAI Python SDK
PSAIAgent - Is a PowerShell module that allows you turn an OpenAI LLM into an AI Assistant with memory and tools
Register-Tool - Takes PowerShell functions signatures and creates the JSON to be used by OpenAI
New-Agent - Creates an AI Agent that can be used to interact with OpenAI
Get-AgentResponse - Takes the agent and prompt, calls the OpenAI model, runs the functions if needed and returns the response
#>
@dfinke
dfinke / Singleton.ps1
Created June 28, 2024 13:50
PowerShell Singleton Pattern: Ensure single instance for shared resource management
# Singleton
class Product {
$Name
Product($name) {
$this.Name = $name
}
}

PowerShell Issues FAQ

General

Q: How frequently are issues in the PowerShell repository reviewed? A: The frequency of issue reviews can vary; however, issues are often reviewed when they are newly created. Regular review cycles might also be in place depending on the projectΓÇÖs maintenance policy.

Q: How can I determine if a cmdlet/module is maintained in the PowerShell repository? A: You can use the repository's search function, issue templates, and officially provided documentation to determine if a cmdlet/module is maintained in the powershell/powershell repository.