Using ChatGPT to write PowerShell scripts, SQL code, etc


PhilB

Well-known member
Power User
VIP
Local time
10:13 AM
Posts
857
Location
Western USA
OS
Windows 11 2H25
I've started to play around, nothing too serious yet, with asking ChatGPT, the free version, to write PowerShell scripts. I'm not proud of that but this grey old head doesn't learn new languages the way he used to when he listened to ABBA and the BeeGees.

So I'm wondering what more experienced people think of htis idea. Am I just causing headaches for myself? Better AI models than ChatGPT for this purpose?

I kinda/sorta/not really know SQL, so I'm also thinking I could use ChatGPT to write scripts programs that use sqlite3 database. And if all that works, then maybe even lua scripts for Adobe Lightroom Classic.
 

My Computer My Computer

At a glance

Windows 11 2H25AMD 9900X64 GBAMD 9070 XT
OS
Windows 11 2H25
Computer type
PC/Desktop
Manufacturer/Model
DIY
CPU
AMD 9900X
Motherboard
MSI X870E Carbon
Memory
64 GB
Graphics Card(s)
AMD 9070 XT
Sound Card
built-in
Monitor(s) Displays
Dell 24"
Hard Drives
Sabrent 1 TB NVMe, 4 x SSD (need to check models), 4 x 3.5" HDD, 8-16 TB, all WD
PSU
Seasonic 850
Case
Fractal Design North XL (which I likw)
Cooling
Corsair AIO for CPU, fans for case
Keyboard
Das Keyboard 4
Mouse
Corsair M65 (white)
Internet Speed
1 TB download
Browser
Firefox
Antivirus
Bitdefender
Other Info
Also have Lenovo T14S laptop (me) and Lenovo Slim 71 (wife)
1. the script will be working.
2. the code quality is mediocre.

hence, we tried awhile but not any longer.
my computers are mainly running python, excel macro, , ,
 

My Computer My Computer

At a glance

Windows 7/11Intel i7-11800H32GB DDR4 3200MHzNVIDIA GeForce RTX 3070
OS
Windows 7/11
Computer type
PC/Desktop
Manufacturer/Model
HP/Lenovo/Asus
CPU
Intel i7-11800H
Motherboard
Lenovo Legion 5i Pro Gen 6
Memory
32GB DDR4 3200MHz
Graphics Card(s)
NVIDIA GeForce RTX 3070
Monitor(s) Displays
LG 35WN65C-B
Screen Resolution
3440 x 1440
Hard Drives
1TB PCIe SSD
Other Info
Edition Windows 11 Pro
Version 25H2
Installed on ‎12/‎12/‎2025
OS build 26200.7462
GitHub Copilot is better at writing code. It is purpose-built for this.
 

My Computer My Computer

At a glance

Windows 11 Enterprise 25H2
OS
Windows 11 Enterprise 25H2
I use ChatGPT to code for me with some success. But only simple things.
 

My Computers My Computers

  • At a glance

    Windows 11 Pro 25H2 26200.9168AMD Ryzen 7 5825U with Radeon Graphics16GB
    OS
    Windows 11 Pro 25H2 26200.9168
    Computer type
    Laptop
    Manufacturer/Model
    Acemagic LX15PRO
    CPU
    AMD Ryzen 7 5825U with Radeon Graphics
    Motherboard
    BIOS CT_BI_AMI_LX15PRO_AB8139_A-004
    Memory
    16GB
    Screen Resolution
    1920 x 1080
    Hard Drives
    SSD 2TB
    Internet Speed
    30 Mbps
    Browser
    Brave
    Antivirus
    Webroot SecureAnywhere Complete beta
  • At a glance

    Windows 11 Pro 23H2 22631.2506Atom N450 1.66GHz2GB
    Operating System
    Windows 11 Pro 23H2 22631.2506
    Computer type
    Laptop
    Manufacturer/Model
    HP Mini 210-1090NR PC (bought in late 2009!)
    CPU
    Atom N450 1.66GHz
    Memory
    2GB
    Browser
    Brave
    Antivirus
    Webroot
  • Acer Swift SF114-34 laptop
    OS Windows 11 Pro 26200.8894
    CPU Pentium Silver N6000
    RAM 4GB
    BIOS v1.17
    SSD Samsung 970 EVO Plus SSD 2TB (an upgrade)
I use AI a lot as a coding aid (mostly GitHub Copilot with C#). It relieves me of a lot of tedious research and trial and error to get the structure and syntax correct for Windows APIs.

In general, the smaller the task you give it each time, the greater the success. But a smaller command line tool can be written almost in one go if you give it good instructions. The best instructions are pseudo code. If you write out well thought out pseudo code, the AI can translate that into whatever language you choose.

I find that the results are better with a stricter language, such as C#, than PowerShell. You must also be sure to tell the AI the target context (.Net version, PowerShell version, etc.). For programs with a GUI, you have to break things up into well organized pieces in order to effectively use AI, but it can't see the GUI results, so it's a lot of back and forth.

You have to always keep in mind that it can't see over your shoulder, but it can see your existing code in Copilot. Copilot is also handy for things like code review. You can ask it to review your code and suggest improvements and it usually finds something.
 

My Computer My Computer

At a glance

Windows 10/11
OS
Windows 10/11
Computer type
Laptop
Manufacturer/Model
Acer
I also use AI for refrence on daily basis for small code questions. Somehow i do like CoPilot, however copy pasting from there always seem to go wrong. Go wrong in that some sections i select, get deselected when copying.. So i use other AI websites, and not use CoPilot, maybe once a week, when other AI can't get things right.
For code reviews i use LLM Local AI, so that the codes not get stolen and used in training for AI models. So that means i only ask questions to internet AI on how to do something, rather then copy en past existing code and ask it to change it.
 

My Computer My Computer

At a glance

Windows 11
OS
Windows 11
Computer type
PC/Desktop
Here is a good example of why I use ChatGPT. I asked "how to enable hibernate".

To enable Hibernate in Windows 11 (or Windows 10), follow these steps:


1. Enable Hibernate in Power Options


  1. Press Win + R, type control, and press Enter to open the Control Panel.
  2. Go to Hardware and Sound > Power Options.
  3. Click Choose what the power buttons do from the left panel.
  4. Click Change settings that are currently unavailable.
  5. Under Shutdown settings, tick Hibernate.
  6. Click Save changes.

2. Check if Hibernate is Enabled in the System


  1. Open Command Prompt as Administrator.
  2. Run this command:
    powercfg /availablesleepstates<br>
    If Hibernate is not listed, continue to step 3.

3. Enable Hibernate via Command Line (If Needed)


  1. Open Command Prompt as Administrator.
  2. Type the following and press Enter:
    powercfg /hibernate on<br>

4. Verify Hibernate File Size (Optional)


The hibernation file (hiberfil.sys) can be adjusted for faster startup:


  • To reduce it to 50% of RAM size(enough for Fast Startup but not full hibernation):
    powercfg /h /type reduced<br>
  • To restore full hibernation:
    powercfg /h /type full<br>

5. Add Hibernate to Start Menu (If Missing)


If you don’t see Hibernate in the Start menu:


  1. Go to Control Panel > Power Options.
  2. Click Choose what the power buttons do.
  3. Tick Hibernate under Shutdown settings.

After this, Hibernate should work. Let me know if you run into issues.
 

My Computers My Computers

  • At a glance

    Windows 11 Pro 25H2 26200.9168AMD Ryzen 7 5825U with Radeon Graphics16GB
    OS
    Windows 11 Pro 25H2 26200.9168
    Computer type
    Laptop
    Manufacturer/Model
    Acemagic LX15PRO
    CPU
    AMD Ryzen 7 5825U with Radeon Graphics
    Motherboard
    BIOS CT_BI_AMI_LX15PRO_AB8139_A-004
    Memory
    16GB
    Screen Resolution
    1920 x 1080
    Hard Drives
    SSD 2TB
    Internet Speed
    30 Mbps
    Browser
    Brave
    Antivirus
    Webroot SecureAnywhere Complete beta
  • At a glance

    Windows 11 Pro 23H2 22631.2506Atom N450 1.66GHz2GB
    Operating System
    Windows 11 Pro 23H2 22631.2506
    Computer type
    Laptop
    Manufacturer/Model
    HP Mini 210-1090NR PC (bought in late 2009!)
    CPU
    Atom N450 1.66GHz
    Memory
    2GB
    Browser
    Brave
    Antivirus
    Webroot
  • Acer Swift SF114-34 laptop
    OS Windows 11 Pro 26200.8894
    CPU Pentium Silver N6000
    RAM 4GB
    BIOS v1.17
    SSD Samsung 970 EVO Plus SSD 2TB (an upgrade)
GitHub Copilot with C#… relieves me of a lot of tedious research and trial and error to get the structure and syntax correct for Windows APIs.
Check out CsWin32 in NuGet.
 

My Computer My Computer

At a glance

Windows 11 Enterprise 25H2
OS
Windows 11 Enterprise 25H2

Latest Support Threads

Back
Top Bottom