I was recently part of a discussion about creating a custom user to manage with Windows LAPS with Microsoft Intune without using Remediations due to licensing constraints (Business Premium). And the solution I came up with is what I want to show you here.
Windows LAPS is a easy solution to manage a single local Windows account password. But it lacks the ability to create the user if it not exists.
Remediations in Microsoft Intune are the perfect tool to create a user account if it not exists because they are repeatedly checking for a wanted status on a device and repair/remediate it if it is not present. I use it myself and published an Intune version of my script I used in Configuration Manager with Configuration Baselines to the EndpointAnalyticsRemediationScripts GitHub repo.
But the use of Remediations is limited to Enterprise customers and how can non Enterprise customers handle this?
Sounds simple? Yes but there are some caveats like running the script in the 32-bit PowerShell Host.
What the scripts are doing
The detect-LAPSUser.ps1 also checks if a local account with the configured AdministratorAccountName is present.
The new-LAPSUser.ps1 creates a user account with the AdministratorAccountName with a random password.
Package the script
- Put the new-LAPSUser.ps1 script in an empty folder.
- Download and execute the Microsoft Win32 Content Prep Tool
- Use the folder from step 1. as source folder
- The setup file is new-LAPSUser.ps1
- Choose a path were the .intunewin file will be saved
Create the application
- In Intune open Apps - Windows - Create new application and choose Windows app (Win32)
- Upload the .intunewin created in the last step
- Fill out at least Name, Description and Publisher and press Next
- The install command uses the sysnative folder to run the script in the 64-bit PowerShell: c:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe -noprofile -executionpolicy bypass -file .\new-LAPSUser.ps1
- Uninstall command: cmd /c exit 0 (currently not included)
- Allow available uninstall: No
- Install behavior: System
- Device restart behavior: No specific action
- OS architecture: 64-bit
- Minimum OS: Windows 10 20H2 (oldest version supported by Windows LAPS)
- Add+ additional requirement rule
- Type: Registry
- Key path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Policies\LAPS
- Value name: AdministratorAccountName
- Registry key requirement: Value exists then OK
- Choose Detection script and use the following script (added a line with Write-Output to signal the detection)
Bring it all together
Now you only have to assign the application and a LAPS configuration containing an AdministratorAccountName to the devices and an user with the configured name should be created for LAPS to take over.
- The device checks in with Intune and recognizes the app deployment
- The Intune Management Extension runs the detection script to check if the application is installed. It therefore checks if a user account is necessary and if it is already present.
- If the user is configured but does not exist the requirement rule (AdministratorAccountName is configured by Intune LAPS profile) is checked. The installation will be started if the requirements are met and will create the account.
- The detection is script runs again and discovers the user and therefore the application.
- If the AdministratorAccountName is changed the application re-evaluation will detect the app as not installed and it will retry the installation and this will create a new local account.