{"id":9187,"date":"2022-12-16T12:04:33","date_gmt":"2022-12-16T17:04:33","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=9187"},"modified":"2022-12-16T12:04:37","modified_gmt":"2022-12-16T17:04:37","slug":"friday-fun-powershell-scripting-with-chatgpt","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9187\/friday-fun-powershell-scripting-with-chatgpt\/","title":{"rendered":"Friday Fun: PowerShell Scripting with ChatGPT"},"content":{"rendered":"\n<p>I have been trying out the latest AI, <a href=\"https:\/\/chat.openai.com\/chat\" target=\"_blank\" rel=\"noreferrer noopener\">ChatGPT<\/a>. I've asked it silly questions.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/woodchuck.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"360\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/woodchuck-1024x360.png\" alt=\"ChatGPT conversation about woodchucks\" class=\"wp-image-9188\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/woodchuck-1024x360.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/woodchuck-300x105.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/woodchuck-768x270.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/woodchuck-1536x540.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/woodchuck-850x299.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/woodchuck.png 1840w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>As well as the really important questions.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/dreams.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"382\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/dreams-1024x382.png\" alt=\"do dogs dream?\" class=\"wp-image-9189\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/dreams-1024x382.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/dreams-300x112.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/dreams-768x287.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/dreams-1536x574.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/dreams-850x317.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/dreams.png 1864w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>But what I find most fascinating is using ChatGPT to write PowerShell code. I gave the AI this instruction: \"Write a PowerShell function that will display \"Hello, World\" in the center of the screen in alternating colors. Include a parameter to have the message blink.\". After a few seconds, it generated this code.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">function Show-HelloWorld {\n    [CmdletBinding()]\n    param(\n        [Parameter(Mandatory=$true)]\n        [ValidateSet(\"On\", \"Off\")]\n        [string]$Blink\n    )\n\n    # Clear the screen\n    Clear-Host\n\n    # Set the text colors to alternate between red and green\n    $colors = @(\"Red\", \"Green\")\n    $colorIndex = 0\n\n    # Set the cursor position to the center of the screen\n    $x = (Get-Host).UI.RawUI.WindowSize.Width \/ 2\n    $y = (Get-Host).UI.RawUI.WindowSize.Height \/ 2\n\n    # Set the cursor position and display the message\n    Write-Host \"Hello, World\" -ForegroundColor $colors[$colorIndex] -NoNewline\n    $host.UI.RawUI.CursorPosition = New-Object System.Management.Automation.Host.Coordinates $x, $y\n\n    # Toggle the text color and blink the message if the Blink parameter is set to \"On\"\n    while ($Blink -eq \"On\") {\n        Start-Sleep -Milliseconds 500\n        $colorIndex = ($colorIndex + 1) % 2\n        Write-Host \"`b\" -NoNewline\n        Write-Host \"Hello, World\" -ForegroundColor $colors[$colorIndex] -NoNewline\n    }\n}<\/code><\/pre>\n\n\n\n<p>You need to think of this process as scripting with a friend who might still be learning PowerShell. To the AI's credit, it used a proper verb for the function. It was smart enough to realize clearing the screen would be necessary. And the scripting language is what I would expect from someone just getting started. Although, it didn't make my blink option a switch, or even a boolean value. But that is easy enough to change. I'll run it without blinking.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/hello1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"558\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/hello1-1024x558.png\" alt=\"hello world\" class=\"wp-image-9190\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/hello1-1024x558.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/hello1-300x164.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/hello1-768x419.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/hello1-1536x837.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/hello1-2048x1117.png 2048w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/hello1-850x463.png 850w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Not quite what I had in mind. Adding blinking also wasn't what I hoped for.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/hello2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/hello2-1024x558.png\" alt=\"hello world again\" class=\"wp-image-9191\" width=\"840\" height=\"457\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/hello2-1024x558.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/hello2-300x164.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/hello2-768x419.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/hello2-1536x837.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/hello2-2048x1117.png 2048w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/hello2-850x463.png 850w\" sizes=\"auto, (max-width: 840px) 100vw, 840px\" \/><\/a><\/figure>\n\n\n\n<p>I asked ChatGPT to revise the function.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Revise the function to use ANSI escape sequences or $PSStyle. Each character should be a different color.<\/p>\n<\/blockquote>\n\n\n\n<p>The result wasn't much better, and failed to run. Here's an excerpt.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">  # Set the text colors to alternate between red and green\n        $colors = @(\"31\", \"32\")\n        $colorIndex = 0\n\n        # Set the cursor position to the center of the screen\n        $x = (Get-Host).UI.RawUI.WindowSize.Width \/ 2\n        $y = (Get-Host).UI.RawUI.WindowSize.Height \/ 2\n\n        # Set the cursor position and display the message\n        Write-Host \"H\" -NoNewline\n        Write-Host \"e\" -NoNewline -ForegroundColor $colors[$colorIndex]\n        $colorIndex = ($colorIndex + 1) % 2\n        Write-Host \"l\" -NoNewline -ForegroundColor $colors[$colorIndex]\n        $colorIndex = ($colorIndex + 1) % 2\n        Write-Host \"l\" -NoNewline -ForegroundColor $colors[$colorIndex]\n        $colorIndex = ($colorIndex + 1) % 2\n        Write-Host \"o\" -NoNewline -ForegroundColor $colors[$colorIndex]\n        $colorIndex = ($colorIndex + 1) % 2\n        Write-Host \", \" -NoNewline -ForegroundColor $colors[$colorIndex]<\/code><\/pre>\n\n\n\n<p>But I could use the code as a starting point and revise it with what I know about PowerShell. The point I'm making is that using AI, even something like CodePilot, can be a great help, but it won't teach you PowerShell, and you are still responsible for writing effective and proper code.<\/p>\n\n\n\n<p>That said, let me leave you with two more functions I asked ChatGPT to create for me. I wanted a function to display a fractal in the console window. One function creates a Julia set.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">function Show-JuliaSet {\n    [cmdletbinding()]\n    param (\n      [double]$cReal = -0.8,\n      [double]$cImag = 0.156,\n      [int]$width = 80,\n      [int]$height = 24,\n      [int]$maxIterations = 256\n    )\n\n    # Create the Julia set function\n    function julia {\n      param (\n        [double]$cReal,\n        [double]$cImag,\n        [int]$width,\n        [int]$height,\n        [int]$maxIterations\n      )\n\n      # Calculate the pixel values for the Julia set\n      $pixels = for ($y = 0; $y -lt $height; $y++) {\n        for ($x = 0; $x -lt $width; $x++) {\n          # Map the pixel coordinates to the complex plane\n          $zReal = [math]::Round((($x \/ $width) * 3.5) - 2.5, 2)\n          $zImag = [math]::Round((($y \/ $height) * 2) - 1, 2)\n\n          # Iterate the Julia set equation\n          $iteration = 0\n          while (($zReal * $zReal + $zImag * $zImag) -lt 4) {\n            $tempReal = $zReal * $zReal - $zImag * $zImag + $cReal\n            $zImag = 2 * $zReal * $zImag + $cImag\n            $zReal = $tempReal\n            $iteration++\n            if ($iteration -ge $maxIterations) {\n              break\n            }\n          }\n\n          # Return the number of iterations as a pixel value\n          $iteration\n        }\n      }\n\n      # Print the Julia set to the console\n      for ($y = 0; $y -lt $height; $y++) {\n        for ($x = 0; $x -lt $width; $x++) {\n          $pixel = $pixels[$y * $width + $x]\n          if ($pixel -eq $maxIterations) {\n            Write-Host \".\" -NoNewline\n          } else {\n            Write-Host \" \" -NoNewline\n          }\n        }\n        Write-Host \"\"\n      }\n    }\n\n   # Call the Julia set function\n  julia -cReal $cReal -cImag $cImag -width $width -height $height -maxIterations $maxIterations\n}<\/code><\/pre>\n\n\n\n<p>I inverted the original display code. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/julia.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"558\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/julia-1024x558.png\" alt=\"julia fractal in a PowerShell console\" class=\"wp-image-9192\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/julia-1024x558.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/julia-300x164.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/julia-768x419.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/julia-1536x837.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/julia-2048x1117.png 2048w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/julia-850x463.png 850w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>I have to admit, I would never have figured out the math part, and that is definitely true in the Mandelbrot function.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">function Show-MandelbrotSet {\n    [cmdletbinding()]\n    param (\n      [int]$width = 80,\n      [int]$height = 24,\n      [int]$maxIterations = 256\n    )\n\n    # Create the Mandelbrot set function\n    function mandelbrot {\n      param (\n        [int]$width,\n        [int]$height,\n        [int]$maxIterations\n      )\n\n      # Calculate the pixel values for the Mandelbrot set\n      $pixels = for ($y = 0; $y -lt $height; $y++) {\n        for ($x = 0; $x -lt $width; $x++) {\n          # Map the pixel coordinates to the complex plane\n          $cReal = [math]::Round((($x \/ $width) * 3.5) - 2.5, 2)\n          $cImag = [math]::Round((($y \/ $height) * 2) - 1, 2)\n          $zReal = 0\n          $zImag = 0\n\n          # Iterate the Mandelbrot set equation\n          $iteration = 0\n          while (($zReal * $zReal + $zImag * $zImag) -lt 4) {\n            $tempReal = $zReal * $zReal - $zImag * $zImag + $cReal\n            $zImag = 2 * $zReal * $zImag + $cImag\n            $zReal = $tempReal\n            $iteration++\n            if ($iteration -ge $maxIterations) {\n              break\n            }\n          }\n\n          # Return the number of iterations as a pixel value\n          $iteration\n        }\n      }\n\n      # Print the Mandelbrot set to the console\n      for ($y = 0; $y -lt $height; $y++) {\n        for ($x = 0; $x -lt $width; $x++) {\n          $pixel = $pixels[$y * $width + $x]\n          if ($pixel -eq $maxIterations) {\n            Write-Host \" \" -NoNewline\n          } else {\n            Write-Host \".\" -NoNewline\n          }\n        }\n        Write-Host \"\"\n      }\n    }\n\n    # Call the Mandelbrot set function\n    mandelbrot -width $width -height $height -maxIterations $maxIterations\n  }<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/mandelbrot.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"558\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/mandelbrot-1024x558.png\" alt=\"mandelbrot fractal in a powershell console\" class=\"wp-image-9193\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/mandelbrot-1024x558.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/mandelbrot-300x164.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/mandelbrot-768x419.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/mandelbrot-1536x837.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/mandelbrot-2048x1117.png 2048w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/mandelbrot-850x463.png 850w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>I'll let you take these functions and develop them further.<\/p>\n\n\n\n<p>I find coding with an AI quite fascinating. I definitely don't worry about being replaced any time soon. But the AI can take some of the grunt work from coding and may even offer an approach that you hadn't even considered. Think of the AI as a muse for inspiration.<\/p>\n\n\n\n<p>What have been your experiences scripting an AI or using CodePilot in VSCode?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have been trying out the latest AI, ChatGPT. I&#8217;ve asked it silly questions. As well as the really important questions. But what I find most fascinating is using ChatGPT to write PowerShell code. I gave the AI this instruction: &#8220;Write a PowerShell function that will display &#8220;Hello, World&#8221; in the center of the screen&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"New on the blog: Friday Fun - #PowerShell Scripting with #ChatGPT","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,8],"tags":[676,534,540],"class_list":["post-9187","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","tag-ai","tag-powershell","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Friday Fun: PowerShell Scripting with ChatGPT &#8226; The Lonely Administrator<\/title>\n<meta name=\"description\" content=\"I have some fun writing PowerShell functions with ChatGPT. AI won&#039;t replace us as scripters, but can offer inspiration and provide a jump start.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/9187\/friday-fun-powershell-scripting-with-chatgpt\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Friday Fun: PowerShell Scripting with ChatGPT &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"I have some fun writing PowerShell functions with ChatGPT. AI won&#039;t replace us as scripters, but can offer inspiration and provide a jump start.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/9187\/friday-fun-powershell-scripting-with-chatgpt\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-16T17:04:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-12-16T17:04:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/woodchuck-1024x360.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9187\\\/friday-fun-powershell-scripting-with-chatgpt\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9187\\\/friday-fun-powershell-scripting-with-chatgpt\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Friday Fun: PowerShell Scripting with ChatGPT\",\"datePublished\":\"2022-12-16T17:04:33+00:00\",\"dateModified\":\"2022-12-16T17:04:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9187\\\/friday-fun-powershell-scripting-with-chatgpt\\\/\"},\"wordCount\":414,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9187\\\/friday-fun-powershell-scripting-with-chatgpt\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/woodchuck-1024x360.png\",\"keywords\":[\"AI\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9187\\\/friday-fun-powershell-scripting-with-chatgpt\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9187\\\/friday-fun-powershell-scripting-with-chatgpt\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9187\\\/friday-fun-powershell-scripting-with-chatgpt\\\/\",\"name\":\"Friday Fun: PowerShell Scripting with ChatGPT &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9187\\\/friday-fun-powershell-scripting-with-chatgpt\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9187\\\/friday-fun-powershell-scripting-with-chatgpt\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/woodchuck-1024x360.png\",\"datePublished\":\"2022-12-16T17:04:33+00:00\",\"dateModified\":\"2022-12-16T17:04:37+00:00\",\"description\":\"I have some fun writing PowerShell functions with ChatGPT. AI won't replace us as scripters, but can offer inspiration and provide a jump start.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9187\\\/friday-fun-powershell-scripting-with-chatgpt\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9187\\\/friday-fun-powershell-scripting-with-chatgpt\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9187\\\/friday-fun-powershell-scripting-with-chatgpt\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/woodchuck.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/woodchuck.png\",\"width\":1840,\"height\":647},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9187\\\/friday-fun-powershell-scripting-with-chatgpt\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Friday Fun: PowerShell Scripting with ChatGPT\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Friday Fun: PowerShell Scripting with ChatGPT &#8226; The Lonely Administrator","description":"I have some fun writing PowerShell functions with ChatGPT. AI won't replace us as scripters, but can offer inspiration and provide a jump start.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9187\/friday-fun-powershell-scripting-with-chatgpt\/","og_locale":"en_US","og_type":"article","og_title":"Friday Fun: PowerShell Scripting with ChatGPT &#8226; The Lonely Administrator","og_description":"I have some fun writing PowerShell functions with ChatGPT. AI won't replace us as scripters, but can offer inspiration and provide a jump start.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9187\/friday-fun-powershell-scripting-with-chatgpt\/","og_site_name":"The Lonely Administrator","article_published_time":"2022-12-16T17:04:33+00:00","article_modified_time":"2022-12-16T17:04:37+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/woodchuck-1024x360.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9187\/friday-fun-powershell-scripting-with-chatgpt\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9187\/friday-fun-powershell-scripting-with-chatgpt\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Friday Fun: PowerShell Scripting with ChatGPT","datePublished":"2022-12-16T17:04:33+00:00","dateModified":"2022-12-16T17:04:37+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9187\/friday-fun-powershell-scripting-with-chatgpt\/"},"wordCount":414,"commentCount":5,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9187\/friday-fun-powershell-scripting-with-chatgpt\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/woodchuck-1024x360.png","keywords":["AI","PowerShell","Scripting"],"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/9187\/friday-fun-powershell-scripting-with-chatgpt\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9187\/friday-fun-powershell-scripting-with-chatgpt\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9187\/friday-fun-powershell-scripting-with-chatgpt\/","name":"Friday Fun: PowerShell Scripting with ChatGPT &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9187\/friday-fun-powershell-scripting-with-chatgpt\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9187\/friday-fun-powershell-scripting-with-chatgpt\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/woodchuck-1024x360.png","datePublished":"2022-12-16T17:04:33+00:00","dateModified":"2022-12-16T17:04:37+00:00","description":"I have some fun writing PowerShell functions with ChatGPT. AI won't replace us as scripters, but can offer inspiration and provide a jump start.","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9187\/friday-fun-powershell-scripting-with-chatgpt\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/9187\/friday-fun-powershell-scripting-with-chatgpt\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9187\/friday-fun-powershell-scripting-with-chatgpt\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/woodchuck.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/12\/woodchuck.png","width":1840,"height":647},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9187\/friday-fun-powershell-scripting-with-chatgpt\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Friday Fun: PowerShell Scripting with ChatGPT"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":6142,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6142\/join-me-for-a-2-day-powershell-scripting-workshop\/","url_meta":{"origin":9187,"position":0},"title":"Join Me for a 2 Day PowerShell Scripting Workshop","author":"Jeffery Hicks","date":"November 12, 2018","format":false,"excerpt":"I am very happy to announce a 2 day public PowerShell learning event. In association with the fine people behind the Techmentor conference, I will be presenting a 2 day PowerShell Scripting workshop in Dallas, TX on February 4-5, 2019. There is an option to attend virtually, but you'll really\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"announcer-blue","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/announcer-blue_thumb.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":4169,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4169\/friday-fun-updated-ise-scripting-geek-module\/","url_meta":{"origin":9187,"position":1},"title":"Friday Fun: Updated ISE Scripting Geek Module","author":"Jeffery Hicks","date":"January 9, 2015","format":false,"excerpt":"A few years ago I published a module with a number of functions and enhancements for the PowerShell ISE. This ISEScriptingGeek module has remained popular over the last few years. But I wrote it for PowerShell v2. I have also come up with a number of new additions to the\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"geek","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/01\/geek-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":677,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/677\/teched-2010-deck\/","url_meta":{"origin":9187,"position":2},"title":"TechEd 2010 VBScript to PowerShell","author":"Jeffery Hicks","date":"June 15, 2010","format":false,"excerpt":"Last week I posted my demo slides as well as my demo videos. As promised, I've gone through and expanded a bit on my original slide deck.\u00a0 TechEdNA-2010-Hicks-ParadigmShift is a 3MB PDF of my expanded PowerPoint slide deck. If you have any questions about the content or what it takes\u2026","rel":"","context":"In &quot;Conferences&quot;","block_context":{"text":"Conferences","link":"https:\/\/jdhitsolutions.com\/blog\/category\/conferences\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3117,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/3117\/msdevwny-powershell-advanced-functions\/","url_meta":{"origin":9187,"position":3},"title":"MSDevWNY PowerShell Advanced Functions","author":"Jeffery Hicks","date":"June 20, 2013","format":false,"excerpt":"Last night I presented for the MSDevWNY user group in the Buffalo, NY area. They were an interested and enthusiastic audience and I think we could have spent another few hours talking about PowerShell. My presentation was one I've given before on Advanced PowerShell functions. I promised the group a\u2026","rel":"","context":"In &quot;Best Practices&quot;","block_context":{"text":"Best Practices","link":"https:\/\/jdhitsolutions.com\/blog\/category\/best-practices\/"},"img":{"alt_text":"talkbubble-v3","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/05\/talkbubble-v3-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":748,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/748\/get-your-free-scripting-toolkit\/","url_meta":{"origin":9187,"position":4},"title":"Get Your Free Scripting Toolkit","author":"Jeffery Hicks","date":"July 29, 2010","format":false,"excerpt":"If you were at this year's TechEd event in New Orleans, I hoped you dropped by the SAPIEN Technologies booth and picked up your free Scripting Toolkit. What's that you say? Check it out on the SAPIEN blog and then download your free copy.","rel":"","context":"In &quot;Books&quot;","block_context":{"text":"Books","link":"https:\/\/jdhitsolutions.com\/blog\/category\/books\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":92,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/92\/powershell-dba\/","url_meta":{"origin":9187,"position":5},"title":"PowerShell DBA","author":"Jeffery Hicks","date":"January 26, 2007","format":false,"excerpt":"There is a very nice review of the new Powershell book at : http:\/\/weblog.infoworld.com\/dbunderground\/archives\/2007\/01\/rtfm.html. I'm glad he likes the book, even though he doesn't know who I am. But I'm working on it!! Anyway, the interesting point in his review is that he is looking at PowerShell from the perspective\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/9187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=9187"}],"version-history":[{"count":1,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/9187\/revisions"}],"predecessor-version":[{"id":9194,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/9187\/revisions\/9194"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=9187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=9187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=9187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}