【发布时间】:2017-06-15 10:54:24
【问题描述】:
我在下面创建了在 Power shell 上运行的测试脚本。我想要首先检查 AD 上的计算机,然后从该特定 PC 获取 BIOS 版本。 下面是我的示例代码,
$arrADcomp = (Get-ADComputer -Filter * -SearchBase " OU=Prod,OU=Workstations,OU=CCCSOE,DC=XXX,DC=com").Name
$arrRtn=@()
foreach ($chkBIOS in $arrADcomp)
{
$BIOSinfo = @{}
$BIOSinfo.Asset_Tag = $chkBIOS
$arrRtn += new-object -typename psobject -property $chkBIOS
}
$arrRtn | Select-Object Asset_Tag | Out-File C:\Powershell\computer1.csv
不幸的是,我遇到了错误。我是 powershell 新手,我不知道如何解决这个问题
New-Object : Cannot bind parameter 'Property'. Cannot convert the "LT9JL5N32" value of type "System.String" to type "System.Collections.IDictionary".
At line:8 char:56
+ $arrRtn += new-object -typename psobject -property $chkBIOS
+ ~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-Object], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.NewObjectCommand
【问题讨论】:
-
看起来应该是
-property $BIOSinfo
标签: powershell powershell-2.0 powershell-3.0