Convert-QADAttributeValue

From PowerGUI Wiki

Jump to: navigation, search

Convert attribute values of a directory object to the specified .NET type.

Contents

Syntax

Convert-QADAttributeValue -Input <Object> -OutputTypeName <String> [<CommonParameters>]

Detailed Description

Use this cmdlet to convert attribute values of directory objects returned by a cmdlet (for example, by a Get-QADUser cmdlet). You can convert:

- Values of the byte[] type to the SecurityIdentifier or Guid type
- Values of the IADsLargeInteger type to the Int64, DateTime,
  or TimeSpan type



Related Commands

Parameters

Name Description Required? Pipeline Input Default Value
Input Specify the object representing the attribute value to convert. This parameter accepts pipeline input. This parameter is optional since you can pipe into this cmdlet the object returned by a Get- cmdlet (see examples). true true (ByValue, ByPropertyName)
OutputTypeName Specify the fully qualified name of the .NET type to convert the attribute value to. The assembly name and namespace indication can be omitted if the type is from the System namespace (see examples). true false

Examples

Example 1

get-QADuser 'MyDomain\JSmith' | %{$_.DirectoryEntry.objectGuid} | convert-QADAttributeValue -outputTypeName 'Guid' | Write-Host

Convert the value of the objectGuid attribute to the Guid type, and display the value in the console window.

Example 2

get-QADuser 'MyDomain\JSmith' | %{$_.DirectoryEntry.objectSid} | convert-QADAttributeValue -outputTypeName 'Security.Principal.SecurityIdentifier' | Write-Host

Convert the value of the objectSid attribute to the SecurityIdentifier type, and display the value in the console window.

Example 3

get-QADuser 'MyDomain\JSmith' | %{$_.DirectoryEntry.lastLogon} | convert-QADAttributeValue -outputTypeName 'DateTime' | Write-Host

Convert the value of the lastLogon attribute to the DateTime type, and display the value in the console window.

Example 4

get-QADComputer -searchRoot 'mydomain.company.com/domain controllers' | Select-Object Name,@{Name="Last Logon"; Expression={%{ get-QADUser 'MyDomain\JSmith' -Service $_.Name} | %{$_.DirectoryEntry.lastLogon} | convert-QADAttributeValue -outputTypeName 'DateTime'}}

For each domain controller, retrieve the time that the user JSmith last logged on by using a given domain controller, and display the results in the console window.

Personal tools