简体   繁体   中英

How to change result of Curl command in powershell

Can you help me this issue? How to change result of Curl command in powershell like this :

在此处输入图片说明

to success or failure

You just use an if statement or a try catch statement and put in the message you want.

($UrlOrIPA = 'stackoverflow.com')

($UrlOrIPA = '10.0.119.61:8101')

try
{
    curl -Uri $UrlOrIPA -UseBasicParsing | Select Status*
    "Testing $UrlOrIPA"
    'Success'
}
catch 
{
    "Testing $UrlOrIPA"
    'Failure'
}




StatusCode StatusDescription
---------- -----------------
       200 OK               
Testing stackoverflow.com
Success


Testing 10.0.119.61:8101
Failure

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM