Read the script before it runs

Módulo 1: What AI already does in your job

Temario del curso

Esta lección aún no está en tu idioma, así que aquí la tienes en inglés.

Prueba rápida

Guess first, no penalty. An AI script should disable accounts nobody has used in 90 days. Its key line is $cutoff = (Get-Date).AddDays(90). It runs with no error. What happens?

PowerShell is the command language Windows admins use to make changes in bulk. Active Directory (AD) holds your company's user accounts. AI can write a script for both in seconds, and the script runs with your permissions.

One missing minus sign. No error, no warning. Monday morning, nobody can sign in.

Worked example

Antes y después

The AI's script, then the safer version. Highlights show what changed.

AI script

$cutoff = (Get-Date).AddDays(90) Get-ADUser -Filter * -Properties LastLogonDate | Where-Object { $_.LastLogonDate -lt $cutoff } | Disable-ADAccount

Three changes:

  • The cutoff is 90 days in the past.
  • It only looks at enabled staff accounts in one OU (a folder of accounts), so admin and service accounts elsewhere are left alone.
  • -WhatIf "Displays a message that describes the effect of the command, instead of executing the command" (Microsoft Learn). You read the list before anything changes.

Completa los espacios

Fill the gaps in the dry-run version.

Script

$cutoff = (Get-Date).AddDays() Get-ADUser -Filter -Properties LastLogonDate | Where-Object { $_.LastLogonDate -and $_.LastLogonDate -lt $cutoff } | Disable-ADAccount

Show a finished AI help desk card
MY SETUP: Windows 11, Outlook and Teams, Cisco Secure Client VPN,
Microsoft 365 sign-in.
ASK AI: setup + what changed + what I tried + "list your assumptions".
BEFORE I SEND: version checked, vendor docs checked, no password
requests and no security steps for the user.
SCRIPTS: save the current state, -WhatIf, a batch of 10, log it.
INTERVIEW LINE: added in the next lesson.

Try it

Tus pasos, unos 2 minutos

0 de 1
  1. 1.Add your script rule to your card: save the current state, -WhatIf first, then a batch of 10. Use it on one AI-written script for a routine task before you run anything.2 min

Práctica

Pregunta 1 de 3

You add -WhatIf to the end of Disable-ADAccount in a script and run it. What happens?

Tutor de IA

Pregunta sobre esta lección y recibe ayuda con la tarea de “Pruébalo”. El tutor es parte de Learn Pro.

Ver Learn Pro