Files
Victor Lyuboslavsky 89bbda0577 Improve error handling in create-admin-user.ps1 script (#45176)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #45160

Issue and fix: https://www.youtube.com/watch?v=Ow9GAFedEnQ

# Checklist for submitter

## Testing

- [x] QA'd all new/changed functionality manually



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

## Release Notes

* **Bug Fixes**
* Enhanced error handling in the admin user creation process to ensure
immediate failure on errors, preventing incomplete operations during
user account creation or group membership assignment.

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/fleetdm/fleet/pull/45176)

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-05-11 14:59:52 -05:00

11 lines
539 B
PowerShell

# Please don't delete. This script is referenced in the guide here: https://fleetdm.com/guides/enforce-disk-encryption
$Username = "IT admin"
$Password = ConvertTo-SecureString "StrongPassword123!" -AsPlainText -Force
# Create the local user account
New-LocalUser -Name $Username -Password $Password -FullName "Fleet IT admin" -Description "Fleet breakglass admin account" -AccountNeverExpires -ErrorAction Stop
# Add the user to the Administrators group
Add-LocalGroupMember -Group "Administrators" -Member $Username -ErrorAction Stop