Security Power
Chapter 17 of 18
Chapter 17: PowerShell Security and Hardening
Welcome to a chapter that puts safety first. You will learn how PowerShell protects scripts, limits what code can do, and keeps a record you can check later. These skills matter because a small check now can stop a big problem later. You do not need to be an expert to use them well. By the end, you will know how to check a script before you trust it, work inside safe limits, and leave a clear trail of what happened.
4 lessons 3 learning objectives 3 related commands
Topics at a glance: Execution policy and script signing, Constrained language mode, Logging and transcription, Safe scripting and auditing changes.
Where this chapter fits
This chapter comes after Chapter 16: PowerShell for Ethical Hackers in the journey, so ideas from that chapter will feel familiar here.
After this chapter comes Chapter 18: PowerShell Automation Projects.
Learning objectives
By the end of this chapter, you will be able to:
- Explain execution policy, script signing, and constrained language mode in simple terms
- Use transcripts and logging concepts to review what happened after an incident
- Apply safe scripting habits and audit a change before you trust it
Lessons in this chapter
Work through the lessons in order. Each lesson page has explanations, examples, common mistakes, and a knowledge check.
Lesson 1: Execution policy and script signing
Execution policy sets the rules for which scripts may run, and signing adds a trusted mark to a script. Together they help you pause and check before you run code from someone else.
3 things to learn in this lesson
Lesson 2: Constrained language mode
Language mode controls how much of the PowerShell language is available in a session. Constrained language mode narrows that set, so risky language features are not available to code running in that session.
3 things to learn in this lesson
Lesson 3: Logging and transcription
A transcript is a written record of a PowerShell session, and logging records what commands ran. These records help you review work later and understand what happened after an incident.
3 things to learn in this lesson
Lesson 4: Safe scripting and auditing changes
Safe scripting means previewing a change, using the smallest permission that works, and reading a script before you run it. Auditing means checking afterwards that the change is what you intended.
3 things to learn in this lesson
Related command references
These command pages are linked to lessons in this chapter. Each command page has its syntax, parameters, and examples.
Start-Transcript
Starts recording console input and output to a text file.
From the lesson: Logging and transcription
Stop-Transcript
Stops the transcript started by Start-Transcript.
From the lesson: Logging and transcription
Get-AuthenticodeSignature
Checks the digital signature on a file, such as a script.
From the lesson: Execution policy and script signing
Tip: read the lesson first, then use the command page as a quick reference.