我是PowerShell的新手。以下是一些代码示例将帮助我解释:
第一个示例给出了我想要的正确输出,这是一个值列表,在本例中是两个值,在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
但是,以下命令将两个值“OU = t2,DC = test,OU = t1,DC = acc”视为单个字符串。使用两个单独的值而不是单个字符串创建的正确语法是什么?我尝试了不同的方式(有或没有双引号),它们不起作用。
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
答案 0 :(得分:2)
$OUDNArray = @("OU=t2,DC=test","OU=t1,DC=acc")
$test=New-APSDirectoryConfig -DirectoryName test.com -OrganizationalUnitDistinguishedName $OUDNArray -ServiceAccountCredentials_AccountName TEST\serviceaccount -ServiceAccountCredentials_AccountPassword T3st12345
<强>参数强>
-OrganizationalUnitDistinguishedName&lt; String []&gt;
计算机帐户的组织单位的可分辨名称。 需要?假位置?命名为Accept管道输入?假
OrganizationalUnitDistinguishedName
接受数组。