How to change the output color of test-connection outputHow do I get the color from a hexadecimal color code using .NET?C code changes terminal text color; how to restore defaults? LinuxHow to set the text color of TextView in code?How to change node.js's console font color?Redirect command prompt output to GUI and KEEP COLOR?Hex transparency in colorsChanging color of text background based on conditional statementConvert Test-Connection into BooleanChange output colour in Powershell scriptTest Connection and loop if true or false (change colors…)

Can someone give the intuition behind Mean Absolute Error and the Median?

Two side-by-side squares are inscribed in a semicircle. The diameter of the semicircle is 16. What is the sum of the two squares' areas?

Flowers sent by the birds

Seventh degree polynomial

Why was Logo created?

Why isn't there armor to protect from spells in the Potterverse?

Why did the Soviet Union not "grant" Inner Mongolia to Mongolia after World War Two?

Algorithm that generates orthogonal vectors: C++ implementation

How can I tell the difference between fishing for rolls and being involved?

Are fuzzy sets appreciated by OR community?

Which lens has the same capability of lens mounted in Nikon P1000?

Is it impolite to ask for an in-flight catalogue with no intention of buying?

Why does (inf + 0j)*1 evaluate to inf + nanj?

Intheritance at package visibility in Java

How to justify getting additional team member when the current team is doing well?

Clear text passwords in Unix

What is the difference between an astronaut in the ISS and a freediver in perfect neutral buoyancy?

What happens to a net with the Returning Weapon artificer infusion after it hits?

What would influence an alien race to map their planet in a way other than the traditional map of the Earth

Why does C++ have 'Undefined Behaviour' and other languages like C# or Java don't?

Should the average user with no special access rights be worried about SMS-based 2FA being theoretically interceptable?

Windows 10 deletes lots of tiny files super slowly. Anything that can be done to speed it up?

Help in drawing resonance structures in case of polybasic acids

Suffocation while cooking under an umbrella?



How to change the output color of test-connection output


How do I get the color from a hexadecimal color code using .NET?C code changes terminal text color; how to restore defaults? LinuxHow to set the text color of TextView in code?How to change node.js's console font color?Redirect command prompt output to GUI and KEEP COLOR?Hex transparency in colorsChanging color of text background based on conditional statementConvert Test-Connection into BooleanChange output colour in Powershell scriptTest Connection and loop if true or false (change colors…)






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I need to change the color of the text depending on the output of the Test-Connection -quiet cmdlet.



If true green and if False red.



I try to use write-host but without luck



$StartIP = Read-Host -Prompt 'Input Start IP'
$EndIP = Read-Host -Prompt 'Input End IP'
$results= ([int]$StartIP..[int]$EndIP) | % "192.168.128.$($): $(Test-Connection -count 1 -comp 192.168.128.$($) -quiet)"
Read-Host -Prompt "Press Enter to exit"









share|improve this question


























  • You are not using write-host, also output goes to a variable - where do you expect color to show up?

    – LotPings
    Mar 28 at 18:44

















0















I need to change the color of the text depending on the output of the Test-Connection -quiet cmdlet.



If true green and if False red.



I try to use write-host but without luck



$StartIP = Read-Host -Prompt 'Input Start IP'
$EndIP = Read-Host -Prompt 'Input End IP'
$results= ([int]$StartIP..[int]$EndIP) | % "192.168.128.$($): $(Test-Connection -count 1 -comp 192.168.128.$($) -quiet)"
Read-Host -Prompt "Press Enter to exit"









share|improve this question


























  • You are not using write-host, also output goes to a variable - where do you expect color to show up?

    – LotPings
    Mar 28 at 18:44













0












0








0








I need to change the color of the text depending on the output of the Test-Connection -quiet cmdlet.



If true green and if False red.



I try to use write-host but without luck



$StartIP = Read-Host -Prompt 'Input Start IP'
$EndIP = Read-Host -Prompt 'Input End IP'
$results= ([int]$StartIP..[int]$EndIP) | % "192.168.128.$($): $(Test-Connection -count 1 -comp 192.168.128.$($) -quiet)"
Read-Host -Prompt "Press Enter to exit"









share|improve this question
















I need to change the color of the text depending on the output of the Test-Connection -quiet cmdlet.



If true green and if False red.



I try to use write-host but without luck



$StartIP = Read-Host -Prompt 'Input Start IP'
$EndIP = Read-Host -Prompt 'Input End IP'
$results= ([int]$StartIP..[int]$EndIP) | % "192.168.128.$($): $(Test-Connection -count 1 -comp 192.168.128.$($) -quiet)"
Read-Host -Prompt "Press Enter to exit"






powershell colors output






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 18:37









LotPings

24.3k6 gold badges17 silver badges33 bronze badges




24.3k6 gold badges17 silver badges33 bronze badges










asked Mar 28 at 18:14









papa0s0papa0s0

52 bronze badges




52 bronze badges















  • You are not using write-host, also output goes to a variable - where do you expect color to show up?

    – LotPings
    Mar 28 at 18:44

















  • You are not using write-host, also output goes to a variable - where do you expect color to show up?

    – LotPings
    Mar 28 at 18:44
















You are not using write-host, also output goes to a variable - where do you expect color to show up?

– LotPings
Mar 28 at 18:44





You are not using write-host, also output goes to a variable - where do you expect color to show up?

– LotPings
Mar 28 at 18:44












1 Answer
1






active

oldest

votes


















2
















Following your existing code:



$start = (Read-Host -Prompt Start) -as [int]
$end = (Read-Host -Prompt End) -as [int]
$start..$end | ForEach-Object
$ip = "192.168.128.$_"
if (Test-Connection -Count 1 -Quiet -ComputerName $ip)
"$ip TRUE"
else
"$ip FALSE"






share|improve this answer

























  • Thanks! @TheIncorrigible1

    – papa0s0
    Mar 28 at 19:27













Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55404334%2fhow-to-change-the-output-color-of-test-connection-output%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2
















Following your existing code:



$start = (Read-Host -Prompt Start) -as [int]
$end = (Read-Host -Prompt End) -as [int]
$start..$end | ForEach-Object
$ip = "192.168.128.$_"
if (Test-Connection -Count 1 -Quiet -ComputerName $ip)
"$ip TRUE"
else
"$ip FALSE"






share|improve this answer

























  • Thanks! @TheIncorrigible1

    – papa0s0
    Mar 28 at 19:27















2
















Following your existing code:



$start = (Read-Host -Prompt Start) -as [int]
$end = (Read-Host -Prompt End) -as [int]
$start..$end | ForEach-Object
$ip = "192.168.128.$_"
if (Test-Connection -Count 1 -Quiet -ComputerName $ip)
"$ip TRUE"
else
"$ip FALSE"






share|improve this answer

























  • Thanks! @TheIncorrigible1

    – papa0s0
    Mar 28 at 19:27













2














2










2









Following your existing code:



$start = (Read-Host -Prompt Start) -as [int]
$end = (Read-Host -Prompt End) -as [int]
$start..$end | ForEach-Object
$ip = "192.168.128.$_"
if (Test-Connection -Count 1 -Quiet -ComputerName $ip)
"$ip TRUE"
else
"$ip FALSE"






share|improve this answer













Following your existing code:



$start = (Read-Host -Prompt Start) -as [int]
$end = (Read-Host -Prompt End) -as [int]
$start..$end | ForEach-Object
$ip = "192.168.128.$_"
if (Test-Connection -Count 1 -Quiet -ComputerName $ip)
"$ip TRUE"
else
"$ip FALSE"







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 28 at 18:46









TheIncorrigible1TheIncorrigible1

12.5k3 gold badges16 silver badges39 bronze badges




12.5k3 gold badges16 silver badges39 bronze badges















  • Thanks! @TheIncorrigible1

    – papa0s0
    Mar 28 at 19:27

















  • Thanks! @TheIncorrigible1

    – papa0s0
    Mar 28 at 19:27
















Thanks! @TheIncorrigible1

– papa0s0
Mar 28 at 19:27





Thanks! @TheIncorrigible1

– papa0s0
Mar 28 at 19:27




















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55404334%2fhow-to-change-the-output-color-of-test-connection-output%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript