小编deb*_*bal的帖子

用于检查URL状态的PowerShell脚本

与此问题类似,我试图监控一组网站链接是否已启动并正在运行或未响应.我在Internet上找到了相同的PowerShell脚本.

但是,我需要检查更具体的链接,而不是直接的网站链接,例如:

http://mypage.global/Chemical/

http://maypage2:9080/portal/site/hotpot/
Run Code Online (Sandbox Code Playgroud)

当我试图检查这些链接的状态时,我得到以下输出:

URL    StatusCode    StatusDescription    ResponseLength    TimeTaken
http://mypage.global/Chemical/    0
http://maypage2:9080/portal/site/hotpot/    0
Run Code Online (Sandbox Code Playgroud)

以上链接要求我连接到VPN,但我可以从浏览器访问这些链接.

产量Invoke-WebRequest -Uri https://stackoverflow.com/questions/20259251/powershell-script-to-check-the-status-of-a-url:

PS C:\Users\682126> Invoke-WebRequest -Uri https://stackoverflow.com/questions/20259251/powershell-script-to-check-the-status-of-a-url

The term 'Invoke-WebRequest' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

At line:1 char:18
+ Invoke-WebRequest <<<<  -Uri https://stackoverflow.com/questions/20259251/powershell-script-to-check-the-status-of-a-url > tmp.txt
    + CategoryInfo          : ObjectNotFound: (Invoke-WebRequest:String) …
Run Code Online (Sandbox Code Playgroud)

powershell monitoring web-services hyperlink

18
推荐指数
6
解决办法
12万
查看次数

使用PowerShell从远程服务器获取服务状态

如何获取需要用户名和密码登录的远程计算机的服务状态?

我正在尝试使用以下代码找到解决方案:

$serviceStatus = get-service -ComputerName $machineName -Name $service

get-service命令的默认语法是:

Parameter Set: Default
Get-Service [[-Name] <String[]> ] [-ComputerName <String[]> ] [-DependentServices] [-Exclude <String[]> ] [-Include <String[]> ] [-RequiredServices] [ <CommonParameters>]

Parameter Set: DisplayName
Get-Service -DisplayName <String[]> [-ComputerName <String[]> ] [-DependentServices] [-Exclude <String[]> ] [-Include <String[]> ] [-RequiredServices] [ <CommonParameters>]

Parameter Set: InputObject
Get-Service [-ComputerName <String[]> ] [-DependentServices] [-Exclude <String[]> ] [-Include <String[]> ] [-InputObject <ServiceController[]> ] [-RequiredServices] [ <CommonParameters>]
Run Code Online (Sandbox Code Playgroud)

这没有用户名和密码选项.

powershell service remote-server

8
推荐指数
2
解决办法
5万
查看次数

将powershell命令的输出存储在变量中

以下内容:

$sun=PowerShell [DateTime]::Today.AddDays(-8).ToString('dd-MMM-yyyy')

echo %sun %
Run Code Online (Sandbox Code Playgroud)

回声的输出是

PowerShell [DateTime] :: Today.AddDays(-8).ToString('dd-MMM-yyyy')

如何让它输出类似的东西

22九月2013

powershell batch-file

4
推荐指数
1
解决办法
5242
查看次数

Bash 标准错误重定向

我试图验证用户输入的输入是数字类型还是非数字类型。如果是数字类型,那么它将执行必要的操作,否则它将生成我设计的错误消息(不是生成的标准错误)

我一直在使用的步骤是:

1> 对输入执行数学运算。
echo -n "Enter a number : "; read a

现在,如果输入a是数字类型,则操作成功,否则将生成标准错误。

Enter a number : ww

expr: non-numeric argument

我用来重定向标准错误的代码是:

tmp=`expr $a / 1` >&2
Run Code Online (Sandbox Code Playgroud)

我还尝试使用以下代码将其重定向到空文件:

tmp=`expr $a / 1` > /dev/null
Run Code Online (Sandbox Code Playgroud)

但错误仍在显示。

bash standard-error

2
推荐指数
1
解决办法
337
查看次数