Define the desired state
Write the desired state in plain language before writing the script. Then map it to one observable signal. Avoid scripts that silently combine unrelated fixes because they are difficult to test and assign safely.
Make repair idempotent
Running a repair twice should produce the exact same result as running it once. Check current state before writing, preserve existing permissions, and use explicit error handling for unavailable resources.
$service = Get-Service -Name 'w32time' -ErrorAction Stopif ($service.StartType -ne 'Automatic') { Set-Service -Name 'w32time' -StartupType Automatic}if ($service.Status -ne 'Running') { Start-Service -Name 'w32time' }exit 0
Design for support
Return concise status values and log only what support needs. A failure should identify the stage and error category, not dump an opaque transcript containing sensitive machine data.
Operational checklist
- Keep one desired state per script.
- Check before changing.
- Use explicit failure handling.
- Test repeated execution and rollback.
No matching guide content found
Try searching for keywords like "desired state", "idempotent", "support", or "checklist".
Read more
Compliance Automation
Use PowerShell detection and remediation to automate endpoint compliance with evidence and guardrails.
Win32 Packaging
A repeatable Intune Win32 application packaging workflow with detection, requirements, dependencies, and return codes.
Device Inventory
Create a useful endpoint inventory snapshot with PowerShell by combining stable device signals and clear freshness metadata.
Loading discussion threads...