I have the following code:
$PreReqFail1 = "- Your computer is not in the office"
$PreReqFail2 = "- Your computer does not have its power cable plugged in"
$PreReqFail3 = "- Your computer does not have a network cable plugged in"
If (-NOT([string]::IsNullOrEmpty($PreReqFail1))) {$PreReqFail = $True}
If (-NOT([string]::IsNullOrEmpty($PreReqFail2))) {$PreReqFail = $True}
If (-NOT([string]::IsNullOrEmpty($PreReqFail3))) {$PreReqFail = $True}
If ($PreReqFail)
{
$Issues = @($PreReqFail1,$PreReqFail2,$PreReqFail3)
$Issues
$PreReqFails = "The following conditions have not been met:`r`n`r`n" + $Issues
$PreReqFails
}
$Issues = $null
$PreReqFail = $null
$PreReqFail1 = $null
$PreReqFail2 = $null
$PreReqFail3 = $null
$PreReqFails = $null
The idea is that I can comment out any one or more of the $PreReqFailx variables and present a dynamic list of the issues, e.g. 1,2,3 or 1,2 or 1,3 or 2,3, etc.
The Output from $Issues (lines 11 & 12) is as follows:
- Your computer is not in the office
- Your computer does not have its power cable plugged in
- Your computer does not have a network cable plugged in
This is the format I want. However, when I add it to the $PreReqFails variable, as shown in lines 13 & 14, this is what I get:
The following conditions have not been met:
- Your computer is not in the office - Your computer does not have its power cable plugged in - Your computer does not have a network cable plugged in
How I do tweak things so the output shows carriage returns for each issue, for example:
The following conditions have not been met:
- Your computer is not in the office
- Your computer does not have its power cable plugged in
- Your computer does not have a network cable plugged in
Thanks in advance for your assistance.