我創建了以下測試腳本以在Power shell上運行。我首先想要檢查AD上的計算機,然後從該特定PC獲取BIOS版本。 下面是我的示例代碼,Powershell腳本來檢查我所有的AD計算機BIOS版本並導出到Excel表
$arrADcomp = (Get-ADComputer -Filter * -SearchBase " OU=Prod,OU=Workstations,OU=CCCSOE,DC=XXX,DC=com").Name
[email protected]()
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' – TessellatingHeckler