我有幾百臺運行不同版本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