简体   繁体   English

如何在Powershell中更改Curl命令的结果

[英]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 : 如何在Powershell中更改Curl命令的结果,如下所示:

在此处输入图片说明

to success or failure 成功或失败

You just use an if statement or a try catch statement and put in the message you want. 您只需要使用if语句或try catch语句,然后输入所需的消息。

($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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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