Introduction
PowerShell is one of the most powerful administrative tools on modern Windows systems. However, executing scripts downloaded from the internet requires proper security precautions.
Step 1: Inspect Script Contents
Always open the .ps1 script in Visual Studio Code, Notepad, or PowerShell ISE before running it. Look out for unexpected network requests or obfuscated commands.
Get-Content .\cleanup-toolkit.ps1 -TotalCount 20
Step 2: Unblock Downloaded Files
Windows automatically marks files downloaded from web browsers with an alternate data stream (Zone.Identifier). To unblock:
Unblock-File -Path .\cleanup-toolkit.ps1
Step 3: Check Execution Policy
If you receive an execution policy error, you can bypass it for your single session without weakening system-wide security:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Conclusion
By following these simple steps, you can safely leverage administrative automation scripts while maintaining full control over your environment.