invoke-webrequest

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #8844
    deepfriedbutter
    Participant

    I’m trying to run ‘invoke-webrequest’ command to disable a server from out checkscript. The command works fine if I run it though PS natively, but not if i try to run it as a remote command, remote logged or local command. Here is the command I’m using:

    cmd.exe /c echo . | powershell.exe -ExecutionPolicy Bypass -command “Invoke-WebRequest ‘http://exampleurl.com/command:$computer=stop'”

    #10143
    doug
    Moderator

    Works for me without issue. When you say that it doesn’t work, could you be more specific? What exactly happens in BatchPatch?

    #10144
    deepfriedbutter
    Participant

    The command doesn’t disable the box in our script, but it does when I run it directly in PS.

    #10145
    deepfriedbutter
    Participant

    Exit Code: 1

    #10146
    doug
    Moderator

    Considering that you are passing the $computer variable into the web request, this can be run as a local command and does not need to be run on the target computer, so I would focus on running it as a local command for the moment. I know you said it returns exit code 1, but what is returned in the ‘Local Command Output Log’ column?

    I am able to run all of the following commands successfully in BatchPatch as local commands. Obviously I am unable to test your particular web application, so I couldn’t comment on why it would not be doing what you are expecting, but BatchPatch appears to be able to successfully execute invoke-webrequest powershell commands without any issues for me:

    powershell.exe -ExecutionPolicy Bypass -command “Invoke-WebRequest https://mysite.whatever”

    powershell.exe -ExecutionPolicy Bypass -command “Invoke-WebRequest ‘https://mysite.whatever'”

    cmd.exe /c echo . | powershell.exe -ExecutionPolicy Bypass -command “Invoke-WebRequest https://mysite.whatever”

    cmd.exe /c echo . | powershell.exe -ExecutionPolicy Bypass -command “Invoke-WebRequest ‘https://mysite.whatever'”

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.