__Trustee

Trustee

The __Trustee abstract system class represents a trustee. Either a name or an SID (byte array) can be used.

On this page

Main example

List instances

# All instances of __Trustee, with the main properties
Get-CimInstance -ClassName __Trustee -Namespace 'root' |
    Select-Object -Property Name, Domain, SidLength, SidString

Examples

Filter with WQL

# WQL filter evaluated by the provider: names starting with "a" (the WQL wildcard is %)
$cimParameters = @{
    ClassName = '__Trustee'
    Namespace = 'root'
    Filter    = "Name LIKE 'a%'"
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, Domain, SidLength, SidString

The filter is evaluated by the WMI provider: less data is transferred than with Where-Object.

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 {
    $cimParameters = @{
        CimSession = $cimSession
        ClassName  = '__Trustee'
        Namespace  = 'root'
    }
    Get-CimInstance @cimParameters |
        Select-Object -Property Name, Domain, SidLength, SidString
} 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 __Trustee -Namespace 'root'
$cimClass.CimClassProperties |
    Select-Object -Property Name, CimType, Flags

Properties

6 of 6 properties
NameTypeAccessDescription
Domainstringread/write

Domain portion of the account.

Code
# Value of Domain for each instance
$cimParameters = @{
    ClassName = '__Trustee'
    Namespace = 'root'
    Property  = @('Name', 'Domain')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, Domain

Warning. Changes the system: check with -WhatIf first. An elevated console is often required.

# Warning: changes Domain on the instance. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName __Trustee -Namespace 'root' |
    Select-Object -First 1
$setParameters = @{
    InputObject = $instance
    Property    = @{ Domain = 'Example' }
    WhatIf      = $true  # Remove this line to actually apply the change
}
Set-CimInstance @setParameters
Namestringread/write

Name portion of the account.

Code
# Value of Name for each instance
$cimParameters = @{
    ClassName = '__Trustee'
    Namespace = 'root'
    Property  = 'Name'
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name

Warning. Changes the system: check with -WhatIf first. An elevated console is often required.

# Warning: changes Name on the instance. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName __Trustee -Namespace 'root' |
    Select-Object -First 1
$setParameters = @{
    InputObject = $instance
    Property    = @{ Name = 'Example' }
    WhatIf      = $true  # Remove this line to actually apply the change
}
Set-CimInstance @setParameters
SIDuint8[]read/write

The SID of the trustee in the binary byte array form.

Code
# Value of SID for each instance
# SID is an array: -ExpandProperty returns its items one by one
$cimParameters = @{
    ClassName = '__Trustee'
    Namespace = 'root'
    Property  = 'SID'
}
Get-CimInstance @cimParameters |
    Select-Object -ExpandProperty SID

Warning. Changes the system: check with -WhatIf first. An elevated console is often required.

# Warning: changes SID on the instance. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName __Trustee -Namespace 'root' |
    Select-Object -First 1
$setParameters = @{
    InputObject = $instance
    Property    = @{ SID = @(0) }
    WhatIf      = $true  # Remove this line to actually apply the change
}
Set-CimInstance @setParameters
SidLengthuint32read/write

The length of the SID in bytes.

Code
# Value of SidLength for each instance
$cimParameters = @{
    ClassName = '__Trustee'
    Namespace = 'root'
    Property  = @('Name', 'SidLength')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, SidLength

Warning. Changes the system: check with -WhatIf first. An elevated console is often required.

# Warning: changes SidLength on the instance. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName __Trustee -Namespace 'root' |
    Select-Object -First 1
$setParameters = @{
    InputObject = $instance
    Property    = @{ SidLength = 0 }
    WhatIf      = $true  # Remove this line to actually apply the change
}
Set-CimInstance @setParameters
SidStringstringread/write

The SID of the trustee in the string format, for example, "S-1-1-0".

Code
# Value of SidString for each instance
$cimParameters = @{
    ClassName = '__Trustee'
    Namespace = 'root'
    Property  = @('Name', 'SidString')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, SidString

Warning. Changes the system: check with -WhatIf first. An elevated console is often required.

# Warning: changes SidString on the instance. -WhatIf shows the operation without running it.
# Target instance
$instance = Get-CimInstance -ClassName __Trustee -Namespace 'root' |
    Select-Object -First 1
$setParameters = @{
    InputObject = $instance
    Property    = @{ SidString = 'Example' }
    WhatIf      = $true  # Remove this line to actually apply the change
}
Set-CimInstance @setParameters
TIME_CREATEDuint64read

Time in the CIM_DATETIME format when the security descriptor was created.

Code
# Value of TIME_CREATED for each instance
$cimParameters = @{
    ClassName = '__Trustee'
    Namespace = 'root'
    Property  = @('Name', 'TIME_CREATED')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, TIME_CREATED

Remarks

This class provides properties that are inherited by the Win32_Trustee class, which is a member of the Win32_SecurityDescriptor class. For more information, see WMI Security Descriptor Objects and Changing Access Security on Securable Objects. For more information about ACEs, see Access Control Components.

Inheritance

Superclass chain

This class has no superclass.

Known subclasses

No known subclass.

Requirements

Namespace
root
Minimum client
Windows Vista
Minimum server
Windows Server 2008
DLL
All

Microsoft source

Source: Microsoft Learn

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.