Claude AI for IT Professionals: Using Claude AI to Work With Scripts

Are you an IT Professional wondering how you can use generative AI tools to become more productive? In this clip from my Anthropic: Prompt Engineering for IT Administrators course on Pluralsight you will see how you can use Claude AI to work with Scripts!

Full Anthropic: Prompt Engineering for IT Administrators

Video Summary

Here are the key points from the video:

  • Introduction to Claude: The speaker logs into a free Claude account and explains that the course will use this free account for all activities, ensuring no payment is needed.
  • Explaining PowerShell Scripts: Claude can analyze and explain existing PowerShell scripts, detailing what each part does and providing a summary of the script’s function, which is helpful for IT administrators who inherit scripts they don’t fully understand.
  • Creating Scripts with Claude: Claude can also generate new scripts based on user specifications. For example, it can create a PowerShell script to add a new user to Azure AD, including all necessary modules and commands.
  • Asking Questions About Scripting: Users can ask Claude questions about scripting, such as which languages can be used to create a virtual machine in AWS. Claude provides relevant examples and explanations based on the context of the conversation.
  • Troubleshooting Scripts: Claude can help troubleshoot errors in scripts by identifying issues and suggesting corrections. For instance, it can point out syntax errors and provide the corrected version of a PowerShell script.

For more information, read the transcript blog below, or watch the video above!

Video Transcript

With the introduction done, let’s head over to the lab and start using Claude to be more productive. In this first demo, we will learn how to use Claude to work with scripts. I’m now in the lab environment. Let me open up the browser over here, where I simply went to Claude.ai and logged into a free account because everything that we will do in this course will be with a free account, so there is no payment needed for you to do everything that I’m doing in this course.

Now, how can Claude help? Let me first go through my first scenario here, which is something that has happened to me quite a lot as IT administrators. One of our big duties is to script things, whether it’s maintenance or productivity tasks. A lot of the time, we start working at a company, and some scripts have already been created for us, especially in some systems that maybe we do not know as much about because, as IT administrators, we manage so many systems. So, in this case, I work at a company, and then I have this report here that another admin created before I joined the company, but I don’t really understand it. So, what I can do is I can ask Claude to explain the following PowerShell script for me. It will analyze the script and then explain to me what each property does. In the end, I even have the summary: in summary, the script retrieves all the SharePoint online sites in the current tenant, selects the site URL, current storage usage, storage quota, and the percentage of the quota used. The output is then sorted in descending order based on the current storage usage, and it tells me how this can be helpful. You can see for each property selected, it’s telling me exactly what it does. So, AI can be a great way for you to better understand the scripts that you are running.

Now, let’s take a look at another example because Claude can not only understand scripts but it can also create them. I could ask Claude, “Can you create a new PowerShell script for me that will add a new user to Azure AD?” Here are the properties: first name Vlad, last name Catrinescu, I have the username in there, the country and I’m also telling it what PowerShell module to use. I’m telling it, “Hey, use the PowerShell SDK module.” So, let’s let it run a little bit here. It will always take one or two seconds. You see, at the end, I’m telling it to use the Graph PowerShell SDK. If you want it to use a certain module or a certain API, be specific because the more specific you are with generative AI solutions, the better result you will get, or you will get a result that matches your expectations. So, here in this case, as you can see, it gave me a PowerShell script. It even added the import modules, it added the connect to the MG graph, all the properties that I gave it, and then it created the new user. Awesome! I even have the breakdown of the script so I can better understand it. But remember, creating scripts with generative AI is a bit like copying scripts off the internet. Make sure to always test them in Dev or in QA before you run them in production. Never copy-paste scripts off the internet. That’s the first rule for IT professionals.

Okay, now let’s talk about something else to do with scripting because I’m going to switch subjects here at the left. I will start a new chat because generative AI solutions have a memory; they understand the context of the current chat. So, as we’ve been talking about PowerShell, I want to talk about something else now, and it’s always better to start a new chat and tell it, “Hey, we are going to switch subjects. Forget that I asked you about SharePoint and Azure AD and PowerShell. We are going to now talk about something completely new.” So, I can also ask Claude questions about a certain script. For example, I can ask it, “I need to create a new virtual machine in AWS by script. What language can I use?” Now it will tell me all the different languages that I can use to do that, and it will even give me some examples. In this case, it was a Python script that it gave me. Great! I can read all of that. You see, it explains to me each one of them, what it can do. Now, let me ask it, let’s go to the bottom here, I want to ask it, “Give me a script to create a virtual machine in my default region. The image ID is,” and I have an ID here, I have the instance type, the key name, and the security group. Notice I did not say in AWS; however, because of the context of the conversation, it knows that it’s in AWS here, so I didn’t need to specify it. That’s why it’s important to start a new conversation when you switch subjects. Now it knows we are talking about AWS, so whatever I ask it now if I don’t specify, it will assume it has to do with AWS. Because the previous one, gave me a Python script using Boto3, you can see the script that it gave me here also uses the same language. Again, if I wanted C# or I wanted something else, I should have specified it. Awesome!

Okay, let’s start a new chat and let’s look at a final example for scripting. I can ask Claude, “Hey, I’m running into an error with the following script. Can you tell me what I did wrong?” Now it will look over the script and it will tell me what I did wrong. So, it looks like you’re trying to display disk information using the Get-WmiObject cmdlet in PowerShell. That’s exactly what I’m doing. However, there seems to be a syntax issue with the way you’re constructing the calculated properties. So now it’s telling me, “Hey, you need to wrap the script blocks (the expressions) within curly braces with double quotation marks.” It explains to me everything and it gives me the corrected version. Awesome!

Okay, this is it for this quick demo on how we can use Claude to be more productive when working with scripts.

Blogs and Videos