< Back

Get-CWmiLocalUserAccount

Sun Jan 12, 2020 10:01 pm

NAME Get-CWmiLocalUserAccount



SYNOPSIS

Gets a WMI `Win32_UserAccount` object for a *local* user account.





SYNTAX

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





DESCRIPTION

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.





PARAMETERS

-Username <String>

The username of the local user to get.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-WhatIf [<SwitchParameter>]



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Confirm [<SwitchParameter>]



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Get-CWmiLocalUserAccount -Username Administrator



Gets the local Administrator account as a `Win32_UserAccount` WMI object.











RELATED LINKS

http://msdn.microsoft.com/en-us/library ... s.85).aspx