我创建了以下测试脚本以在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
答案 0 :(得分:1)
引用TessellatingHeckler的评论,
替换:
Error 2 error C2664: 'CString Class1::TestFunction(CString, int,int,int)' : cannot convert parameter 1 from 'int' to 'CString'
6 IntelliSense: no instance of overloaded function "Class1::TestFunction" matches the argument list
使用:
$arrRtn += new-object -typename psobject -property $chkBIOS