User Accounts

The WMI Win32_UserAccount class is very useful for investigating the accounts availabel on a Windows machine.  The basic usage gives  a list of the users and some basic information e.g.
 
Get-WmiObject -Class Win32_UserAccount
AccountType : 512
Caption     : HOME04Guest
Domain      : HOME04
SID         : S-1-5-21-3389053838-1963095184-1087455968-501
FullName    :
Name        : Guest
 
etc
 
The -Filter parameter can be used to limit the information returned to a single user
 
Get-WmiObject -Class Win32_UserAccount -Filter ‘Name = "Guest"’
Or you can look at all of the available information for an account like this 
$ua = Get-WmiObject -Class Win32_UserAccount -Filter ‘Name = "Guest"’
$ua | Select * | Format-List
 
Status             : Degraded
Caption            : HOME04Guest
PasswordExpires    : False
__GENUS            : 2
__CLASS            : Win32_UserAccount
__SUPERCLASS       : Win32_Account
__DYNASTY          : CIM_ManagedSystemElement
__RELPATH          : Win32_UserAccount.Domain="HOME04",Name="Guest"
__PROPERTY_COUNT   : 16
__DERIVATION       : {Win32_Account, CIM_LogicalElement, CIM_ManagedSystemElement}
__SERVER           : HOME04
__NAMESPACE        : rootcimv2
__PATH             :
\HOME04rootcimv2:Win32_UserAccount.Domain="HOME04",Name="Guest"
AccountType        : 512
Description        : Built-in account for guest access to the computer/domain
Disabled           : True
Domain             : HOME04
FullName           :
InstallDate        :
LocalAccount       : True
Lockout            : False
Name               : Guest
PasswordChangeable : False
PasswordRequired   : False
SID                : S-1-5-21-3389053838-1963095184-1087455968-501
SIDType            : 1
 
The only method available on the object is Rename BUT thet following are available as scriptmethods:

ConvertFromDateTime
ConvertToDateTime
Delete
GetType
Put

Which enables the properties of the user accounts to be manipulated.  It doesn’t seem to be possible to reset a password this way but there are a number of things that can be done through this class.

About these ads
This entry was posted in Powershell. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s