我有几百台运行不同版本MS Office的机器。我需要找到哪些机器正在运行哪些版本。我有一个PowerShell脚本,我可以获取并导出安装了MS Office的计算机的名称到csv文件,但我无法获得安装在计算机上的office版本以导出到csv。我正在使用的代码如下所示:我在PowerShell中遇到了一些问题
$Computers = Get-Content "\\networkpath\ComputerList.txt"
$csvFilePath = "\\networkpath\SoftwareList.csv"
if (!(Test-Path -path $csvFilePath)) { ""|select name,version | Export-Csv -Path $csvFilePath -NoTypeInformation}
$outputArray = New-Object -TypeName System.Collections.ArrayList
ForEach ($Computer in $Computers)
{
Get-WmiObject -computerName $computer -Class CIM_Product -Filter 'Name like "%Microsoft Office Professional Plus%"' | select name
$Version = select name
$row = ""|select name,version
$row.Name = $Computer.ToString()
$row.Version = $Version.ToString()
$outputArray.Add($row)
}
$outputArray | Export-Csv -Path $csvFilePath -NoTypeInformation #-Append
谢谢您的信息。 – Jason