Reputation: 1
I created below test script to run on Power shell. What I wanted firstly check computer on AD and then get the BIOS version from that particular PC. Below is my sample code,
$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
Unfortunately I am getting below error. I am new to powershell and I have no idea about how to solve this
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
Upvotes: 0
Views: 1487
Reputation: 9193
Quoting the TessellatingHeckler's comment,
Replace:
$arrRtn += new-object -typename psobject -property $chkBIOS
With:
$arrRtn += new-object -typename psobject -property $BIOSinfo
Upvotes: 1