Gets a WMI Win32_UserAccount object for a local user account.


Get-WmiLocalUserAccount [-Username] <String> [-WhatIf] [-Confirm] [<CommonParameters>]


Man, there are so many ways to get a user account in Windows. This function uses WMI to get a local user account. It returns a Win32_UserAccount object. The username has to be less than 20 characters. We don't remember why anymore, but it's probaly a restriction of WMI. Or Windows. Or both.

You can do this with Get-WmiObject, but when you try to get a Win32_UserAccount, PowerShell reaches out to your domain and gets all the users it finds, even if you filter by name. This is slow! This function stops WMI from talking to your domain, so it is faster.

Related Commands


Name Type Description Required? Pipeline Input Default Value
Username String

The username of the local user to get.

true false
WhatIf SwitchParameter false false
Confirm SwitchParameter false false
CommonParameters This cmdlet supports common parameters. For more information type
Get-Help about_CommonParameters.


Get-WmiLocalUserAccount -Username Administrator

Gets the local Administrator account as a Win32_UserAccount WMI object.