'Batch Script Powershell Snippet on stopping a website
Don't know much about Powershell, but I have created a bunch of scripts, thanks to Stack Overflow and all people who give examples on how to do something. I have a snippet and it works for checking a URL and lets me know if its up, down, or don't exist by catching the 100 the batch scripts works fine. Here's a piece of that script:
Set CheckUrl=`Powershell.exe -nologo -NoProfile -command "try { (Invoke-WebRequest -Uri http://exceedtst.infarmbureau.com/Exceed).StatusCode } catch { "100" }"`
I use a for /F to get the result. Now I'm trying to do the same thing when stopping a website. What I'm currently trying is:
Set CheckUrl=`Powershell.exe -nologo -NoProfile -command "try { (Invoke-Command -ComputerName WB-EXCEEDA-DEV -ScriptBlock { Stop-WebAppPool -Name Exceedtst).value } catch { "100" }"`
When I run the entire script I get:
"( was unexpected at this time."
I don't even know if I get the syntax correct even if what I'm trying to do is possible.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
