3.9.2. Common Administrative Scripting Tasks
💡 First Principle: Scripts are most valuable for tasks that are frequent, repetitive, and consistent. Administrative tasks that fit this profile include server startup/shutdown procedures, user account management, service monitoring, and bootstrap configuration. Automating these tasks reduces errors and frees administrators for higher-value work.
Common Scripting Use Cases
| Task | What It Does | Why Script It |
|---|---|---|
| Startup | Start services, check health, log results on boot | Ensures consistent state every time server starts |
| Shutdown | Gracefully stop services, flush caches, log shutdown | Prevents data loss, ensures clean state |
| Service monitoring | Check if services are running; restart if stopped | Automatic recovery without admin intervention |
| Login | Map drives, set environment, apply user settings | Consistent user environment across machines |
| Account creation | Create AD accounts, set initial passwords, assign groups | Eliminates manual errors in provisioning |
| Bootstrap | Initial server configuration after OS install | Ensures every server is identically configured from first boot |
Bootstrap Scripts in Context
Bootstrap scripts run automatically after an unattended OS installation. They:
- Install required applications and agents
- Apply configuration baselines
- Join the domain
- Register with monitoring systems
- Apply initial patches
- Reboot
This is how large-scale deployments achieve consistency: the golden image + bootstrap script produces an identical server every time, regardless of which technician runs the deployment.
⚠️ Exam Trap: A script that runs as a domain account has that account's permissions—if the account lacks rights, the script fails. Scripted tasks often need a service account with specific permissions. This is also a security consideration: a compromised service account can run malicious scripts.
Reflection Question: A server admin writes a PowerShell script that creates new user accounts in Active Directory. The script runs successfully on the admin's workstation but fails when run as a scheduled task. What is the most likely cause?