PS Script that Documents other scripts using AI

Hey Guys,

I am new here and looking for some feedback on a project I am kicking around.

Basically I hate code commenting and documentation but it is super important for keeping an IT department from falling behind the 8-ball when turnover happens. To get around this I am creating a script that I can push other scripts to and it will use the ChatGPT API to create a comment header, code comments and a man page.

Hoping once ChatGPT 4 API is generally available I can get it to generate a flowchart based on the logic of the script. I also want to refine the context of the requests once the 32K context version of ChatGPT 4 API is available as well.

Let me know what you guys think.

First, if half of the stuff I see about this ChatGPT AI is true, it’s revolutionary and extremely intimidating. Seen articles about it writing objectives and code for folks, writing resumes, re-writing blog content, writing emails and now this. Would not be surprised if you could just point it to a API doc website and tell it to write the entire Powershell module for us (seen comparable modules parse Swagger APIs to generate the PS Module). An interesting project as I am finishing up a large Powershell module and documentation is on my list of things to do. Generation of Pester Tests would a fun project too.

I would be extremely careful about what you put into ChatGPT. Theoretically anything you put in can be taken out and that includes sensitive data, credentials etc. I would make sure your code is clean of anything sensitive.

1 Like

yep. Definitely have to make sure scripting best practices for security are used. Like making sure API keys and creds are pulled in from secure sources and not explicitly called out in the script. Enviromental variables is the preferred way for the ChatGPT API. Microsoft actually have a KB on that:

Our corporate folks blocked ChatGPT literally the day it went live for this very reason. I would be surprised if any corporation allows access to the general masses.