Displaying 1 result from an estimated 1 matches for "webexception".
Did you mean:
krbexception
2013 Apr 15
5
Using onlyif for Windows exec
...something like this:
onlyif => ''$webRequest =
[System.Net.WebRequest]::Create("http://some-url.test.aspx");
$webRequest.UseDefaultCredentials = $true; try {
if([int]$webRequest.GetResponse().StatusCode -eq "200") { exit 0; } else {
exit 1; } } catch [System.Net.WebException] { exit 1; }''
Which, at the command line, has the correct result. However, when I try to
run this, I get an error saying that $webRequest is not recognised.
Which leads me to think that using variables within the onlyif is not
supported. Is that correct? If so, what is the best appr...