What It Does
This script is read-only. Run it on the device itself, as SYSTEM from your RMM. If this Windows has no Windows LAPS (it needs Windows 11, Windows 10 with the April 2023 update or later, or Windows Server 2019 or later) it ends SKIPPED.
It finds the active policy. Windows LAPS looks in four places in a fixed order (the LAPS CSP from Intune, Group Policy, local configuration and legacy Microsoft LAPS) and uses the first one that has a value. The script reads BackupDirectory (disabled, Microsoft Entra ID or Active Directory), AdministratorAccountName and PasswordAgeDays (default 30) from it. No policy, or backup disabled, is an ALERT. When the legacy policy is the active one, the directory is taken to be Active Directory.
Then it reads the Windows LAPS event log by event ID only. It alerts when there is no success event for the directory, when the newest one is older than PasswordAgeDays plus 2 days, or when the newest policy processing result is a failure. ExpectedDirectory can be EntraId or ActiveDirectory, and a different directory alerts.
The event log keeps limited history, so a quiet device whose log has rolled over can show no success event even though backups work; the answer says so. A second run just reads the same log again.
Before You Run It
- Run it as SYSTEM from your RMM on the device. It needs administrator rights to read the event log.
- Make sure a LAPS policy is applied by Intune or Group Policy first, or every run alerts.
- Set ExpectedDirectory to EntraId or ActiveDirectory if one place is your standard.
- Expect a possible false alert on a quiet device whose event log has rolled over.
- Use get-laps-coverage to see which computers have a managed password at all.
- Schedule it in your RMM and alert on exit 1.
Type and Risk
- Type: Monitor. It checks one condition. It exits 1 when it finds the problem, so your RMM can alert on it, 0 when all is well, and 2 when it could not run.
- Risk: Low. It reads and changes nothing.
- Restart: It never restarts the machine.
- Typical run: Under 10 seconds.
- Example answer: "Windows LAPS backs up to Entra ID; last backup 3 days ago; password age 30 days"
- Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.
Inputs
Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.
- ExpectedDirectory: Where the password must be backed up: Any (default; any enabled directory is fine), EntraId or ActiveDirectory. A different directory is an ALERT.
Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.
License
Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.