Reputation: 443
I am new to powershell. Here are some code examples will help me to explain:
The first example gives the correct output I want which is a list of values, two values in this example, under OrganizationalUnitDistinguishedNames
PS C:\Users\Administrator\Desktop> $test=Get-APSDirectoryConfigList -DirectoryName test.com
PS C:\Users\Administrator\Desktop> $test
CreatedTime DirectoryName OrganizationalUnitDistinguishedNames ServiceAccountCredentials
----------- ------------- ------------------------------------ -------------------------
12/4/2017 9:26:50 AM test.com {OU=t1,DC=acc, OU=t2,DC=test} Amazon.AppStream.Model.ServiceAccountCredentials
PS C:\Users\Administrator\Desktop> $test.OrganizationalUnitDistinguishedNames
OU=t1,DC=acc
OU=t2,DC=test
However, the following command treats two values "OU=t2,DC=test,OU=t1,DC=acc" as a single string. What is the correct syntax to create with two separate values instead of a single string? I have tried different ways (with or without double quotes), they don't work.
PS C:\Users\Administrator\Desktop> $test=New-APSDirectoryConfig -DirectoryName test.com -OrganizationalUnitDistinguishedName "OU=t2,DC=test,OU=t1,DC=acc" -ServiceAcco
untCredentials_AccountName TEST\serviceaccount -ServiceAccountCredentials_AccountPassword secret_password
PS C:\Users\Administrator\Desktop> $test
CreatedTime DirectoryName OrganizationalUnitDistinguishedNames ServiceAccountCredentials
----------- ------------- ------------------------------------ -------------------------
12/4/2017 9:33:25 AM test.com {OU=t2,DC=test,OU=t1,DC=acc} Amazon.AppStream.Model.ServiceAccountCredentials
PS C:\Users\Administrator\Desktop> $test.OrganizationalUnitDistinguishedNames
OU=t2,DC=test,OU=t1,DC=acc
Upvotes: 1
Views: 299
Reputation: 6180
$OUDNArray = @("OU=t2,DC=test","OU=t1,DC=acc")
$test=New-APSDirectoryConfig -DirectoryName test.com -OrganizationalUnitDistinguishedName $OUDNArray -ServiceAccountCredentials_AccountName TEST\serviceaccount -ServiceAccountCredentials_AccountPassword T3st12345
According to the AWS Appstream Docs:
Parameters
-OrganizationalUnitDistinguishedName <String[]>
The distinguished names of the organizational units for computer accounts. Required? False Position? Named Accept pipeline input? False
The OrganizationalUnitDistinguishedName
accepts an array.
Upvotes: 2