【问题标题】:Powershell script to check all my AD computers BIOS versions and export to excel sheet用于检查我所有 AD 计算机 BIOS 版本并导出到 Excel 表的 Powershell 脚本
【发布时间】: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


【解决方案1】:

引用 TessellatingHeckler 的评论,

替换:

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

与:

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

【讨论】:

  • 接受答案将是可观的
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-05
  • 1970-01-01
  • 2018-11-23
  • 2017-11-26
  • 1970-01-01
  • 2022-11-10
相关资源
最近更新 更多