Home > Net >  how to Concatenate string
how to Concatenate string

Time:10-31

Using the following code below to build a list of installed apps if they are installed, however, I am getting the result on a new line for each entry. Would like to know how I can concatenate the lines.

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"
}

CodePudding user response:

Are you after Write-Host -NoNewline?

enter image description here

  • Related