2017-06-15 24 views
0

我創建了以下測試腳本以在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 
+1

外貌喜歡它應該是'-property $ BIOSinfo' – TessellatingHeckler

回答

1

引述TessellatingHeckler的評論,

替換:

$arrRtn += new-object -typename psobject -property $chkBIOS 

有了:

$arrRtn += new-object -typename psobject -property $BIOSinfo 
+0

感謝它現在的工作 – Sachee

+0

接受答案將是可觀的 –

相關問題