Я написал скрипт, который может вернуть вас, если установлено программное обеспечение или нет.
Я хотел бы дать ему немного цветов, но я не знаю, как объединить 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)
![enter image description here](https://i.stack.imgur.com/qUilE.png)
Я знаю, что могу объединиться с
[string]::Concat("$First_Phrase", "$response")
, но не работает.