Main example
List instances
# All instances of Win32_NetworkLoginProfile, with the main properties
Get-CimInstance -ClassName Win32_NetworkLoginProfile |
Select-Object -Property Name, Description, AccountExpires, AuthorizationFlagsExamples
Filter with WQL
# WQL filter evaluated by the provider: names starting with "a" (the WQL wildcard is %)
Get-CimInstance -ClassName Win32_NetworkLoginProfile -Filter "Caption LIKE 'a%'" |
Select-Object -Property Name, Description, AccountExpires, AuthorizationFlagsThe filter is evaluated by the WMI provider: less data is transferred than with Where-Object.
Decode numeric values
# AuthorizationFlags is a bit field: each set bit is decoded with -band
$authorizationFlagsFlag = @{
1 = 'Printer'
2 = 'Communication'
4 = 'Server'
8 = 'Accounts'
}
# Flags is a bit field: each set bit is decoded with -band
$flagsFlag = @{
1 = 'Script A logon script executed'
2 = 'Account Disabled The user''s account is disabled'
8 = 'Home Directory Required A home directory is required'
16 = 'Lockout The account is currently locked out'
32 = 'Password Not Required No password is required'
64 = 'Password Cannot Change The user cannot change the password'
128 = 'Encrypted Test Password Allowed'
256 = 'Temp Duplicate Account An account for users whose primary…'
512 = 'Normal Account Default account type that represents a…'
2048 = 'Interdomain Trust Account A permit to a trust account for a…'
4096 = 'Workstation Trust Account A computer account for a Windows…'
8192 = 'Server Trust Account A computer account for a backup domain…'
65536 = 'Do Not Expire Password'
131072 = 'MNS Logon Account Majority Node Set (MNS) logon account type…'
262144 = 'Smartcard Required'
524288 = 'Trusted for Delegation'
1048576 = 'Not Delegated'
2097152 = 'Use DES Key Only'
4194304 = 'Do Not Require Preauthorization'
8388608 = 'Password Expired Indicates that the password has expired'
}
Get-CimInstance -ClassName Win32_NetworkLoginProfile |
Select-Object -Property @(
'Name'
'Description'
'AccountExpires'
@{
Name = 'AuthorizationFlags'
Expression = {
$value = $_.AuthorizationFlags
$authorizationFlagsFlag.Keys |
Sort-Object |
Where-Object -FilterScript { $value -band $_ } |
ForEach-Object -Process { $authorizationFlagsFlag[$_] }
}
}
@{
Name = 'Flags'
Expression = {
$value = $_.Flags
$flagsFlag.Keys |
Sort-Object |
Where-Object -FilterScript { $value -band $_ } |
ForEach-Object -Process { $flagsFlag[$_] }
}
}
)Query a remote computer (CIM session)
review before running# Name of the remote computer
$computerName = 'SERVER01'
# The CIM session (WSMan by default) can be reused for several queries
$cimSession = New-CimSession -ComputerName $computerName
try {
Get-CimInstance -CimSession $cimSession -ClassName Win32_NetworkLoginProfile |
Select-Object -Property Name, Description, AccountExpires, AuthorizationFlags
} finally {
Remove-CimSession -CimSession $cimSession
}WSMan (WinRM) is used by default. For a host without WinRM, create the session with -SessionOption (New-CimSessionOption -Protocol Dcom). Add -Credential to use another account.
Show the class structure
# Class structure: properties, types and flags (Key, ReadOnly…)
$cimClass = Get-CimClass -ClassName Win32_NetworkLoginProfile
$cimClass.CimClassProperties |
Select-Object -Property Name, CimType, FlagsProperties
| Name | Type | Access | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| AccountExpires# | datetime | read | Account will expire. This value is calculated from the number of seconds elapsed since 00:00:00, January 1, 1970, and is set in this format: yyyymmddhhmmss.mmmmmm sutc. Example: 20521201000230.000000 000 Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AuthorizationFlags# | uint32 | read | Set of flags that specify the resources a user is authorized to use or modify. Values (4) — bit field
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BadPasswordCount# | uint32 | read | Number of times the user enters a bad password when logging on to a computer system running Windows. Example: 0 Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Caption# | string | read | Short textual description of the current object. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CodePage# | uint32 | read | Code page for the user's language of choice. A code page is the character set used. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment# | string | read | Comment or description for this logon profile. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CountryCode# | uint32 | read | Country/region code for the user's language of choice. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description# | string | read | Textual description of the current object. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Flags# | uint32 | read | The properties available to this network profile. Properties that can be set include: The following properties describe the account type. Only one value can be set:
Values (20) — bit field
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FullName# | string | read | Full name of the user belonging to the network login profile. This string can be empty if the user chooses not to associate a full name with a user name. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| HomeDirectory# | string | read | Path to the home directory of the user. This string may be empty if the user chooses not to specify a home directory. Example:"\HOMEDIR" Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| HomeDirectoryDrive# | string | read | Drive letter assigned to the user's home directory for log on purposes. Example: "C:" Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LastLogoff# | datetime | read | User last logged off the system. This value is calculated from the number of seconds elapsed since 00:00:00, January 1, 1970. A value of " .+*** " means that the last logoff time is unknown. The format of this value is yyyymmddhhmmss.mmmmmm sutc. For information about translating this property into your local time, see WMI Tasks: Dates and Times. Example: 19521201000230.000000 000 Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LastLogon# | datetime | read | User last logged on to the system. This value is calculated from the number of seconds elapsed since 00:00:00, January 1, 1970. The format of this value is yyyymmddhhmmss.mmmmmm sutc. For information about translating this property into your local time, see WMI Tasks: Dates and Times. Example: 19521201000230.000000 000 Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LogonHours# | string | read | Times during the week when the user can log on. Each bit represents a unit of time specified by the UnitsPerWeek property. For instance, if the unit of time is hourly, the first bit (bit 0, word 0) is Sunday, 0:00 to 0:59, the second bit (bit 1, word 0) is Sunday, 1:00 to 1:59, and so on. If this member is set to NULL, then there is no time restriction. The time is set to GMT and must be adjusted for other time zones (for example, GMT minus 8 hours for PST). Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LogonServer# | string | read | Name of the server to which logon requests are sent. Server names should be preceded by two backslashes (\\). A server name with an asterisk (\\*) indicates that the logon request can be handled by any logon server. A null string indicates that requests are sent to the domain controller. Example: "\\MyServer" Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MaximumStorage# | uint64 | read | Maximum amount of disk space available to the user. If MaximumStorage is set to USER_MAXSTORAGE_UNLIMITED, the user is allowed to use all of the available disk space. Example: 10000000 For more information about using uint64 values in scripts, see Scripting in WMI). Unit: bytes Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Name# key | string | read | User account on a particular domain or computer. The number of characters in the name cannot exceed the value of UNLEN. Example: "somedomain\johndoe" Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NumberOfLogons# | uint32 | read | Number of successful times the user tried to log on to this account. A value of 0xFFFFFFFF indicates that the value is unknown. This property is maintained separately on each backup domain controller (BDC) in the domain. To get an accurate value, only the largest value from all BDCs should be used. Example: 4 Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Parameters# | string | read | Space set aside for use by applications. This string can be null, or it can have any number of characters before the terminating null character. Microsoft products use this member to store user configuration information. Do not modify this information, because this value is specific to an application. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PasswordAge# | datetime | read | Length of time a password has been in effect. This value is measured from the number of seconds elapsed since the password was last changed. Example: 00001201000230.000000 000 Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PasswordExpires# | datetime | read | Date and time the password expires. The value is set in this format: yyyymmddhhmmss.mmmmmm sutc Example: 19521201000230.000000 000 Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PrimaryGroupId# | uint32 | read | Relative identifier (RID) of the Primary Global Group for this user. The identifier verifies the primary group to which the user's profile belongs. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Privileges# | uint32 | read | Level of privilege assigned to the usri3_name property. Values (3)
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Profile# | string | read | Path to the user's profile. This value can be a null string, a local absolute path, or a UNC path. A user profile contains settings that are customizable for each user such as the desktop colors. Example: "C:\Windows" Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ScriptPath# | string | read | Directory path to the user's logon script. A logon script automatically executes a set of commands each time a user logs on to a system. Example: "C:\win\profiles\ThomasSteven" Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SettingID# | string | read | Identifier by which the current object is known. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UnitsPerWeek# | uint32 | read | Number of time units the week is divided into. It is used with the LogonHours property to limit user access to the computer. Example: 168 (hours per week) Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UserComment# | string | read | User-defined comment or description for this profile. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UserId# | uint32 | read | RID of the user. The identifier verifies that the user exists and is unique to this domain. Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UserType# | string | read | Type of account to which the user has privileges. The values are:
Values (6)
Code | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Workstations# | string | read | Names of workstations from which the user can log on. Up to eight workstations can be specified; the names must be separated by commas (,). A null string indicates no restrictions. To disable logons from all workstations to this account, set the UF_ACCOUNTDISABLE in the Flags property of this class. Code |
Remarks
The Win32_NetworkLoginProfile class is derived from CIM_Setting.
The calling process that uses this class must have the SE_RESTORE_NAME privilege on the computer in which the registry resides. For more information, see Executing Privileged Operations.
Inheritance
Superclass chain
- CIM_Setting
- Win32_NetworkLoginProfile
Known subclasses
No known subclass.
Requirements
- Namespace
- root/cimv2
- Minimum client
- Windows Vista
- Minimum server
- Windows Server 2008
- Provider
- CIMWin32
- MOF file
- CIMWin32.mof
- DLL
- CIMWin32.dll
Class qualifiers
Dynamic Provider("CIMWin32") Privileges("SeRestorePrivilege") UUID("{8502C4E7-5FBB-11D2-AAC1-006008C78BC7}") AMENDMENT
Microsoft source
Descriptions, properties and methods come from the Microsoft documentation (MicrosoftDocs/win32 repository), published under the CC BY 4.0 licence. Formatting and translations are specific to this site; the PowerShell examples are written for it.