powershell 如何连接字符串

6tqwzwtp  于 2022-11-10  发布在  Shell
关注(0)|答案(1)|浏览(132)

使用下面的代码构建已安装应用程序的列表(如果它们已安装),但是,我在每个条目的新行上获得结果。我想知道我怎样才能把这些线连接起来。

clear
$appsToCheck = "WebEx","Adobe Acrobat"

function Check_Program_Installed {
    [CmdletBinding()]
    Param(
        [Parameter(Position = 0, Mandatory=$true, ValueFromPipeline = $true)]
        $Name
    )
    $app = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*", "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" | 
           Where-Object { $_.DisplayName -match $Name } | 
           Select-Object DisplayName, DisplayVersion, InstallDate, Version
    if ($app) {
        Write-Host "$($app.DisplayName) v$($app.DisplayVersion) | "
    }
}

foreach ($app in $appsToCheck) {
Check_Program_Installed "$app"
}
carvr3hs

carvr3hs1#

你是在追求Write-Host -NoNewline吗?

相关问题