1

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

1 Answer 1

2

Try:

$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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.