Skip to content

Convert-OUString

SYNOPSIS

Converts a DN string to a PSCustomObject or hashtable.

SYNTAX

1
2
Convert-OUString [-OUString] <String> [-AsPSCustomObject] [-ProgressAction <ActionPreference>]
 [<CommonParameters>]

DESCRIPTION

The Convert-OUString function takes a string and splits it according to the specification of an LDAP DN as contained in RFC 4514. Each RDN (name-value pair) is added to the returning object with nameNumber as name and value as the value.

The DN 'uid=johnDoe,ou=People,dc=example,dc=com' will result in a PSCustomObject or hashtable with following properties and values.

  • dc1 : com
  • dc2 : example
  • ou1 : People
  • uid1 : johnDoe
  • OUPath : ou=People,dc=example,dc=com

The Convert-OUString function also adds a property named 'OUPath' with the full DN up to the last (when reading from right to left) RDN.

EXAMPLES

EXAMPLE 1

1
2
3
4
5
6
7
8
9
Convert-OUString -OUString "uid=john.doe,ou=People,dc=example,dc=com"

Name                           Value
----                           -----
OUPath                         ou=People,dc=example,dc=com
dc1                            com
dc2                            example
ou1                            People
uid1                           john.doe

In this example we are converting a DN to a hashtable.

EXAMPLE 2

1
2
3
4
5
6
7
Convert-OUString -OUString "uid=john.doe,ou=People,dc=example,dc=com" -AsPSCustomObject

OUPath : ou=People,dc=example,dc=com
dc1    : com
dc2    : example
ou1    : People
uid1   : john.doe

In this example we are converting a DN to a PSCustomObject.

PARAMETERS

-AsPSCustomObject

Tells the function to return a PSCustomObject instead of a hashtable

1
2
3
4
5
6
7
8
9
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-OUString

String to convert

1
2
3
4
5
6
7
8
9
Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ProgressAction

Determines how PowerShell responds to progress updates generated by a script, cmdlet, or provider, such as the progress bars generated by the Write-Progress cmdlet. The Write-Progress cmdlet creates progress bars that show a command's status.

The ProgressAction parameter takes one of the ActionPreference enumeration values: SilentlyContinue, Stop, Continue, Inquire, Ignore, Suspend, or Break.

1
2
3
4
5
6
7
8
9
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

None. You cannot pipe objects to Convert-OUString.

OUTPUTS

PSCustomObject

Hashtable

NOTES