我写了一个脚本,如果安装了软件,它可以返回你。
我想给它一些颜色,但我不知道如何将 2 连接到仅适用于...Write-Output
的同一行上,在这种情况下我不能使用:-NoNewline
Write-Host
# The function we use to give color
function Positive {
process { Write-Host $_ -ForegroundColor Green }
}
function Negative {
process { Write-Host $_ -ForegroundColor Red }
}
# Is the software installed?
# '0' = NO, is not installed
# '1' = YES, is installed
$Check = '1'
function Check_Installation($Check){
if ($Check -eq '0') {return $response = "No, is not installed" | Negative}
elseif ($Check -eq '1') {return $response = "Yes, is installed" | Positive}
}
$First_Phrase = "Let's check if the software is installed: "
Write-Output "$First_Phrase", "$response"
Check_Installation($Check)
我知道我可以与
[string]::Concat("$First_Phrase", "$response")
但不工作。