Skip to content

Instantly share code, notes, and snippets.

View dfinke's full-sized avatar

Doug Finke dfinke

View GitHub Profile
@dfinke
dfinke / PSConvoBot.ps1
Created August 29, 2023 21:25
Simulates a conversation between two bots
class Bot {
[string] $Convo
[string] $Name
[string] $Context
[object] $Client
[object[]] $History
Bot([string] $convo, [string] $name, [string] $context, [object] $client, [object[]] $history) {
$this.Convo = $convo
$this.Name = $name
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dfinke
dfinke / prompt.ps1
Created July 1, 2023 13:55
PowerShell prompt to display a chat is in progress at the PS cli
function prompt {
if (Get-Command Test-ChatInProgress -ErrorAction SilentlyContinue) {
$filler = ''
if (Test-ChatInProgress) {
$Provider = Get-ChatAPIProvider
if ($Provider -eq 'AzureOpenAI') {
$model = (Get-AzureOpenAIOptions)['DeploymentName']
}
else {
$model = (Get-ChatSessionOptions)['model']
@dfinke
dfinke / Invoke-ExcelTemplate.ps1
Last active June 30, 2023 02:24
Generates an Excel spreadsheet based on a given query.
function Invoke-ExcelTemplate {
<#
.SYNOPSIS
Generates an Excel spreadsheet based on a given query.
.DESCRIPTION
The Invoke-ExcelTemplate function generates an Excel spreadsheet based on a given query. The function takes a single parameter, $q, which represents the query to be used for generating the spreadsheet.
.PARAMETER q
The query to be used for generating the spreadsheet.
@dfinke
dfinke / other.md
Last active May 2, 2023 11:03
PowerShell AI covered by others
Date Author Title Type Link
4/2023 Mikey Bronowski A Brief Introduction to PowerShellAI: An Intelligent Command Line Article https://www.sqlservercentral.com/articles/a-brief-introduction-to-powershellai-an-intelligent-command-line
4/2023 Darren J Robinson Generative AI ChatGPT with PowerShell Post https://blog.darrenjrobinson.com/generative-ai-chatgpt-with-powershell/
4/2023 Trond E Haavarstein Win32App, Intune Tweet https://twitter.com/xenappblog/status/1651893224171077632?s=20
5/2023 PowerShellMichael The PowerShellAI Module! Let's Automate! Tweet https://www.youtube.com/watch?v=UFY5Ynjqg2c
5/2023 Juergen Klaassen JumpCloud PowerShell Module and the PowerShellAI Module Post https://community.jumpcloud.com/t5/community-scripts/experimenting-with-the-jumpcloud-powershell-module-in/m-p/2777/highlight/true#M230
5/2023 Merlijn Van Waeyenberghe GPT - Your AI Scripting Buddy Conference https://mms2023atmoa.sched.com/event/1LS3Y/gpt-your-ai-scripting-buddy
5/2023 Use ChatGPT OpenAI
@dfinke
dfinke / cosine_similarity.ps1
Last active April 27, 2023 00:19
Calculates the cosine similarity between two vectors - All generated by ChatGPT at the command line
# Install-Module PowerShellAI
function cosine_similarity {
param(
[Parameter(Mandatory = $true)]
[double[]]$a,
[Parameter(Mandatory = $true)]
[double[]]$b
)
@dfinke
dfinke / Invoke-OpenAI
Last active November 28, 2022 13:17
Convert natural language commands into executable PowerShell using OpenAI
<#
Aims to grow the understanding of using OpenAI in PoweShell by providing an example of an implementation and references
#>
function Invoke-OpenAI {
<#
.SYNOPSIS
Convert natural language commands into commands in PowerShell
.EXAMPLE
function Invoke-Speak {
param($msg)
Add-Type -AssemblyName System.Speech
$speaker = New-Object System.Speech.Synthesis.SpeechSynthesizer
$speaker.Speak($msg)
}
function getmessage {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dfinke
dfinke / psncal.ps1
Created March 19, 2022 13:39
Print the calendar vertically i.e. the weekdays will be shown in a column, not in a row
function psncal {
<#
.SYNOPSIS
Print the calendar vertically i.e. the weekdays will be shown in a column, not in a row
.EXAMPLE
psncal
.EXAMPLE
psncal 1