PowerShell: reading and safely modifying an existing script
For service desk, MSP and endpoint technicians who inherit PowerShell scripts (cleanup jobs, account changes, RMM tasks) and need to understand them before changing anything. You should already be able to run cmdlets and use the pipeline (see PowerShell for desktop diagnostics). The course covers reading a script's help, parameters and flow; predicting what happens when a command fails; previewing changes with -WhatIf and -Confirm; what execution policy does and does not protect against; and making one small, tested, recorded change. Examples follow the PowerShell 7.6 documentation; most of it applies to Windows PowerShell 5.1 as well. Ends with a supervisor-graded script review and modification.
- Level
- Intermediate
- Length
- About 90 minutes
- Contents
- 5 lessons · final exam
- Status
- Published · updated 10 Oct 2026
Skills you'll practise
- Read an existing script's help, parameters and flow and identify every line that changes the system
- Predict whether a failing command stops the script, is caught by try/catch, or is silently ignored
- Add and use -WhatIf and -Confirm support to preview a script's changes before they happen
- Choose a safe way to run a reviewed script without weakening execution policy
- Make one small, tested and recorded change to a script using strict mode and a static checker
Course outline
- 1.Read an existing script before you change itLesson · 16 min
- 2.Predict what happens when a command failsLesson · 18 min
- 3.Preview changes with -WhatIf and -ConfirmLesson · 16 min
- 4.Run a reviewed script without weakening execution policyLesson · 14 min
- 5.Make one small, tested and recorded changeLesson · 10 min
- 6.PowerShell: reading and safely modifying an existing script: knowledge checkKnowledge check · 14 questions
- 7.PowerShell: reading and safely modifying an existing script: practical exerciseKnowledge check · 1 question
- 8.Final exam10 questions · passing it completes the course, so people who already know the material can test out
Sources it draws on
The lessons and questions are written from these references, so learners can go back to the original.
- Microsoft Learn: about_Comment_Based_Help (help keywords and where script help must sit)
- Microsoft Learn: about_Quoting_Rules (expandable and verbatim strings)
- Microsoft Learn: about_Functions_Advanced_Parameters (Mandatory and validation attributes)
- Microsoft Learn: about_CommonParameters (ErrorAction values, WhatIf and Confirm)
- Microsoft Learn: about_Try_Catch_Finally (terminating errors, catch order, finally)
- Microsoft Learn: about_Preference_Variables ($ErrorActionPreference, $ConfirmPreference, $WhatIfPreference)
- Microsoft Learn: about_Automatic_Variables ($?, $LASTEXITCODE, $PSCmdlet)
- Microsoft Learn: about_Functions_CmdletBindingAttribute (SupportsShouldProcess and ConfirmImpact)
- Microsoft Learn: about_Execution_Policies (policies, scopes, precedence; not a security boundary)
- Microsoft Learn: Set-StrictMode (what versions 1.0, 2.0 and 3.0 prohibit)
- Microsoft Learn: PSScriptAnalyzer module overview (static code checker)
See it with your own jobs and topics
Tell us about your team and we'll walk you through setup, from choosing jobs to your first skills check.