What It Does
This script is read-only. It builds one list of Windows computers from up to two places. From Active Directory, when this computer is in a domain, it reads the computers with a Windows operating system and only their password expiration time attributes, for Windows LAPS and legacy Microsoft LAPS. It first checks that each attribute exists in the schema and says which do not. The password attributes themselves are never requested.
From Microsoft Entra ID, when TenantId and ClientId are given, it reads the Windows LAPS records, which Microsoft documents as excluding the credentials, and the device list. The app needs DeviceLocalCredential.ReadBasic.All and Device.Read.All, never DeviceLocalCredential.Read.All. A hybrid device is matched to Active Directory by name. An Entra-joined or registered device gets its own row even if it shares a name with an Active Directory computer.
The AD scan leaves out domain controllers. Both scans skip disabled computers unless IncludeDisabled is true, and records with a known last-seen date older than StaleDays (default 90, set to 0 to turn off the filter). Without AD expiration or Entra backup or refresh data, a computer is Not managed. The script marks covered computers Overdue when the newest recorded expiration is more than one day past. Other covered computers are Managed.
The answer counts computers with Windows LAPS, with legacy LAPS, with neither, and with overdue expiration times. A backup or expiration timestamp does not prove that the stored password matches the local account. Use test-windows-laps on a device to check its backup events. The AD scan covers only the domain of the computer running the report.
On an Active Directory-only run, the script warns if it read computers but none had a readable LAPS expiration time. Check the attribute's read permissions if you expect LAPS to be in use.
Before You Run It
- On a domain member, install the ActiveDirectory module (RSAT) and run as a domain account. Any domain user can read computer objects by default.
- For Entra ID, create an app registration with DeviceLocalCredential.ReadBasic.All and Device.Read.All, grant admin consent and set TenantId and ClientId.
- Leave TenantId empty to read Active Directory only.
- Treat a warning that every computer is Not managed as a possible permissions problem, not as proof.
- Use test-windows-laps on a single device to check its own backup.
Type and Risk
- Type: Report. It collects facts into a table and never alerts. It exits 0, or 2 when it could not run.
- Risk: Low. It reads and changes nothing.
- Restart: It never restarts the machine.
- Typical run: Under 2 minutes.
- Example answer: "LAPS coverage: 41 of 52 Windows computers (79%) have a managed password (38 Windows LAPS, 3 legacy); no password on 11; 2 overdue (not rotated)"
- Tested before listing with Windows PowerShell 5.1, run as SYSTEM, against its own test cases and a Microsoft 365 Business Premium test tenant.
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.
- TenantId: The client tenant (a GUID or a domain such as contoso.onmicrosoft.com). Optional: empty reads Active Directory only. Required for the Entra ID part.
- ClientId: The app registration's Application (client) ID, a GUID. Required when TenantId is set.
- CertificateThumbprint: Thumbprint (40 hex characters) of the app's certificate with its private key in LocalMachine\My or CurrentUser\My. Preferred. When empty, the secret is read from the environment variable ClientSecret (a secure RMM field).
- StaleDays: Leave out computers not seen (last logon in Active Directory, last sign-in in Entra ID) for this many days. Whole number, 0 to 3650; 0 lists every computer. Default 90.
- IncludeDisabled: true to also list disabled computers. Default false.
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.