Working with different data and attribute types
The PowerShell cmdlets make it easy to work with attributes of different data types and multivalued properties.
Date data types
The client will accept both ISO8601 date formats (yyyy-MM-ddT00:00:00.000) as well as native DateTime values. Note that when providing the date as a string, the date must be in universal time.
# Sets the expiry date to the current date and time
$obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser
$obj.ExpiryDate = [DateTime]::Now
Save-Resource $obj
# Sets the expiry date to a specific value
$obj.ExpiryDate = "2020-01-01T00:00:00.000"
Save-Resource $obj
Reference data types
References attributes can be any of the following
GUID object
String representation of a GUID
Another resource object
The native UniqueValue data type from another reference attribute
# Sets the value of a person's manager attribute to a known ID
$obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser
$obj.Manager = '7fb2b853-24f0-4498-9534-4e10589723c4'
Save-Resource $obj
# Sets the value of a person's manager attribute to that of another object
$obj.Manager = GetResource -ObjectType Person -AttributeName AccountName -AttributeValue testuser2
Save-Resource $obj
Binary data types
Binary data types can be any of the following
A byte array (byte[])
A base-64 encoded binary string
# Sets the value of the ObjectSID attribute to a base-64 encoded string
$obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser
$obj.ObjectSID = "AQUAAAAAAAUVAAAAFYLkaG79nJrWb05iFzcCAA=="
Save-Resource $obj
# Sets the value of the ObjectSID attribute to a byte array
$obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser
$obj.ObjectSID = [Byte[]] (0, 1, 2, 3)
Save-Resource $obj
Integer data types
Integer data types can be any of the following
A 32-bit integer (Int32 or int)
A 64-bit integer (Int64 or long)
A string representation that can be converted to an Int64 value
# Sets the freeze count using an integer value
$obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser
$obj.FreezeCount = 5
Save-Resource $obj
# Sets the freeze count using a string value
$obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser
$obj.FreezeCount = "5"
Save-Resource $obj
Working with multivalued attributes
# Setting a multivalued attribute
$obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser
$obj.jobTitles = @("Manager", "Engineer")
Save-Resource $obj
# Adding a value to a multivalued attribute
$obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser
$obj.jobTitles.Add("Developer");
Save-Resource $obj
# Removing a value from a multivalued attribute
$obj = Get-Resource -ObjectType Person -AttributeName AccountName -AttributeValue testuser
$obj.jobTitles.Remove("Developer");
Save-Resource $obj
Last updated